Search Unity

Mutiple calls to AssetBundle.LoadAllAssetsAsync crashes Editor & Build

Discussion in 'Scripting' started by HarryCodder, Jan 29, 2016.

  1. HarryCodder

    HarryCodder

    Joined:
    Feb 20, 2015
    Posts:
    84
    Hello everyone,

    I just encountered a problem with AssetBundle.LoadAllAssetsAsync which causes both the editor (in play mode) and a build of our game to crash.

    What we do is loading a lot of small asset bundles (around 350) and each time load all the assets in it with LoadAllAssetsAync. The actual code is essentially this :

    Code (csharp):
    1.  
    2. string[] allBundleNames = manifest.GetAllAssetBundles();
    3. int bundleCount = allBundleNames.Length;
    4. for(int  i = 0; i < bundleCount; ++i)
    5. {
    6.    string bundleName = allBundleNames[i];
    7.    WWW www = WWW.LoadFromCacheOrDownload(bundleName, 0);
    8.    yield return www;
    9.  
    10.    if(null != www.error)
    11.       yield break;
    12.  
    13.    AssetBundle assetBundle = www.assetBundle;
    14.    var request = assetBundle.LoadAllAssetsAsync();
    15.    yield return request; // crash happens here
    16.  
    17.    // this is where do things with the assets,
    18.    // but this does not change anything
    19.  
    20.    assetBundle.Unload(false);
    21. }
    22.  
    The crash does not occur for the same bundle every time so it does not seem to be bundle related.
    But just in case, I'll say that some assets in our bundles have the same name and same extension (but are not of the same type, both inherited from ScriptableObject) :

    Code (csharp):
    1.  
    2. bundle "foobar"
    3. {
    4.     "Art/Illustrations/foobar.png",
    5.     "Data/ScriptableObjectType1/foobar.asset"
    6.     "Data/ScriptableObjectType2/foobar.asset"
    7. }
    8.  
    Also, calling LoadAllAssets instead of LoadAllAssetsAsync fixes the problem (but it's not what I'm trying to do :p).

    This is the error log from the Editor.log file :

    Code (csharp):
    1.  
    2. found != m_ThreadedObjectActivationQueue.end()
    3.  
    4. (Filename: C:/buildslave/unity/build/Runtime/Serialize/PersistentManager.cpp Line: 1154)
    5.  
    6. Crash!!!
    7.  
    8. ...
    9.  
    10. ========== OUTPUTING STACK TRACE ==================
    11.  
    12. 0x000000014050A644 (Unity) PersistentManager::PostReadActivationQueue
    13. 0x0000000140516431 (Unity) PersistentManager::LoadObjectsThreaded
    14. 0x00000001404A1062 (Unity) LoadOperation::Perform
    15. 0x000000014049EA58 (Unity) PreloadManager::ProcessSingleOperation
    16. 0x000000014049EB54 (Unity) PreloadManager::Run
    17. 0x000000014049EB99 (Unity) PreloadManager::Run
    18. 0x00000001405799B6 (Unity) Thread::RunThreadWrapper
    19. 0x00000000774D5A4D (kernel32) BaseThreadInitThunk
    20.  
    21. ========== END OF STACKTRACE ===========
    22.  
    This is in 5.3.2f1.

    Thanks in advance for any help.
     
    Last edited: Jan 29, 2016
    zakirov78 likes this.
  2. MaxFr77

    MaxFr77

    Joined:
    Nov 9, 2015
    Posts:
    7
    Same problem here, although it's hapening with only 3 asset bundles, and files are loaded from local drive. Crashes both editor and android build after the first assetbundle is loaded. I think the problem appeared with 5.3.2f1 (did not have the problem on 5.2 but other stuff happened in between).

    here's my crash log:

    Code (CSharp):
    1. Assetbundle match3gameplay loaded
    2. (Filename: Assets/Scripts/MaxFW/Asset/AssetMgr.cs Line: 144)
    3. (my code trace which shows that the bundle has been loaded in memory, and crash happens on:
    4. AssetBundleRequest loadOperation = remoteBundleFile.LocalBundle.LoadAllAssetsAsync();)
    5.  
    6. found != m_ThreadedObjectActivationQueue.end()
    7. (Filename: C:/buildslave/unity/build/Runtime/Serialize/PersistentManager.cpp Line: 1154)
    8.  
    9. (...)
    10.  
    11. ========== OUTPUTING STACK TRACE ==================
    12.  
    13. 0x000000014050A0C4 (Unity) PersistentManager::PostReadActivationQueue
    14. 0x0000000140515EB1 (Unity) PersistentManager::LoadObjectsThreaded
    15. 0x00000001404A1272 (Unity) LoadOperation::Perform
    16. 0x000000014049EC68 (Unity) PreloadManager::ProcessSingleOperation
    17. 0x000000014049ED64 (Unity) PreloadManager::Run
    18. 0x000000014049EDA9 (Unity) PreloadManager::Run
    19. 0x0000000140579C96 (Unity) Thread::RunThreadWrapper
    20. 0x00000000774359ED (kernel32) BaseThreadInitThunk
    21.  
    22. ========== END OF STACKTRACE ===========
    crash is still present in v5.3.2p3
    few notes:
    - crash is random (happens 95% of the time I'd say)
    - switching to LoadAllAsset (non async version that does the same thing) removes the crash. For now I'll use this crappy workaround.
     
    Last edited: Feb 16, 2016
    zakirov78 likes this.
  3. Bradamante

    Bradamante

    Joined:
    Sep 27, 2012
    Posts:
    300
    I had a similar problem in September with Unity 5.2.x and submitted a repro (#731271). Never heard from them.
     
  4. Sperandii

    Sperandii

    Joined:
    Sep 5, 2013
    Posts:
    1
    I have the same crash with unity 5.3.3, sometimes crashes the editor, sometimes the IOS build. Any news?
     
  5. Tournabus

    Tournabus

    Joined:
    Mar 7, 2016
    Posts:
    1
    Hello,

    I occur the same bug. But for me it's don't crash in Editor, only in build.
    The Asset Bundles are about : 200Mb (Texture and mesh not compress)
    Every Time it's bug on the second assetBundle.
    Version Unity 5.3.4p1

    Code (CSharp):
    1. IEnumerator load(){
    2.                 foreach(var file in new DirectoryInfo(pathAssetBundle).GetFiles("*")){
    3.                     if(file.Extension == ".meta" || file.Extension == ".manifest"){
    4.                         continue;
    5.                     }
    6.                     AssetBundle ab = AssetBundle.LoadFromFile(file.FullName);
    7.  
    8.  
    9.                     //ab.LoadAllAssets<GameObject>();//this don't bug
    10.                     AssetBundleRequest request =  ab.LoadAllAssetsAsync<GameObject>();// each asset contains only one GameObject.
    11.                     while(!request.isDone){
    12.                         yield return null;// tried to yield request and null, in while or not, nothing change
    13.                     }
    14.  
    15.                     // doing something with the request but don't change the bug
    16.                     // I instantiate the GameObject, it's appears on screen before crash.
    17.                     ab.Unload(true);
    18.                     //request = null; //that change nothing
    19.                     yield return null;
    20.                 }
    21.             }
     
    Last edited: May 11, 2016
  6. orkungo

    orkungo

    Joined:
    May 3, 2014
    Posts:
    62
    Did anyone had a solution for that?