Out of memory issues on WebGL

Our game crashes very often with “out of memory” errors on WebGL.

Our heap size is 512mb, but we have investigated and found this is likely due to “Memory file system” that requires additional memory (our game downloads many asset bundles at runtime and stores them to “disk” (IndexedDB).

We are on 2018.4, so changing to UWR and DownloadHandleFile didn’t work (there’s a bug so it doesn’t work - was resolved in 2019.x).

My question - is there any “magical” solution to help us ?

For example:

  1. Use somer other file caching mechanism for storing files?
  2. Avoid caching them, and let the browser handle caching internally?
  3. Anything else?

Can you share the exact error?

And maybe you can re-patch the bug with UnityWebRequest using .jslib file and override the code.

Is the “out of memory” related to out of space in the IndexedDB? I guess you can manually clean it.

What do you mean patch with UWR and jslib ?

You can override some of the JS methods from the framework.unityweb file.

You can see here:

How they override _glClear in the “TransparentBackground.jslib” file.

Does this version of DownloadHandlerFile by Luke Holland help? I’m using Unity 2018 and can confirm that it doesn’t have the bug that the inbuilt one has. I don’t know if it resolves your issue or not, of course.