WebGL limitations

Hello guys! Before choosing PlayCanvas, I would like to understand possible limitations we might have with WebGL and PlayCanvas. For example - what if we have 1Gb+ of assets, how much of that browser will be able to cache? How much RAM can be used by our application?

We are building a mobile MMORPG and looking into PlayCanvas as a potential option.

Hi @Denis_Ermolin,

When it comes to memory management any limitations usually come from the browser and the underlying OS (operating system) running the browser window. PlayCanvas provides tools to help you both with memory management and reduce your video memory allocation footprint.

What kind of assets do you have?

For textures and model assets that get uploaded to the GPU (VRAM) you need to study your target devices. For example on a desktop with a discreet GPU you may easily get away with big VRAM allocations, but on mobile/tablet devices where usually VRAM is shared with regular RAM the limit can be pretty low (especially on iOS).

  1. Use texture compression, especially Basis, to reduce textures VRAM usage: Texture Compression | Learn PlayCanvas

  2. Write a resources manager that scans your active level and unloads from VRAM any resources not required at that moment.

  3. 1GB of resources potentially can be a lot for mobile devices. Consider quality presets where you don’t load at all certain resources (e.g. ambient occlusion maps) or serve lower quality versions.

  4. Apart from VRAM allocation you may have to consider your JS memory footprint. If you are parsing large data sets to setup your levels/scenes make sure that those data references are removed so they can be garbage collected. On mobile, especially iOS, the OS can be very strict with tabs that exhibit large memory allocations and decide to kill the tab.

In any case use the browser dev tools to profile your game, and check this manual page for some advices on performance:

https://developer.playcanvas.com/en/user-manual/optimization/

1 Like

Yeah, so it won’t be 1GB of VRAM/RAM for sure. I am talking about assets themselves. Big games on the mobile easily go beyond 1GB of assets to download. I was wondering - will the browser cache any of it? waiting to download even 200 MB of assets every time is not a good thing. Does PlayCanvas have some kind of dynamic assets loading on demand, to download resources when they are requested in the game?

Yes, uncheck the Preload flag on the asset and it will not get requested (download/loaded) when your app loads, only when it’s required (e.g. from a model rendering a material referencing this texture):

image

Edit: but make sure to unload it when it is not required at any point, if it makes sense to your VRAM allocation strategy. If you do that, from the point you unload it and on, you need to reload it yourself afterwards.

PlayCanvas will work with whatever the browser caches, so if the browser cached those files they won’t be downloaded again. This usually works automatically, if you self host just make sure to setup your server to cache those files.

Just beware, there may be a maximum cache size on some browsers (do some research on this). On Chrome I know there isn’t, it’s calculated as a percentage based on the size of the local disk.

1 Like

We have a document page that has bit more on asset streaming: Preloading and Streaming | Learn PlayCanvas

Seemore is an example project that does a lot of this: https://playcanvas.com/editor/scene/741889

1 Like

Thank you, very helpful.