Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

"Race Condition" when loading assets from bundle async [2018.4.16]

Discussion in 'Asset Bundles' started by livingtarget, Jan 29, 2020.

  1. livingtarget

    livingtarget

    Joined:
    Apr 21, 2015
    Posts:
    83
    Hi,

    Just creating this thread for visibility. I've just submitted this bug to Unity and was wondering if other people are experiencing the same?

    Basically we are seeing:
    Internal: JobTempAlloc has allocations that are more than 4 frames old - this is not allowed and likely a leak

    Which we mostly just ignored because taking the time to submit a bug report is tedious. But in 2018.4.16 it actually stopped loading the asset bundles at all.

    Code (CSharp):
    1. AssetBundleRequest request = assetBundle.LoadAllAssetsAsync<Texture>();
    2. yield return request;
    Request in this case will never yield and never return isDone = true;

    The rather stupid workaround is to immediately reference the asset/assets property. My guess it maybe releases the lock which causes the deadlock, but that's only a guess.
    Code (CSharp):
    1. AssetBundleRequest request = assetBundle.LoadAllAssetsAsync<Texture>();
    2. Object[] assets = request.allAssets;
    3. yield return request;
    or if you load a single asset:
    Code (CSharp):
    1. AssetBundleRequest request = assetBundle.LoadAssetAsync<Texture>();
    2. UnityEngine.Object asset = request.asset;
    3. yield return request;
    Bug Report:
    https://fogbugz.unity3d.com/default.asp?1215446_65bd8kuj67j76bkq
     
    Adrien_Danglard likes this.
  2. Adrien_Danglard

    Adrien_Danglard

    Joined:
    Nov 4, 2019
    Posts:
    18