Hi there
We have an app, built for 64bits with IL2CPP for iOS with Fabric (formerly called Crashlytics) and we are receiving some crashed on AppWillTerminate with all version of Unity (we started working on it on 4.6.3). It’s quite strange, because to it seems to happen once the app is killed from background by OS due to memory pressure
Do you know anything about this? It’s quite weird
Regards
Here is the raw of the crash
Thread : Crashed: com.apple.main-thread
0 libsystem_kernel.dylib 0x3853ddf0 __pthread_kill + 8
1 libsystem_pthread.dylib 0x385bccc7 pthread_kill + 62
2 libsystem_c.dylib 0x384d9909 abort + 76
3 Scooby 0x01865270 GC_stop_world (darwin_stop_world.c:569)
4 Scooby 0x018644f4 GC_stopped_mark (alloc.c:610)
5 Scooby 0x0186407c GC_try_to_collect_inner (alloc.c:460)
6 Scooby 0x01860a6c GC_collect_or_expand (alloc.c:1260)
7 Scooby 0x01860d64 GC_allocobj (alloc.c:1349)
8 Scooby 0x0185f544 GC_generic_malloc_inner (malloc.c:133)
9 Scooby 0x01860e34 GC_generic_malloc (malloc.c:182)
10 Scooby 0x01861870 GC_malloc (misc.c:381)
11 Scooby 0x018b7b10 il2cpp::vm::Object::Clone(Il2CppObject*) (Object.cpp:52)
12 Scooby 0x00b104f8 MulticastDelegate_RemoveImpl_m1569 (GeneratedVirtualInvokers.h:20)
13 Scooby 0x00b11ef0 Delegate_Remove_m1466 (Bulk_mscorlib_0.cpp:61557)
14 Scooby 0x001e6168 EventManager_remove_OnDarkBackgroundOut_m3980 (il2cpp-codegen.h:331)
15 Scooby 0x002fedd0 TutorialEvent_OnDestroy_m4589 (il2cpp-codegen.h:331)
16 Scooby 0x00ce2ce0 RuntimeInvoker_Void_t54(MethodInfo*, void*, void**) (GeneratedInvokers.cpp:12)
17 Scooby 0x018bd048 il2cpp::vm::Runtime::Invoke(MethodInfo*, void*, void**, Il2CppObject**) (Runtime.cpp:307)
18 Scooby 0x0130a344 ScriptingInvocation::Invoke(ScriptingException**, bool) (ScriptingInvocation.cpp:128)
19 Scooby 0x0130a8dc ScriptingInvocationNoArgs::InvokeChecked() (ScriptingInvocationNoArgs.cpp:83)
20 Scooby 0x012fe21c MonoBehaviour::CallMethodInactive(ScriptingMethodIl2Cpp) (MonoBehaviour.cpp:370)
21 Scooby 0x01114664 Unity::GameObject::WillDestroyGameObject() (stl_iterator.h:752)
22 Scooby 0x012a8264 PreDestroyRecursive(Unity::GameObject&, unsigned long*) (stl_vector.h:400)
23 Scooby 0x012a84bc DestroyGameObjectHierarchy(Unity::GameObject&) (GameObject.h:424)
24 Scooby 0x012a8904 DestroyObjectHighLevel(Object*, bool) (GameObjectUtility.cpp:1447)
25 Scooby 0x012c7bd8 CleanupAllObjects(bool) (BaseObject.h:845)
26 Scooby 0x012c8430 CleanupEngine() (SaveAndLoadHelper.cpp:450)
27 Scooby 0x012b004c PlayerCleanup(bool, bool) (Player.cpp:1162)
28 Scooby 0x01005378 UnityCleanup (LibEntryPoint.mm:235)
29 UIKit 0x2d1d18b1 -[UIApplication _terminateWithStatus:] + 192
30 UIKit 0x2d3b8349 -[UIApplication _handleApplicationDectivationWithScene:shouldForceExit:transitionContext:completion:] + 2416
31 UIKit 0x2d3b38e7 -[UIApplication workspaceShouldExit:] + 166
32 FrontBoardServices 0x305c2ec9 __31-[FBSSerialQueue performAsync:]_block_invoke_2 + 16
33 CoreFoundation 0x29ac1fd5 CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK + 12
34 CoreFoundation 0x29ac1299 __CFRunLoopDoBlocks + 216
35 CoreFoundation 0x29abfa37 __CFRunLoopRun + 790
36 CoreFoundation 0x29a0c201 CFRunLoopRunSpecific + 476
37 CoreFoundation 0x29a0c013 CFRunLoopRunInMode + 106
38 GraphicsServices 0x311e8201 GSEventRunModal + 136
39 UIKit 0x2d1b0a59 UIApplicationMain + 1440
40 Scooby 0x000b09e4 main (main.mm:45)
We’ve not seen a crash like this before, from what I can gather. Is this something reproducible, or does it occur intermittently?
Thanks Josh for the time. Yes, it is reproducible if in debug, you start opening others app until WatchDog tries to close yours.
This crash is from our crash tracker tool, crashlytics.
In method “TutorialEvent_OnDestroy” we only desubscribe from an event, but this couldn’t be the error, this line is executed everytime we change scene.
very strange
Thanks for the information. Can you submit a bug report with a project that causes this crash? That will give us the best chance to correct it.
Mwumwu
June 19, 2015, 1:52am
5
Is there an update for this issue? We are having the exact same problem.
Well have you tried the lasted version of Unity to see if the problem still exists?
4.6.6 even patch releases, considering that each new release has had a tone of fixes for iOS 64bit
@Mwumwu
We’ve not yet corrected this issue, as we don’t have a bug report for it yet with a reproducible case. Can you submit a bug report and include a project that causes this? If so, we would love to have a look so that we can correct it. Thanks.
Looking at my crashes in XCode from my live app, I’m seeing a VERY similar crash stack in my app as well. I’ve been unable to repro it locally so far. Like the OP, this looks to be triggered by desubscribing to an event, but in my case, I’m desubscribing in OnDisable (not OnDestroy like the OP).
My app was built with Unity 4.6.6p1
Callabrator88:
Looking at my crashes in XCode from my live app, I’m seeing a VERY similar crash stack in my app as well. I’ve been unable to repro it locally so far. Like the OP, this looks to be triggered by desubscribing to an event, but in my case, I’m desubscribing in OnDisable (not OnDestroy like the OP).
My app was built with Unity 4.6.6p1
@Callabrator88
Thanks for the information. If you are able to reproduce it locally, please let us know, and we will investigate it.
Just to let you know, our latest game update built on 4.6.6p4 still have this issue. But no STR on our side either.
I have soft launched a game a few days ago, with about 100 users right now. We got 9 crashes, apparently from the same device / user, all apparently starting after the game is killed because of memory pressure.
8 of the crashes have a very similar stack, of an exception triggered during GameObject destroy that calls our Log Handler which then tries to allocate memory (and then fail) while reporting the issue to our server.
Thread 0 name:
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x000000019433b270 __pthread_kill + 8
1 libsystem_pthread.dylib 0x00000001943d916c pthread_kill + 108 (pthread.c:1230)
2 libsystem_c.dylib 0x00000001942b2b14 abort + 108 (abort.c:91)
3 Numbers 0x0000000100fcdbd0 GC_stop_world + 172 (darwin_stop_world.c:569)
4 Numbers 0x0000000100fcd1a8 GC_stopped_mark + 56 (alloc.c:610)
5 Numbers 0x0000000100fccd3c GC_try_to_collect_inner + 292 (alloc.c:460)
6 Numbers 0x0000000100fc99ec GC_collect_or_expand + 216 (alloc.c:1260)
7 Numbers 0x0000000100fc9d28 GC_allocobj + 228 (alloc.c:1349)
8 Numbers 0x0000000100fc84b4 GC_generic_malloc_inner + 496 (malloc.c:133)
9 Numbers 0x0000000100fc9de8 GC_generic_malloc + 112 (malloc.c:182)
10 Numbers 0x0000000100fca3fc GC_malloc_atomic + 228 (malloc.c:251)
11 Numbers 0x000000010100c0d0 il2cpp::vm::Object::NewAllocSpecific(TypeInfo*) + 60
12 Numbers 0x000000010100bf00 il2cpp::vm::Object::Box(TypeInfo*, void*) + 92
13 Numbers 0x0000000100392d70 DefaultComparer_Equals_m30481_gshared + 160 (il2cpp-codegen.h:265)
14 Numbers 0x00000001008697a0 Array_IndexOf_TisByte_t502_m85607_gshared + 332 (GeneratedVirtualInvokers.h:64)
15 Numbers 0x00000001005e4854 WWWTranscoder_ByteArrayContains_m19921 + 108 (Bulk_UnityEngine_2.cpp:18551)
16 Numbers 0x00000001005e4530 WWWTranscoder_Encode_m19920 + 288 (Bulk_UnityEngine_2.cpp:18401)
17 Numbers 0x00000001005e3b18 WWWForm_get_data_m10127 + 5716 (Bulk_UnityEngine_2.cpp:18092)
18 Numbers 0x00000001005adb54 WWW__ctor_m2439 + 88 (Bulk_UnityEngine_0.cpp:11945)
19 Numbers 0x00000001002eae80 LoggingCoroutineRunner_PostLog_m8898 + 516 (Bulk_Assembly-CSharp_9.cpp:10547)
20 Numbers 0x00000001002e8bf4 CompositeErrorReporter_SendExceptionToUnity3d_m8841 + 88 (Bulk_Assembly-CSharp_9.cpp:8913)
21 Numbers 0x00000001002e8b6c CompositeErrorReporter_CaptureLog_m8840 + 84 (Bulk_Assembly-CSharp_9.cpp:8883)
22 Numbers 0x00000001007c67d8 RuntimeInvoker_Void_t374_Object_t_Object_t_Int32_t477(MethodInfo*, void*, void**) + 44 (GeneratedInvokers.cpp:29457)
23 Numbers 0x000000010100f578 il2cpp::vm::Runtime::Invoke(MethodInfo*, void*, void**, Il2CppObject**) + 64
24 Numbers 0x0000000100b645c0 ScriptingInvocation::Invoke(ScriptingException**, bool) + 52 (ScriptingInvocation.cpp:128)
25 Numbers 0x0000000100b644bc ScriptingObject* ScriptingInvocation::Invoke<ScriptingObject*>() + 28 (ScriptingInvocation.cpp:108)
26 Numbers 0x0000000100d21004 LogCallbackImplementation(std::string const&, std::string const&, int) + 112 (UnityEngineApplication.cpp:550)
27 Numbers 0x0000000100bab830 DebugStringToFilePostprocessedStacktrace(char const*, char const*, char const*, int, char const*, int, int, int, int) + 268 (LogAssert.cpp:973)
28 Numbers 0x0000000100b6a3a8 Scripting::LogException(ScriptingException*, int, std::string const&) + 156 (Scripting.cpp:699)
29 Numbers 0x0000000100b645f4 ScriptingInvocation::Invoke(ScriptingException**, bool) + 104 (ScriptingInvocation.cpp:144)
30 Numbers 0x0000000100b64974 ScriptingInvocationNoArgs::InvokeChecked() + 56 (ScriptingInvocationNoArgs.cpp:83)
31 Numbers 0x0000000100b5b76c MonoBehaviour::CallMethodInactive(ScriptingMethodIl2Cpp) + 72 (MonoBehaviour.cpp:370)
32 Numbers 0x00000001009edc70 Unity::GameObject::WillDestroyGameObject() + 80 (GameObject.cpp:84)
33 Numbers 0x0000000100b1ded8 PreDestroyRecursive(Unity::GameObject&, unsigned long*) + 112 (GameObjectUtility.cpp:1222)
34 Numbers 0x0000000100b1df5c PreDestroyRecursive(Unity::GameObject&, unsigned long*) + 244 (GameObjectUtility.cpp:1231)
35 Numbers 0x0000000100b1df5c PreDestroyRecursive(Unity::GameObject&, unsigned long*) + 244 (GameObjectUtility.cpp:1231)
36 Numbers 0x0000000100b1e140 DestroyGameObjectHierarchy(Unity::GameObject&) + 40 (GameObjectUtility.cpp:1287)
37 Numbers 0x0000000100b1e50c DestroyObjectHighLevel(Object*, bool) + 896 (GameObjectUtility.cpp:1447)
38 Numbers 0x0000000100b34ff0 CleanupAllObjects(bool) + 276 (SaveAndLoadHelper.cpp:298)
39 Numbers 0x0000000100b3556c CleanupEngine() + 40 (SaveAndLoadHelper.cpp:450)
40 Numbers 0x0000000100b24828 PlayerCleanup(bool, bool) + 60 (Player.cpp:1162)
41 Numbers 0x000000010091dda0 UnityCleanup + 16 (LibEntryPoint.mm:235)
42 UIKit 0x00000001871c285c -[UIApplication _terminateWithStatus:] + 192 (UIApplication.m:4803)
43 UIKit 0x00000001873c8828 -[UIApplication _handleApplicationDectivationWithScene:shouldForceExit:transitionContext:completion:] + 2328 (UIApplication.m:5040)
44 UIKit 0x00000001873c3698 -[UIApplication workspaceShouldExit:] + 180 (UIApplication.m:2199)
45 FrontBoardServices 0x000000018adb13c4 __31-[FBSSerialQueue performAsync:]_block_invoke_2 + 28 (FBSSerialQueue.m:112)
46 CoreFoundation 0x00000001826b0278 CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK + 16 (CFRunLoop.c:1638)
47 CoreFoundation 0x00000001826af380 __CFRunLoopDoBlocks + 308 (CFRunLoop.c:1675)
48 CoreFoundation 0x00000001826ad580 __CFRunLoopRun + 692 (CFRunLoop.c:2524)
49 CoreFoundation 0x00000001825d92d0 CFRunLoopRunSpecific + 392 (CFRunLoop.c:2795)
50 GraphicsServices 0x000000018bc9f6f8 GSEventRunModal + 164 (GSEvent.c:2245)
51 UIKit 0x000000018719efa8 UIApplicationMain + 1484 (UIApplication.m:3039)
52 Numbers 0x000000010005ea4c main + 172 (main.mm:45)
53 libdyld.dylib 0x0000000194222a04 start + 0 (start_glue.s:78)
And here’s the remaining one again at cleanup time (OnDestroy → save → Json Serialization → allocation → crash )
Thread 0 name:
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x000000019433b270 __pthread_kill + 8
1 libsystem_pthread.dylib 0x00000001943d916c pthread_kill + 108 (pthread.c:1230)
2 libsystem_c.dylib 0x00000001942b2b14 abort + 108 (abort.c:91)
3 Numbers 0x0000000101015bd0 GC_stop_world + 172 (darwin_stop_world.c:569)
4 Numbers 0x00000001010151a8 GC_stopped_mark + 56 (alloc.c:610)
5 Numbers 0x0000000101014d3c GC_try_to_collect_inner + 292 (alloc.c:460)
6 Numbers 0x00000001010119ec GC_collect_or_expand + 216 (alloc.c:1260)
7 Numbers 0x0000000101011180 GC_alloc_large + 156 (malloc.c:63)
8 Numbers 0x0000000101011f48 GC_generic_malloc + 464 (malloc.c:197)
9 Numbers 0x00000001010123fc GC_malloc_atomic + 228 (malloc.c:251)
10 Numbers 0x0000000101053e8c il2cpp::vm::Object::AllocatePtrFree(unsigned long, TypeInfo*) + 16
11 Numbers 0x00000001010592f8 il2cpp::vm::String::NewSize(int) + 68
12 Numbers 0x0000000100788188 StringBuilder_InternalEnsureCapacity_m24398 + 288 (Bulk_mscorlib_6.cpp:11571)
13 Numbers 0x000000010077aa38 StringBuilder_Append_m2487 + 212 (Bulk_mscorlib_6.cpp:10851)
14 Numbers 0x0000000100188e94 JsonWriter_WriteValue_m3805 + 1740 (GeneratedVirtualInvokers.h:31)
15 Numbers 0x00000001001ef16c JsonSerializerInternalWriter_WriteMemberInfoProperty_m4785 + 508 (Bulk_Assembly-CSharp_2.cpp:16462)
16 Numbers 0x00000001001ed378 JsonSerializerInternalWriter_SerializeObject_m4790 + 1056 (Bulk_Assembly-CSharp_2.cpp:16919)
17 Numbers 0x00000001001ee3a4 JsonSerializerInternalWriter_SerializeList_m4796 + 1348 (Bulk_Assembly-CSharp_2.cpp:17392)
18 Numbers 0x0000000100172e3c JsonConvert_SerializeObject_m3426 + 324 (GeneratedVirtualInvokers.h:53)
19 Numbers 0x00000001002ea740 BT_ListPuzzle_SaveStatus_m7962 + 200 (GeneratedVirtualInvokers.h:42)
20 Numbers 0x00000001002f7214 ScPuzzle_SavePuzzleProgression_m8179 + 484 (Bulk_Assembly-CSharp_8.cpp:3838)
21 Numbers 0x00000001002f7254 ScPuzzle_OnDestroy_m8180 + 20 (Bulk_Assembly-CSharp_8.cpp:3855)
22 Numbers 0x00000001007cd0a8 RuntimeInvoker_Void_t374(MethodInfo*, void*, void**) + 24 (GeneratedInvokers.cpp:12)
23 Numbers 0x0000000101057578 il2cpp::vm::Runtime::Invoke(MethodInfo*, void*, void**, Il2CppObject**) + 64
24 Numbers 0x0000000100bac5c0 ScriptingInvocation::Invoke(ScriptingException**, bool) + 52 (ScriptingInvocation.cpp:128)
25 Numbers 0x0000000100bac974 ScriptingInvocationNoArgs::InvokeChecked() + 56 (ScriptingInvocationNoArgs.cpp:83)
26 Numbers 0x0000000100ba376c MonoBehaviour::CallMethodInactive(ScriptingMethodIl2Cpp) + 72 (MonoBehaviour.cpp:370)
27 Numbers 0x0000000100a35c70 Unity::GameObject::WillDestroyGameObject() + 80 (GameObject.cpp:84)
28 Numbers 0x0000000100b65ed8 PreDestroyRecursive(Unity::GameObject&, unsigned long*) + 112 (GameObjectUtility.cpp:1222)
29 Numbers 0x0000000100b66140 DestroyGameObjectHierarchy(Unity::GameObject&) + 40 (GameObjectUtility.cpp:1287)
30 Numbers 0x0000000100b6650c DestroyObjectHighLevel(Object*, bool) + 896 (GameObjectUtility.cpp:1447)
31 Numbers 0x0000000100b7cff0 CleanupAllObjects(bool) + 276 (SaveAndLoadHelper.cpp:298)
32 Numbers 0x0000000100b7d56c CleanupEngine() + 40 (SaveAndLoadHelper.cpp:450)
33 Numbers 0x0000000100b6c828 PlayerCleanup(bool, bool) + 60 (Player.cpp:1162)
34 Numbers 0x0000000100965da0 UnityCleanup + 16 (LibEntryPoint.mm:235)
35 UIKit 0x00000001871c285c -[UIApplication _terminateWithStatus:] + 192 (UIApplication.m:4803)
36 UIKit 0x00000001873c8828 -[UIApplication _handleApplicationDectivationWithScene:shouldForceExit:transitionContext:completion:] + 2328 (UIApplication.m:5040)
37 UIKit 0x00000001873c3698 -[UIApplication workspaceShouldExit:] + 180 (UIApplication.m:2199)
38 FrontBoardServices 0x000000018adb13c4 __31-[FBSSerialQueue performAsync:]_block_invoke_2 + 28 (FBSSerialQueue.m:112)
39 CoreFoundation 0x00000001826b0278 CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK + 16 (CFRunLoop.c:1638)
40 CoreFoundation 0x00000001826af380 __CFRunLoopDoBlocks + 308 (CFRunLoop.c:1675)
41 CoreFoundation 0x00000001826ad9a4 __CFRunLoopRun + 1752 (CFRunLoop.c:2740)
42 CoreFoundation 0x00000001825d92d0 CFRunLoopRunSpecific + 392 (CFRunLoop.c:2795)
43 GraphicsServices 0x000000018bc9f6f8 GSEventRunModal + 164 (GSEvent.c:2245)
44 UIKit 0x000000018719efa8 UIApplicationMain + 1484 (UIApplication.m:3039)
45 Numbers 0x00000001000a6a4c main + 172 (main.mm:45)
46 libdyld.dylib 0x0000000194222a04 start + 0 (start_glue.s:78)
App is IL2CPP built 4.6.5f1 based. Device exhibiting issue is running IOS 8.3.
I have soft launched a game a few days ago, with about 100 users right now. We got 9 crashes, apparently from the same device / user, all apparently starting after the game is killed because of memory pressure.
8 of the crashes have a very similar stack, of an exception triggered during GameObject destroy that calls our Log Handler which then tries to allocate memory (and then fail) while reporting the issue to our server.
And here’s the remaining one again at cleanup time (OnDestroy → save → Json Serialization → allocation → crash )
App is IL2CPP built 4.6.5f1 based. Device exhibiting issue is running IOS 8.3.
@jerome-lacoste
Do you know if it is possible that the app is close to the maximum memory available, and might actually be crashing because it runs out of memory?
@JoshPeterson the affected device is an ipad Air (A1474). It has double the amount of RAM as my test device (ipad2) and I have never managed to crash the app on the ipad2 in normal use.
I will try further with swapping the app out etc.
In all cases, it looks like I should be able to take some preventive measures by reducing the amount of work that happens during this shutdown phase. The OnApplicationQuit() seems to be sent too late (Unity - Manual: Order of execution for event functions ). Is there a way for me to programatically check that Unity is shutting down ? Maybe Application.isPlaying is false ?
@JoshPeterson the affected device is an ipad Air (A1474). It has double the amount of RAM as my test device (ipad2) and I have never managed to crash the app on the ipad2 in normal use.
I will try further with swapping the app out etc.
In all cases, it looks like I should be able to take some preventive measures by reducing the amount of work that happens during this shutdown phase. The OnApplicationQuit() seems to be sent too late (Unity - Manual: Order of execution for event functions ). Is there a way for me to programatically check that Unity is shutting down ? Maybe Application.isPlaying is false ?
@jerome-lacoste
That probably indicates it is not actually running out of memory so there is likely a bug somewhere here that we will need to track down. If you are able to get to this something that is reproducible (even intermittently), we would love to have a bug report on it.
The OnApplicationQuit event is usually the place to check, but since it is too late, you might be able to use the AppDomain.DomainUnload event. I’m unsure if that event is actually before or after OnApplicationQuit though. It might be worth a try at least.
@jerome-lacoste
It looks like OnApplicationPause (Unity - Scripting API: MonoBehaviour.OnApplicationPause(bool) ) might be a possibility as well, if you have not already tried it.
The first thing I noticed was the stack
UnityCleanup()
triggers object Destroy ?
something goes wrong, Exception triggered
Log Handler kicks in (the one from the Perf module)
because of its implementation, it allocates objects before starting the coroutine
crash (probably because memory constrained so allocation fail ?!)
I have been trying to create a reproducible case in the past few hours. I managed to create some oddities but no crash. Without knowing more of what’s happening inside the hood, I cannot turn thee symptoms as bugs to report yet.
I have 2 issues:
I didnt’ manage to get the UnityCleanup() call to be triggered upon memory pressure. At least I don’t know where to place my breakpoints in order to see it happening. If I put a breakpoint on a OnDestroy() somewhere, then if the app if killed while in the background or foreground because of memory pressure, calls to OnDestroy() don’t seem to happen. So my point #2 is maybe incorrectly understood:
28 Numbers 0x0000000100b6a3a8 Scripting::LogException(ScriptingException*, int, std::string const&) + 156 (Scripting.cpp:699)
29 Numbers 0x0000000100b645f4 ScriptingInvocation::Invoke(ScriptingException**, bool) + 104 (ScriptingInvocation.cpp:144)
30 Numbers 0x0000000100b64974 ScriptingInvocationNoArgs::InvokeChecked() + 56 (ScriptingInvocationNoArgs.cpp:83)
31 Numbers 0x0000000100b5b76c MonoBehaviour::CallMethodInactive(ScriptingMethodIl2Cpp) + 72 (MonoBehaviour.cpp:370)
32 Numbers 0x00000001009edc70 Unity::GameObject::WillDestroyGameObject() + 80 (GameObject.cpp:84)
What does the above stack mean ? Does this mean that the Destroy() method of a GameObject threw an exception ? Or is the exception coming internally form Unity ?
Any tip on how to trigger a UnityCleanup() call ?
The first thing I noticed was the stack
UnityCleanup()
triggers object Destroy ?
something goes wrong, Exception triggered
Log Handler kicks in (the one from the Perf module)
because of its implementation, it allocates objects before starting the coroutine
crash (probably because memory constrained so allocation fail ?!)
I have been trying to create a reproducible case in the past few hours. I managed to create some oddities but no crash. Without knowing more of what’s happening inside the hood, I cannot turn thee symptoms as bugs to report yet.
I have 2 issues:
I didnt’ manage to get the UnityCleanup() call to be triggered upon memory pressure. At least I don’t know where to place my breakpoints in order to see it happening. If I put a breakpoint on a OnDestroy() somewhere, then if the app if killed while in the background or foreground because of memory pressure, calls to OnDestroy() don’t seem to happen. So my point #2 is maybe incorrectly understood:
What does the above stack mean ? Does this mean that the Destroy() method of a GameObject threw an exception ? Or is the exception coming internally form Unity ?
Any tip on how to trigger a UnityCleanup() call ?
@jerome-lacoste
I’ve been talking with members of our iOS team about this as well, and we have a few suggestions.
First, you can call UnityCleanup directly from managed code if you want to do so to test something. It is exposed in UnityInterface.h.
The section of the stack trace you mentioned does indeed indicate the Destroy is throwing a managed exception, then the LogException call ends up calling LogCallbackImplementation, which in turn attempts to submit something via WWW. I wonder if you can track down the actual exception in Destroy by sending this user a version which does not submit via WWW, but instead writes something to disk that can be retrieved later.
Also, is there some chance that the user is manually killing the app? Or iOS team suggested that might be the cause.
@JoshPeterson
I’ll investigate some more, although travelling all day tomorrow, then partially in holidays.
Some thoughts:
I will try calling UnityCleanup
I will try killing the app manually
I don’t know who the user is, nor can I send a special build right now. The LogCallbackImplementation is yours (the Perf service one).
I will probably try modifying the UnityAppController.mm so that I can track the applicationWillTerminate() callback. That way I shut down the LogCallbackImplementation when this Unity is shutting down.
@JoshPeterson
I’ll investigate some more, although travelling all day tomorrow, then partially in holidays.
Some thoughts:
I will try calling UnityCleanup
I will try killing the app manually
I don’t know who the user is, nor can I send a special build right now. The LogCallbackImplementation is yours (the Perf service one).
I will probably try modifying the UnityAppController.mm so that I can track the applicationWillTerminate() callback. That way I shut down the LogCallbackImplementation when this Unity is shutting down.
@jerome-lacoste
Ahh, thanks, obviously I don’t know everything going on in the Unity code :).
I think your approach sounds good, please let me know what you determine, thanks!
Iamdain
October 30, 2015, 3:20am
20
Seemingly same issue here. On 4.6.9f1, Xcode 7, IL2PCC, happening on wide range of iOS devices, iPhone / iPad, 32 / 64 bit and OS versions 8.4-9.1.
Will investigate further soon but here’s trace:
1 libsystem_kernel.dylib __pthread_kill + 8
2 libsystem_pthread.dylib pthread_kill + 108
3 libsystem_c.dylib abort + 136
4 [APPNAME] GC_stop_world + 172
5 [APPNAME] GC_stopped_mark + 80
6 [APPNAME] GC_try_to_collect_inner + 292
7 [APPNAME] GC_collect_or_expand + 216
8 [APPNAME] GC_allocobj + 228
9 [APPNAME] GC_generic_malloc_inner + 496
10 [APPNAME] GC_generic_malloc + 112
11 [APPNAME] GC_malloc + 232
12 [APPNAME] il2cpp::vm::Object::Clone(Il2CppObject*) + 40
13 [APPNAME] MulticastDelegate_RemoveImpl_m29023 (GeneratedVirtualInvokers.h:33)
14 [APPNAME] UIAnchor_OnDestroy_m3555 (Bulk_Assembly-CSharp_2.cpp:1994)
15 [APPNAME] RuntimeInvoker_Void_t2283(MethodInfo const*, void*, void**) (Il2CppInvokerTable.cpp:828)
16 [APPNAME] il2cpp::vm::Runtime::Invoke(MethodInfo const*, void*, void**, Il2CppObject**) + 64
17 [APPNAME] ScriptingInvocation::Invoke(ScriptingException**, bool) + 52
18 [APPNAME] ScriptingInvocationNoArgs::InvokeChecked() + 56
19 [APPNAME] MonoBehaviour::CallMethodInactive(ScriptingMethodIl2Cpp) + 72
20 [APPNAME] Unity::GameObject::WillDestroyGameObject() + 80
21 [APPNAME] PreDestroyRecursive(Unity::GameObject&, unsigned long*) + 112
22 [APPNAME] PreDestroyRecursive(Unity::GameObject&, unsigned long*) + 244
23 [APPNAME] PreDestroyRecursive(Unity::GameObject&, unsigned long*) + 244
24 [APPNAME] PreDestroyRecursive(Unity::GameObject&, unsigned long*) + 244
25 [APPNAME] PreDestroyRecursive(Unity::GameObject&, unsigned long*) + 244
26 [APPNAME] PreDestroyRecursive(Unity::GameObject&, unsigned long*) + 244
27 [APPNAME] PreDestroyRecursive(Unity::GameObject&, unsigned long*) + 244
28 [APPNAME] PreDestroyRecursive(Unity::GameObject&, unsigned long*) + 244
29 [APPNAME] DestroyGameObjectHierarchy(Unity::GameObject&) + 40
30 [APPNAME] DestroyObjectHighLevel(Object*, bool) + 896
31 [APPNAME] CleanupAllObjects(bool) + 276
32 [APPNAME] CleanupEngine() + 40
33 [APPNAME] PlayerCleanup(bool, bool) + 60
34 [APPNAME] UnityCleanup + 16
35 UIKit -[UIApplication _terminateWithStatus:] + 276
36 UIKit __102-[UIApplication _handleApplicationDeactivationWithScene:shouldForceExit:transitionContext:completion:]_block_invoke1976 + 312
37 UIKit _runAfterCACommitDeferredBlocks + 288
38 UIKit _cleanUpAfterCAFlushAndRunDeferredBlocks + 88
39 UIKit _afterCACommitHandler + 92
40 CoreFoundation CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 28
41 CoreFoundation __CFRunLoopDoObservers + 368
42 CoreFoundation __CFRunLoopRun + 924
43 CoreFoundation CFRunLoopRunSpecific + 380
44 GraphicsServices GSEventRunModal + 176
45 UIKit UIApplicationMain + 200
46 [APPNAME] main (main.mm:37)
47 libdyld.dylib start + 0