Search Unity

AssetBundle.LoadFromFileAsync is blocking main thread.

Discussion in 'Editor & General Support' started by byunghwl, Aug 14, 2018.

  1. byunghwl

    byunghwl

    Joined:
    Jun 13, 2018
    Posts:
    3
    Hello,
    I am using Unity 2017.2 and PRO.

    AssetBundle.LoadFromFileAsync is blocking the main thread.

    When it loads the bundle, this function makes my game scene being freezed.

    The average size of the bundles is 2~ 3 mb and the bundles are compressed in LZ4 format.

    Does anyone have a solution for this?

    Code (CSharp):
    1.  
    2.             var bundleLoadRequest = AssetBundle.LoadFromFileAsync(path);
    3.             yield return bundleLoadRequest;
    4.  
    5.             var loadedAssetBundle = bundleLoadRequest.assetBundle;
    6.             if (loadedAssetBundle == null)
    7.             {
    8.                 Debug.Log("Failed to load AssetBundle!");
    9.                 if (callback != null) callback(null);
    10.                 yield break;
    11.             }
    12.  
    13.             var assetBundleRequest = loadedAssetBundle.LoadAllAssetsAsync(typeof(T));
    14.             yield return assetBundleRequest;
    15.  
    Thanks in advance!
     
    Last edited: Aug 14, 2018