Debugging WebGL crash?

Hi there,

We’re encountering a weird crash - with full debug symbols, and development mode; it seems to come down to this; which from my assessment seems to say we’re using the ThreadPool, except a full search of all the *.cs and *.js files, indicates we aren’t. It’s possible it’s a 3rd party DLL, but at this particular stage when the crash happens, we’re just doing some basic initialisation, and I don’t believe we’re calling any 3rd party functions.

Nonetheless, error is as follows - any help would be appreciated:

missing function: pthread_create
index.html (34,7)

-1
index.html (30,9)

-1
index.html (34,7)

warning: a problem occurred in builtin C++ name demangling; build with -s DEMANGLE_SUPPORT=1 to link in libcxxabi demangling
index.html (34,7)

Invoking error handler due to
abort(-1) at Error
at jsStackTrace (http://domain.com/assets/webgl/Development/WebGL.js:996:2)
at stackTrace (http://domain.com/assets/webgl/Development/WebGL.js:1010:2)
at abort (http://domain.com/assets/webgl/Development/WebGL.js:9908902:2)
at _pthread_create (http://domain.com/assets/webgl/Development/WebGL.js:9049:2)
at _ZN6il2cpp2os10ThreadImpl3RunEPFvPvES2 [il2cpp::os::ThreadImpl::Run(undefined?F?, void, void)] (http://domain.com/assets/webgl/Development/WebGL.js:9446238:41)
at _ZN6il2cpp2os6Thread3RunEPFvPvES2 [il2cpp::os::thread::Run(undefined?F?, void, void)] (http://domain.com/assets/webgl/Development/WebGL.js:9830278:2)
at __ZN6il2cpp2vm21ThreadPoolCompartment13QueueWorkItemEP17Il2CppAsyncResult [il2cpp::vm::ThreadPoolCompartment::QueueWorkItem(Il2CppAsyncResult?*)] (http://domain.com/assets/webgl/Development/WebGL.js:7965867:3)
at __ZN6il2cpp2vm10ThreadPool5QueueEP14Il2CppDelegateP
UnityConfig.js (76,9)

So, interesting update after 36 hours banging my head on this problem.

I can confirm it’s not a 3rd party library, nor any access to the Threadpool by us. I believe the cause, may actually be the LINQ .Select() operator. The crash occurs on a line which broadly reads:

ListA.AddRange(ListB.Select(b => FactoryFunction));

Given our WebGL builds take 30 minutes to compile/test, I can’t 100% verify this as the cause (the FactoryFunction may be triggering it indirectly some how as well), but it looks like someone decided to make either AddRange or Select parallel using the ThreadPool.

That seems unlikely. Are you sure there is no other code/plugin using threads ?

ReSharper’s “Find all references” says no use of ThreadPool or the Thread classes. The Factory is the only external possibility, compile time makes it a bit difficult to test if they are at fault, but I’ll be picking this back up tomorrow to look into in more detail.

OK, so I’ve had a bit of time to look into this further today, I’m waiting for a build to go up now so I can debug further (unfortunately it’s a huge project - or I’d send it to you), but it still looks to be in that location. I traced all the code paths spawned off the factory (thankfully not many), and there really isn’t much there. I’ll see if I can rule that out entirely and get it back to the line I mentioned earlier.

Unfortunately - upgraded to 5.2 this morning, and getting thrown a new error just before where the older error was hitting, so can’t test further yet.

Invalid function pointer called with signature 'vii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)
index.html (34,7)
Invoking error handler due to
abort(303) at Error
   at jsStackTrace (http://domain.com/assets/webgl/Development/WebGL.js:1011:2)
   at stackTrace (http://domain.com/assets/webgl/Development/WebGL.js:1025:2)
   at abort (http://domain.com/assets/webgl/Development/WebGL.js:9727920:2)
   at nullFunc_vii (http://domain.com/assets/webgl/Development/WebGL.js:16118:2)
   at b303 (http://domain.com/assets/webgl/Development/WebGL.js:9718614:2)
   at __ZN5Unity10GameObject32ActivateAwakeRecursivelyInternalENS_19DeactivateOperationER18AwakeFromLoadQueue [Unity::GameObject::ActivateAwakeRecursivelyInternal?N()] (http://domain.com/assets/webgl/Development/WebGL.js:5739070:5)
   at __ZN5Unity10GameObject24ActivateAwakeRecursivelyENS_19DeactivateOperationE [Unity::GameObject::ActivateAwakeRecursively?N()] (http://domain.com/assets/webgl/Development/WebGL.js:8709895:2)
   at __ZN5Unity10GameObject10DeactivateENS_19DeactivateOperationE [Unity::GameObject::smile:eactivate?N()
UnityConfig.js (76,9)

that’s definitely a different problem. Can you reproduce it locally ?

I presume you mean in the editor? No. Editor is fine.

I have the same issue with Unity 5.2 (ie.: your second issue), on a iOS build. It happens to me while unloading a scene loaded from an asset bundle (or loading a different one, hard to say).
Maybe a call stack from XCode (see attached image) will be more helpful, as it seems to contain debug infos from Unity source.

1 Like

Interesting - we’re loading a scene from asset bundles as well.

So, interesting - because we are actually unloading one scene (from asset bundles), and loading another here (albeit via a different method to the first). We delete all the content, then in the next frame (+ web download time), load the new content. I’m littering our build with debug statements at the moment, so hopefully I’ll be able to narrow down the line triggering the fault.

The crash occurs after the second instance, I thought perhaps it was unloading - after you suggested it; but no - appears to be loading. Could I ask a few specific questions:

    1. What method are you using to unpack the asset bundle? (e.g. LoadAssetAsync?)
    1. What’s in the bundle - is it a whole scene, or a individual gameobject - if you’re using LoadAssetAsync is it a or just a in the type parameter?

With the above said though - I just got another stack trace, and this one seems to point to “DelayedDestroy”, which might be unloading again? (just happening later.)

00:44:25.391 uncaught exception: abort(290) at jsStackTrace@http://domain.com/assets/webgl/Development/WebGL.js:1011:12
stackTrace@http://domain.com/assets/webgl/Development/WebGL.js:1025:21
abort@http://domain.com/assets/webgl/Development/WebGL.js:4275506:43
nullFunc_vii@http://domain.com/assets/webgl/Development/WebGL.js:16053:2
b290@http://domain.com/assets/webgl/Development/WebGL.js:4266522:2
__ZN5Unity10GameObject32ActivateAwakeRecursivelyInternalENS_19DeactivateOperationER18AwakeFromLoadQueue [Unity::GameObject::ActivateAwakeRecursivelyInternal?N()]@http://domain.com/assets/webgl/Development/WebGL.js:1751283:5
__ZN5Unity10GameObject24ActivateAwakeRecursivelyENS_19DeactivateOperationE [Unity::GameObject::ActivateAwakeRecursively?N()]@http://domain.com/assets/webgl/Development/WebGL.js:3194528:2
__ZN5Unity10GameObject10DeactivateENS_19DeactivateOperationE [Unity::GameObject::smile:eactivate?N()]@http://domain.com/assets/webgl/Development/WebGL.js:3737824:3
__Z26DestroyGameObjectHierarchyRN5Unity10GameObjectE [DestroyGameObjectHierarchy(Unity::GameObject&)]@http://domain.com/assets/webgl/Development/WebGL.js:3379159:2
__Z22DestroyObjectHighLevelP6Objectb [DestroyObjectHighLevel(bool*)]@http://domain.com/assets/webgl/Development/WebGL.js:1037029:3
__Z22DelayedDestroyCallbackP6ObjectPv [DelayedDestroyCallback(void**)]@http://domain.com/assets/webgl/Development/WebGL.js:4181909:2
__ZN18DelayedCallManager6UpdateEi [DelayedCallManager::Update(int)]@http://domain.com/assets/webgl/Development/WebGL.js:1340774:9
__Z10PlayerLoopbbP10IHookEvent [PlayerLoop(bool, bool, IHookEvent?*)]@http://domain.com/assets/webgl/Development/WebGL.js:438418:3
__ZL8MainLoopv [MainLoop()]@http://domain.com/assets/webgl/Development/WebGL.js:3524116:3
dynCall_v@http://domain.com/assets/webgl/Development/WebGL.js:4266809:2
Runtime.dynCall@http://domain.com/assets/webgl/Development/WebGL.js:231:11
Browser_mainLoop_runner/<@http://domain.com/assets/webgl/Development/WebGL.js:9391:5
Browser.mainLoop.runIter@http://domain.com/assets/webgl/Development/WebGL.js:10709:5
Browser_mainLoop_runner@http://domain.com/assets/webgl/Development/WebGL.js:9387:3
1 <unknown>

The sequence goes like:

  • yield on loading a local transition scene through LoadLevelAsync(string)
  • yield on Resources.UnloadUnusedAssets
  • yield on loading a scene (by name) from a bundle through LoadLevelAsync(string)

I tried to create a simple demo project, but cannot easily reproduce the circumstances.

The bundle contains whole scenes (there are other bundles that have only prefabs).
Bundles are loaded through WWW.LoadFromCacheOrDownload

Edit: The game crashes before UnloadUnusedAssets, probably in the first LoadLevelAsync

We’re doing something very similar here. Just trying to see what the commonalities are.

Our process is slightly different, but still broadly the same - we’re doing:
Coroutine:

  • Load menu scene
  • Delete all objects in the scene (done via foreach)
  • Release all memory references to objects stored in various other static classes.
  • Resources.UnloadUnusedAssets (could this be it?)
  • Create transition object (we’re still in the same “scene”)
  • Yield while waiting for objects to load/download via WWW.LoadFromCacheOrDownload + LoadObjectAsync.
    - While here, this appears to be when the new crash occurs for us now.
  • Instantiate objects once they’ve loaded to load new level
    - This is where the original crash occurred.

Swapped Object.Delete for Object.DestroyImmediate got a new crash.

An error occured running the Unity content on this page. See your browser's JavaScript console for more info. The error was:
uncaught exception: abort(290) at jsStackTrace@http://domain.com/assets/webgl/Development/WebGL.js:1011:12
stackTrace@http://domain.com/assets/webgl/Development/WebGL.js:1025:21
abort@http://domain.com/assets/webgl/Development/WebGL.js:4275550:43
nullFunc_vii@http://domain.com/assets/webgl/Development/WebGL.js:16053:2
b290@http://domain.com/assets/webgl/Development/WebGL.js:4266566:2
__ZN5Unity10GameObject32ActivateAwakeRecursivelyInternalENS_19DeactivateOperationER18AwakeFromLoadQueue [Unity::GameObject::ActivateAwakeRecursivelyInternal?N()]@http://domain.com/assets/webgl/Development/WebGL.js:1751174:5
__ZN5Unity10GameObject24ActivateAwakeRecursivelyENS_19DeactivateOperationE [Unity::GameObject::ActivateAwakeRecursively?N()]@http://domain.com/assets/webgl/Development/WebGL.js:3194572:2
__ZN5Unity10GameObject10DeactivateENS_19DeactivateOperationE [Unity::GameObject::smile:eactivate?N()]@http://domain.com/assets/webgl/Development/WebGL.js:3737868:3
__Z26DestroyGameObjectHierarchyRN5Unity10GameObjectE [DestroyGameObjectHierarchy(Unity::GameObject&)]@http://domain.com/assets/webgl/Development/WebGL.js:3379203:2
__Z22DestroyObjectHighLevelP6Objectb [DestroyObjectHighLevel(bool*)]@http://domain.com/assets/webgl/Development/WebGL.js:1037046:3
__ZN9Scripting35DestroyObjectFromScriptingImmediateEP6Objectb [Scripting::smile:estroyObjectFromScriptingImmediate(bool*)]@http://domain.com/assets/webgl/Development/WebGL.js:4148235:2
__Z30Object_CUSTOM_DestroyImmediateP15ScriptingObjecth [Object_CUSTOM_DestroyImmediate(unsigned char*)]@http://domain.com/assets/webgl/Development/WebGL.js:4021944:2
_Object_DestroyImmediate_m20106@http://domain.com/assets/webgl/Development/WebGL.js:4032347:2
_Object_DestroyImmediate_m868@http://domain.com/assets/webgl/Development/WebGL.js:4165092:2
_SceneManager_ResetSceneForNewLoad_m18015@http://domain.com/assets/webgl/Development/WebGL.js:1843159:191
_SceneManager_SwapScene_m18011@http://domain.com/assets/webgl/Development/WebGL.js:953593:2
_U3CLoadRegionU3Ec__AnonStorey1D3_U3CU3Em__430_m17987@http://domain.com/assets/webgl/Development/WebGL.js:1345148:2
_Action_1_Invoke_m21417_gshared@http://domain.com/assets/webgl/Development/WebGL.js:3328656:4
dynCall_viii@http://domain.com/assets/webgl/Development/WebGL.js:4160483:2
invoke_viii@http://domain.com/assets/webgl/Development/WebGL.js:18375:3
_U3CWebRoutineU3Ec__Iterator61_1_MoveNext_m76595_gshared@http://domain.com/assets/webgl/Development/WebGL.js:362603:11
__Z27RuntimeInvoker_Boolean_t146PK10MethodInfoPvPS2_ [RuntimeInvoker_Boolean_t146?2(void**, undefined?S?*)]@http://domain.com/assets/webgl/Development/WebGL.js:3835776:20
dynCall_iiii@http://domain.com/assets/webgl/Development/WebGL.js:4147225:9
invoke_iiii@http://domain.com/assets/webgl/Development/WebGL.js:17039:10
__ZN6il2cpp2vm7Runtime6InvokeEPK10MethodInfoPvPS5_PP12Il2CppObject [il2cpp::vm::Runtime::Invoke?5(void**, undefined?S?*)]@http://domain.com/assets/webgl/Development/WebGL.js:3397261:8
_il2cpp_runtime_invoke@http://domain.com/assets/webgl/Development/WebGL.js:4110263:9
__Z20il2cpp_invoke_method21ScriptingMethodIl2CppP15ScriptingObjectP18ScriptingArgumentsPP18ScriptingExceptionb [il2cpp_invoke_method?2()]@http://domain.com/assets/webgl/Development/WebGL.js:3633601:8
__ZN19ScriptingInvocation6InvokeEPP18ScriptingExceptionb [ScriptingInvocation::Invoke(bool**)]@http://domain.com/assets/webgl/Development/WebGL.js:2597529:7
__ZN19ScriptingInvocation6InvokeIbEET_PP18ScriptingExceptionb [undefined ScriptingInvocation::Invoke<bool>?T()]@http://domain.com/assets/webgl/Development/WebGL.js:4012187:7
__ZN9Coroutine3RunEv [Coroutine::Run()]@http://domain.com/assets/webgl/Development/WebGL.js:2761446:7
__ZN9Coroutine3RunEv [Coroutine::Run()]@http://domain.com/assets/webgl/Development/WebGL.js:2761471:32
__ZN9Coroutine17ContinueCoroutineEP6ObjectPv [Coroutine::ContinueCoroutine(void**)]@http://domain.com/assets/webgl/Development/WebGL.js:4031401:3
__ZN12WWWDelayCall8CallbackEP6ObjectPv [WWWDelayCall::Callback(void**)]@http://domain.com/assets/webgl/Development/WebGL.js:3388658:2
__ZN18DelayedCallManager6UpdateEi [DelayedCallManager::Update(int)]@http://domain.com/assets/webgl/Development/WebGL.js:1340884:8
__Z10PlayerLoopbbP10IHookEvent [PlayerLoop(bool, bool, IHookEvent?*)]@http://domain.com/assets/webgl/Development/WebGL.js:438369:3
__ZL8MainLoopv [MainLoop()]@http://domain.com/assets/webgl/Development/WebGL.js:3524160:3
dynCall_v@http://domain.com/assets/webgl/Development/WebGL.js:4266853:2
Runtime.dynCall@http://domain.com/assets/webgl/Development/WebGL.js:231:11
Browser_mainLoop_runner/<@http://domain.com/assets/webgl/Development/WebGL.js:9391:5
Browser.mainLoop.runIter@http://domain.com/assets/webgl/Development/WebGL.js:10709:5
Browser_mainLoop_runner@http://domain.com/assets/webgl/Development/WebGL.js:9387:3

OK, spat out another build - this time to echo before nuking any objects in the scene.

It deletes a bunch of objects safely - then the Terrain object, where it crashes. Hopefully helpful to you Marco!

Further update: SetActive(false) on a Terrain object also seems to trigger this happening. (so much for that workaround.)

Synchronous loading of the scene (LoadLevel instead of LoadLevelAsync) gets a little bit further (ie.: crashes at the second LoadLevel instead of the first one) but with a different stack (see attached screenshot).

Have you tried an older version of Unity (5.1.x) ? Any chance you could submit a bug report ?

Everything works fine on Unity 5.1.x.
I will report a bug, but unfortunately failed to create a simple repro case.

Edit: See bug #726806