Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

WebGL and Addressable Asset System: running out of memory

Discussion in 'Addressables' started by ibongomez, Mar 4, 2020.

  1. ibongomez

    ibongomez

    Joined:
    Mar 4, 2020
    Posts:
    7
    Hello,

    We have the following problem:

    upload_2020-3-4_11-36-41.png

    Our team has recently added Addressable Asset System to our project. We followed the documentation for a proper setup and got it working fine INSIDE Unity editor (both with local and remote builds). The problem comes when we try to run this build on a web browser (either locally or hosted on our web server). The game tries to download the complete bundle instead of downloading only the chunk of data it needs, causing the browser to run out of memory and crashing.

    The bundle is about 750MB big so far, and plenty more assets will be added in the future. A solution we NEED TO AVOID is having to manually break that big addressable bundle into smaller pieces, mainly because the amount of assets we will have will make the maintenance of them infeasible.

    We've been searching the documentation and the forums but couldn't find a similar use case or solution which solves our issue.

    What we want to achieve: WebGL build with the smallest build size possible by using Addressable Asset System to download required assets on demand, running in a Nginx based web server.

    What are we missing?

    P.S. If you need any more info about the setup of the project or have any questions about it, please just ask.
     
  2. wirelessdreamer

    wirelessdreamer

    Joined:
    Apr 13, 2016
    Posts:
    128
    Our team has a webgl project using addressables with about 2.3 gigs of assets right now. We've had no memory issues, have you tried packing individually instead of as one in the asset group settings?
     
  3. ibongomez

    ibongomez

    Joined:
    Mar 4, 2020
    Posts:
    7
    Do you mean packing assets in different groups? Or packing each asset one by one in the same group?
     
  4. wirelessdreamer

    wirelessdreamer

    Joined:
    Apr 13, 2016
    Posts:
    128
  5. ibongomez

    ibongomez

    Joined:
    Mar 4, 2020
    Posts:
    7
    We've tried both, Pack Separately and Pack Together. The only difference is one big ~750MB bundle file or a few smaller bundle files. The result is the same: when the game needs to access an asset in a file, it downloads the entire bundle file, and if it is too big, after a minute downloading, the browser crashes.

    Current test group:
    upload_2020-3-4_17-39-13.png
     
  6. ibongomez

    ibongomez

    Joined:
    Mar 4, 2020
    Posts:
    7
    Any other suggestions?
     
  7. wirelessdreamer

    wirelessdreamer

    Joined:
    Apr 13, 2016
    Posts:
    128
  8. ibongomez

    ibongomez

    Joined:
    Mar 4, 2020
    Posts:
    7
    Tried that settings - still not working.

    The problem is that when we make the first call to the Addressables (i.e. loading only 1 material, and of course, using async calls), the game starts loading every bundle, even the ones that have nothing to do with the current call neither have dependencies.

    upload_2020-3-9_16-26-48.png
    Img1: LoadAssetAsync of 1 material, with no depedencies on any other bundle, starts the download of every bundle.
     
  9. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    5,395
    I managed this in UMA by downloading locally using DownloadDependenciesAsync to download the bundles in advance, and then loading items as needed with Addressables.LoadAssetsAsync<UnityEngine.Object>(), and unloading them by releasing the AsyncOperationHandle when they are not needed.
    By default, I put everything into a single group, and "Pack Separately".
     
  10. ibongomez

    ibongomez

    Joined:
    Mar 4, 2020
    Posts:
    7
    Hi Jaimi,

    Wouldn't that give us the same problem we are having? Which is that if we download all the bundle(s) at once, the browser crashes due to the big size they have.
     
  11. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    5,395
    DownloadDependenciesAsync just caches them locally. If your problem is downloading too much, then manage it by downloading in chunks.
     
  12. ibongomez

    ibongomez

    Joined:
    Mar 4, 2020
    Posts:
    7
    Yeah, that's what we are trying to do and why we are here asking for assistance, because we are trying to download only 1 asset (one material), and instead of downloading only the required chunk, the game is downloading every bundle, even the unused ones.
     
  13. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    5,395
    Well, all I can say is download them all using the DownloadDependenciesAsync. That doesn't load them into memory, so you shouldn't run out of memory. Otherwise, I load everything by label. (I label everything programatically) as I need it. It doesn't load more than what I want into memory.

    I have had problems with the addressables system not "taking" my changes because they are cached somewhere. In extreme cases, I've had to remove the data folder it creates, and recreate everything. I've had it double up asset bundles, etc.

    What you want is "pack separately". It will do what you want.
     
  14. andymilsom

    andymilsom

    Unity Technologies

    Joined:
    Mar 2, 2016
    Posts:
    6
    Though you have "Pack Separately" set. You have four folders in the Group. So it is only packing them separately, to four AssetBundles. You should possible create more groups and separate your Assets more. Folders are still ok. But be aware that the contents of the folder are packed together.
    I would also have a read of https://blogs.unity3d.com/2016/09/20/understanding-memory-in-unity-webgl/
     
unityunity