WebGL - Out of Memory problem

Hello Team,
Me and my team have been working on developing a game on Unity.
Also we are using Asset Bundles to keep the initial build size small (Approx 10 MB).
Total size of Asset bundles used : 500-600 MB currently. (30 MB max for any bundle)

But we have been struggling with some Memory issues while running the WebGL build on Google Chrome browser. We get Out of memory problem after playing game for a while (after downloading few asset bundles).
We have gone through the following blog about managing memory :

Also We are using the new API “UnityWebRequest” to download the asset bundles.

And when we use the given XMLHttpRequest plugin this “out of memory” problem start coming more frequently. (It’s like making things worse).

We are too close to publish our game over Facebook but stuck with the memory problem here.

Unity Version : 5.6.2f1
Please check attached screenshot for error log ref.

We will appreciate it if you guys could guide us here, to sort out this Memory issue.
Also please let us know if you need any other details from our end.

Thanks

Hi,

Could you attach a code snippet that shows how you are using UnityWebRequest?

Thanks for the fast reply.
We have simply converted existing AssetBundleManager to use UnityWebRequest instead WWW request.
Below is the code snippet we are using to download AssetBundles :

Case 1: XMLHttpRequest plugin not included (current scenario )
UnityWebRequest download = null;
string url = m_BaseDownloadingURL + assetBundleName;

// For manifest assetbundle, always download it as we don’t have hash for it.
if (isLoadingAssetBundleManifest)
download = UnityWebRequest.GetAssetBundle (url);
else

download = UnityWebRequest.GetAssetBundle (url, m_AssetBundleManifest.GetAssetBundleHash (assetBundleName), 0);
download.Send ();

Case 2: When XMLHttpRequest included in the build,

UnityWebRequest download = null;
string url = m_BaseDownloadingURL + assetBundleName;

download = UnityWebRequest.GetAssetBundle (url);
download.Send ();

Note: While using XMLHttpRequest plugin we get an extra error in browser console i.e. Refused to get unsafe header “ETag”.

However “ETag” is provided in response from server side. (Not sure if this could be leading the frequent Out of Memory problem in this case)

Thanks

Hi Marco,
Have you had time to look into this ?
It’s acting as a blocker for us before we go live.
Hoping for a way out here from Unity team.

Thanks

By looking at the callstack, it might be that you run out of memory allocating a buffer in JS_WebRequest_SetResponseHandler (It would be clearer with a development build callstack).
It might be that the Unity Heap is fragmented and there isn’t enough contiguous memory for allocating the buffer.
You could try to reduce the size of the asset bundles.

You could also try to make a development build, then open the *.framework.unityweb file and add some logging in _JS_WebRequest_SetResponseHandler. maybe print the size of the buffer that is being allocated.