Unity 5 WebGL crash instanciating downloaded assetbundles

Hi,
I’m experiencing a crash of the WebGL engine (actually an exception) that prevents me from loading an asset bundle.

For this crash recipe use the following ingredients :

  • create an assetbundle with the Unity5 new workflow
  • add the file to the streamingassets folder
  • download the file using LoadFromCacheOrDownload
  • try loading it with
    GameObject o = bundle.LoadAsset(m_AssetName);
    and
    m_ObjectToOrbitAround = (Transform)Instantiate(o.GetComponent());
  • AND most of all, use micro mscorlib stripping level.
    Please note that this does not happen if stripping os set to “disabled”.

I include the callstack at the end of this message.

If I disable the stripping, the content loading is really to long.

Did anyone experienced this ?

Is there a workaround ?

Should I fill a bug report ?

Thanks for you help, since I may be missing a contract here, if it does not work since google killed NPAPI…

Callstack :
uncaught exception: abort() at jsStackTrace@http://192.168.1.8/html5Unitytests/clientname/Development/clientname.js:1000:13
stackTrace@http://192.168.1.8/html5Unitytests/clientname/Development/clientname.js:1017:22
abort@http://192.168.1.8/html5Unitytests/clientname/Development/clientname.js:2730163:25
nullFunc_vii@http://192.168.1.8/html5Unitytests/clientname/Development/clientname.js:14472:467
b79@http://192.168.1.8/html5Unitytests/clientname/Development/clientname.js:2725505:46
__ZL15CloneObjectImplP6ObjectR10vector_mapIiiNSt3__14lessIiEE13stl_allocatorINS2_4pairIiiEEL18MemLabelIdentifier89ELi16EEE [CloneObjectImpl?3(unsigned short&)]@http://192.168.1.8/html5Unitytests/clientname/Development/clientname.js:1096981:5
__Z11CloneObjectR6Object [CloneObject(Object?&)]@http://192.168.1.8/html5Unitytests/clientname/Development/clientname.js:1096726:8
__Z34Object_CUSTOM_Internal_CloneSingleP15ScriptingObject [Object_CUSTOM_Internal_CloneSingle(ScriptingObject?
)]@http://192.168.1.8/html5Unitytests/clientname/Development/clientname.js:1545304:10
__Z33Object_Internal_CloneSingle_m3082P8Object_tP10Object_t99P10MethodInfo [Object_Internal_CloneSingle_m3082(MethodInfo?)]@http://192.168.1.8/html5Unitytests/clientname/Development/clientname.js:2491710:8
__Z40Object_Instantiate_TisTransform_t37_m636P8Object_tP13Transform_t37P10MethodInfo [Object_Instantiate_TisTransform_t37_m636(MethodInfo?
)]@http://192.168.1.8/html5Unitytests/clientname/Development/clientname.js:2563637:8
__Z51U3CDownloadAssetBundleU3Ec__Iterator5_MoveNext_m343P41U3CDownloadAssetBundleU3Ec__Iterator5_t62P10MethodInfo [U3CDownloadAssetBundleU3Ec__Iterator5_MoveNext_m343(MethodInfo?)]@http://192.168.1.8/html5Unitytests/clientname/Development/clientname.js:1984711:13
_Z26RuntimeInvoker_Boolean_t71P10MethodInfoPvPS1 [RuntimeInvoker_Boolean_t71?1(void
, undefined?S?)]@http://192.168.1.8/html5Unitytests/clientname/Development/clientname.js:2507271:8
__ZN6il2cpp2vm7Runtime6InvokeEP10MethodInfoPvPS4_PP12Il2CppObject [il2cpp::vm::Runtime::Invoke?4(void**, undefined?S?
)]@http://192.168.1.8/html5Unitytests/clientname/Development/clientname.js:95370:8
_il2cpp_runtime_invoke@http://192.168.1.8/html5Unitytests/clientname/Development/clientname.js:31002:8
__Z20il2cpp_invoke_method21ScriptingMethodIl2CppP15ScriptingObjectP18ScriptingArgumentsPP18ScriptingExceptionb [il2cpp_invoke_method?2()]@http://192.168.1.8/html5Unitytests/clientname/Development/clientname.js:1125599:9
__ZN19ScriptingInvocation6InvokeEPP18ScriptingExceptionb [ScriptingInvocation::Invoke(bool**)]@http://192.168.1.8/html5Unitytests/clientname/Development/clientname.js:1382252:9
__ZN19ScriptingInvocation6InvokeEPP18ScriptingException [ScriptingInvocation::Invoke(ScriptingException?)]@http://192.168.1.8/html5Unitytests/clientname/Development/clientname.js:1382201:8
__ZN19ScriptingInvocation6InvokeIbEET_PP18ScriptingException [undefined ScriptingInvocation::Invoke?T()]@http://192.168.1.8/html5Unitytests/clientname/Development/clientname.js:1382161:8
__ZN9Coroutine3RunEv [Coroutine::Run()]@http://192.168.1.8/html5Unitytests/clientname/Development/clientname.js:1370207:9
__ZN9Coroutine17ContinueCoroutineEP6ObjectPv [Coroutine::ContinueCoroutine(void
)]@http://192.168.1.8/html5Unitytests/clientname/Development/clientname.js:1370155:3
__ZN12WWWDelayCall8CallbackEP6ObjectPv [WWWDelayCall::Callback(void**)]@http://192.168.1.8/html5Unitytests/clientname/Development/clientname.js:1044220:2
__ZN18DelayedCallManager6UpdateEi [DelayedCallManager::Update(int)]@http://192.168.1.8/html5Unitytests/clientname/Development/clientname.js:1095843:10
__Z10PlayerLoopbbP10IHookEvent [PlayerLoop(bool, bool, IHookEvent?*)]@http://192.168.1.8/html5Unitytests/clientname/Development/clientname.js:1273612:4
__ZL8mainloopv [mainloop()]@http://192.168.1.8/html5Unitytests/clientname/Development/clientname.js:1917451:2
dynCall_v@http://192.168.1.8/html5Unitytests/clientname/Development/clientname.js:2724979:7
Runtime.dynCall@http://192.168.1.8/html5Unitytests/clientname/Development/clientname.js:281:14
Browser_mainLoop_runner/<@http://192.168.1.8/html5Unitytests/clientname/Development/clientname.js:10278:13
Browser.mainLoop.runIter@http://192.168.1.8/html5Unitytests/clientname/Development/clientname.js:6867:13
Browser_mainLoop_runner@http://192.168.1.8/html5Unitytests/clientname/Development/clientname.js:10274:9

So, if this only happens with stripping enabled, what you are seeing here probably is that the code needed to load the classes in your AssetBundle is being stripped. We cannot automatically prevent that, as we cannot know at player build time which types you might be using in any AssetBundles you may want to load.

This was always the same on iOS (where we supported similar stripping for a while now). One solution is to use a link.xml file, as explained here, to whitelist types you don’t want to be stripped:

Thanks Jonas!!!
Works like a charm (I had to add the shader class as well).

Thanks again.