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 :
string[] allBundleNames = manifest.GetAllAssetBundles();
int bundleCount = allBundleNames.Length;
for(int i = 0; i < bundleCount; ++i)
{
string bundleName = allBundleNames[i];
WWW www = WWW.LoadFromCacheOrDownload(bundleName, 0);
yield return www;
if(null != www.error)
yield break;
AssetBundle assetBundle = www.assetBundle;
var request = assetBundle.LoadAllAssetsAsync();
yield return request; // crash happens here
// this is where do things with the assets,
// but this does not change anything
assetBundle.Unload(false);
}
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) :
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:
Assetbundle match3gameplay loaded
(Filename: Assets/Scripts/MaxFW/Asset/AssetMgr.cs Line: 144)
(my code trace which shows that the bundle has been loaded in memory, and crash happens on:
AssetBundleRequest loadOperation = remoteBundleFile.LocalBundle.LoadAllAssetsAsync();)
found != m_ThreadedObjectActivationQueue.end()
(Filename: C:/buildslave/unity/build/Runtime/Serialize/PersistentManager.cpp Line: 1154)
(...)
========== OUTPUTING STACK TRACE ==================
0x000000014050A0C4 (Unity) PersistentManager::PostReadActivationQueue
0x0000000140515EB1 (Unity) PersistentManager::LoadObjectsThreaded
0x00000001404A1272 (Unity) LoadOperation::Perform
0x000000014049EC68 (Unity) PreloadManager::ProcessSingleOperation
0x000000014049ED64 (Unity) PreloadManager::Run
0x000000014049EDA9 (Unity) PreloadManager::Run
0x0000000140579C96 (Unity) Thread::RunThreadWrapper
0x00000000774359ED (kernel32) BaseThreadInitThunk
========== 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.
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
IEnumerator load(){
foreach(var file in new DirectoryInfo(pathAssetBundle).GetFiles("*")){
if(file.Extension == ".meta" || file.Extension == ".manifest"){
continue;
}
AssetBundle ab = AssetBundle.LoadFromFile(file.FullName);
//ab.LoadAllAssets<GameObject>();//this don't bug
AssetBundleRequest request = ab.LoadAllAssetsAsync<GameObject>();// each asset contains only one GameObject.
while(!request.isDone){
yield return null;// tried to yield request and null, in while or not, nothing change
}
// doing something with the request but don't change the bug
// I instantiate the GameObject, it's appears on screen before crash.
ab.Unload(true);
//request = null; //that change nothing
yield return null;
}
}