Search Unity

Async asset bundle loading gets stuck when also starting async scene load

Discussion in 'Asset Bundles' started by Baste, Jul 28, 2019.

  1. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    This is probably a bug, but I wanted to check before I put in the time to make a repro.

    I had some code that essentially did this:

    Code (csharp):
    1. AssetBundle.LoadFromFileAsync(path);
    2.  
    3. foreach(var scene in scenes) {
    4.     SceneManager.LoadSceneAsync(scene, LoadSceneMode.Additive);
    5. }
    This caused the asset bundle loading to get stuck at 0.9, and never finish. (Yes, allowSceneActivation was on). After digging a bunch, it turned out that this fixed it:

    Code (csharp):
    1. var loadOp = AssetBundle.LoadFromFileAsync(path);
    2.  
    3. yield return loadOp;
    4.  
    5. foreach(var scene in scenes) {
    6.     SceneManager.LoadSceneAsync(scene, LoadSceneMode.Additive);
    7. }
    This has to be a bug, right? I'm not sure if it's a good idea to have the asset bundle load at the same time as the scenes, but it should be possible without breaking the bundle load.
     
    Last edited: Jul 29, 2019
  2. M_R

    M_R

    Joined:
    Apr 15, 2015
    Posts:
    559
    you are loading the scenes synchronously.
    there can be one loadOp active at a time, so the scene load waits for the bundle while blocking the frame, but the bundle loadOp is waiting the end of frame to complete. deadlock.

    try using
    SceneManager.LoadSceneAdditiveAsync
     
  3. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    I'm already using Async, updated my post. I wrote the code instead of copy-pasting it because I wanted to strip out unnecessary info, sorry about that.
     
  4. M_R

    M_R

    Joined:
    Apr 15, 2015
    Posts:
    559
    then it may be a bug.

    is any of your scenes included in the bundle?

    what happens if you try that with multiple bundles and/or multiple scenes? (without mixing them)
    or if you start loading the scene, load the bundle and monitor the scene load progress?
    also try other API than load from file.

    do the scenes finish loading with your setup? or they are all stuck at 0.9?