Search Unity

Feedback Addressables AssetLoading is blocked by Async Scene Loading

Discussion in 'Addressables' started by DRI-Ross, May 1, 2019.

  1. DRI-Ross

    DRI-Ross

    Joined:
    Sep 24, 2018
    Posts:
    5
    Possibly a bug, definitely something that needs flagging, if only to save someone else.
    I just had a very annoying issue for the past day, which looked something like this:

    1. I had a boot scene which initialised and download some UI data as well as setting up some gameplay scenes.
    2. I used a simple coroutine to load everything in, with the scenes not allowed to activate until all the boot functions read as complete.

    However, I found this: if you have a scene in the 'is Loading' state, the Addressable LoadAsset/LoadAssets Functions are blocked until you load the scenes in.

    There is no warning or console error for this, it just appears as though the addressable system has stopped.

    Moral of the story - don't prevent scenes from loading pending addressable operations completeing - you just lock your whole system.
     
    lanpartygamesstudio likes this.
  2. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    639
    That's quite a gotcha. Have you put a bug through? It definitely does not sound like desired behaviour to me.
     
  3. DRI-Ross

    DRI-Ross

    Joined:
    Sep 24, 2018
    Posts:
    5
    Not yet, I'll need to assemble an example case so they can see the problem in action.
     
  4. DRI-Ross

    DRI-Ross

    Joined:
    Sep 24, 2018
    Posts:
    5
    Submitted a bug report and they've reproduced it, so now it's a waiting game. For now the workaround is to simply not set AsyncOperation.allowSceneActivation to false while the addressable system is active.
     
    AlkisFortuneFish likes this.
  5. Ryanc_unity

    Ryanc_unity

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    236
    All async operations go through the same single background loading system (PreloadManager). So if you prevent an async scene load call using this method, all other async calls in the PreloadManager that were added after it will be stuck waiting for it to finish.
     
  6. bagelbaker

    bagelbaker

    Joined:
    Jun 5, 2017
    Posts:
    21
    I just ran into the issue posted here while trying to resolve this issue https://forum.unity.com/threads/ord...scene-loading-completion-not-the-same.736520/

    I want to trigger multiple Addressables.LoadSceneAsync() with allowSceneActivation to false and once they're all loaded, activate them in the order that I need. This works in Fast Mode but not in Play Packed mode nor in Builds.

    Would loading them one after another instead of in "parallel" be less efficient or is it the same? Would there be any other way to resolve this?
     
    lanpartygamesstudio likes this.
  7. Ryanc_unity

    Ryanc_unity

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    236
    Loading sequentially is just as efficient as they are all loaded sequentially anyways internally as there is a single background system responsible for loading data. That being said, the behavior of Addressables.LoadSceneAsync not returning the loaded results in the same order I would classify as a bug that we should fix. Please open a fogbug case with this issue for Addressables.
     
  8. bagelbaker

    bagelbaker

    Joined:
    Jun 5, 2017
    Posts:
    21
    Our project is huge so I tried reproducing in a small repro project with Repro Project Wizard but no success so far.

    In our main project, I noticed the following, when calling
    1. addressables 1.1.5: No bug. In the Editor hierarchy, I can see all 4 scenes loaded async additive appear at once, greyed out and empty. Then they start loading in order.
    2. addressables 1.1.7 and 1.1.10: Bug. In the editor, scene 4 appears, then loads first, then scenes 2 and 3 appears greyed out, then loads, then scene 1 appears last and is loaded.
    We call Addressables.LoadSceneAsync() on the 4 scenes in the same frame in order.
    Scene 1 is in a bundle and scene 2, 3, 4 and the main scene from which we call LoadSceneAsync is in another bundle.

    I will try to have a smaller repro project and create a bug report.
     
  9. bagelbaker

    bagelbaker

    Joined:
    Jun 5, 2017
    Posts:
    21
    Ok, while typing out the previous message and making a small repro project, I managed to find the root cause of my problem.

    When calling Addressables.LoadSceneAsync on multiple scenes in the same frame, scenes from the same bundle as the current scene will always be loaded first, then scenes from other bundles will be loaded afterwards. This is new from Addressables v1.1.7

    Detailed info in the bug report: https://fogbugz.unity3d.com/default.asp?1182127_o2mi81jj62vbad0a

    The workaround is to change the setup of our scene bundles.
     
    Last edited: Sep 5, 2019
  10. Ryanc_unity

    Ryanc_unity

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    236
    Hmm, I could see that being as designed as Loading a bundle is an async operation that takes place separately from Loading a scene. So when you think about it this way, internally what happens is that you trigger scene loading for 5 scenes, the first 2 are in bundles that are not already loaded so you end up with an async operation stack like this:

    LoadBundle1 (scene1)
    LoadBundle2 (scene2)
    LoadScene3
    LoadScene4
    LoadScene5

    Then once the bundles are loaded, the load scene operation gets pushed onto the stack:

    LoadScene3
    LoadScene4
    LoadScene5
    LoadScene1
    LoadScene2