Call AssetBundle.LoadAssetAsync in Coroutine cause engine freeze

When I trying to load asset from a bundle with AssetBundle.LoadAssetAsync, it workes fine. But if I start 2 Coroutines, it will cause engine freeze.

The code seems fine. Could it be that bundleA has references to assets in bundleB and vice versa? attempting to open both at the same time could then deadlock.

Thanks, JC_SummitTech! :smile:
I found the problem maybe caused by SceneManager.LoadSceneAsync and AssetBundle.LoadAssetAsync.Here is my steps:

  1. Build scene into bundle.
  2. Use AssetBundle.LoadAssetAsync load this bundle.
  3. Load scene with SceneManager.LoadSceneAsync.
  4. When SceneManager.LoadSceneAsync done, load other assets with AssetBundle.LoadAssetAsync.
    Unity freezed in AssetBundle.LoadAssetAsync(Not every time).

All assets were build into bundles, and I trying to make the whole asset loading progress is asynchronous.

Necro’ing this post just to say this issue still remains in 2019.4.32f1 . Won’t check on newer builds.

This code is a guaranteed softlock.

IEnumerator LoadStage()
{
var op = SceneManager.LoadSceneAsync(“MainMenu”, LoadSceneMode.Single);

op.allowSceneActivation = false;

while(op.progress < 0.9f)
yield return null;

var request = bundle.LoadAssetAsync(“MenuBG”);

while(!request.isDone)
yield return null;

op.allowSceneActivation = true;

}

The workaround basically is to avoid this by loading from the bundle first, then the SceneManager.

Or just read the manual, it is laid out how it works in advance. Why would you try it anyway?
https://docs.unity3d.com/ScriptReference/AsyncOperation-allowSceneActivation.html