Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Crash DebugStringToFilePostprocessedStacktrace

Discussion in 'iOS and tvOS' started by C-Gabriel, Dec 2, 2023.

  1. C-Gabriel

    C-Gabriel

    Joined:
    Jan 27, 2016
    Posts:
    119
    Hi,

    We're seeing this crash a lot on iOS in Firebase (25% crash rate) and it seems to happen while the app is in the background. Android seems fine. We have no idea what might be causing it, but it might be related to sending some events via UnityWebRequest when the app goes in the background (some SDKs maybe)

    Unity 2022.3.14f1

    upload_2023-12-2_15-52-22.png

    Code (CSharp):
    1. Crashed: com.apple.main-thread
    2. 0  libsystem_kernel.dylib         0xa01c __pthread_kill + 8
    3. 1  libsystem_pthread.dylib        0x5680 pthread_kill + 268
    4. 2  libsystem_c.dylib              0x27dd0 raise + 32
    5. 3  UnityFramework                 0x1bbf088 DebugStringToFilePostprocessedStacktrace(DebugStringToFileData const&) + 222 (String.h:222)
    6. 4  UnityFramework                 0x1bbf550 DebugStringToFile(DebugStringToFileData const&) + 222 (String.h:222)
    7. 5  UnityFramework                 0x1800968 UnityWebRequestManager::Register(UnityWebRequest*) + 222 (String.h:222)
    8. 6  UnityFramework                 0x180084c UnityWebRequest::UnityWebRequest(MemLabelId) + 251 (UnityWebRequest.cpp:251)
    9. 7  UnityFramework                 0x5ca6fd4 _GLOBAL__sub_I_External_il2cpp_builds_libil2cpp_os_Posix_2.cpp.cold.1 + 36 (External_il2cpp_builds_libil2cpp_os_Posix_2.cpp:36)
    10. 8  UnityFramework                 0x5885aac _GLOBAL__sub_I_External_il2cpp_builds_libil2cpp_os_Posix_2.cpp.cold.1 + 36 (External_il2cpp_builds_libil2cpp_os_Posix_2.cpp:36)
    11. 9  UnityFramework                 0x5884760 _GLOBAL__sub_I_External_il2cpp_builds_libil2cpp_os_Posix_2.cpp.cold.1 + 36 (External_il2cpp_builds_libil2cpp_os_Posix_2.cpp:36)
    12. 10 UnityFramework                 0x5878e74 _GLOBAL__sub_I_External_il2cpp_builds_libil2cpp_os_Posix_2.cpp.cold.1 + 36 (External_il2cpp_builds_libil2cpp_os_Posix_2.cpp:36)
    13. 11 UnityFramework                 0x29b0d74 il2cpp::vm::Runtime::InvokeWithThrow(MethodInfo const*, void*, void**) + 606 (Runtime.cpp:606)
    14. 12 UnityFramework                 0x29b0cbc il2cpp::vm::Runtime::Invoke(MethodInfo const*, void*, void**, Il2CppException**) + 600 (Runtime.cpp:600)
    15. 13 UnityFramework                 0x1617a68 scripting_method_invoke(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingArguments&, ScriptingExceptionPtr*, bool) + 290 (ScriptingApi_Il2Cpp.cpp:290)
    16. 14 UnityFramework                 0x1624f8c ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool) + 298 (ScriptingInvocation.cpp:298)
    17. 15 UnityFramework                 0x1627b34 ScriptingInvocation::InvokeChecked(ScriptingExceptionPtr*) + 72 (ScriptingInvocation.h:72)
    18. 16 UnityFramework                 0x1676698 SerializableManagedRef::CallMethod(Object&, ScriptingMethodPtr) + 60 (ScriptingNativeTypes.h:60)
    19. 17 UnityFramework                 0x1634260 MonoBehaviour::WillDestroyComponent() + 81 (MonoBehaviour.h:81)
    20. 18 UnityFramework                 0x14478b0 GameObject::WillDestroyGameObject() + 111 (GameObject.cpp:111)
    21. 19 UnityFramework                 0x15237c4 PreDestroyRecursive(GameObject&, unsigned long*) + 612 (dynamic_array.h:612)
    22. 20 UnityFramework                 0x1524054 DestroyObjectHighLevel_Internal(Object*, bool) + 517 (GameObject.h:517)
    23. 21 UnityFramework                 0x151cbb4 CleanupAllObjects() + 431 (SaveAndLoadHelper.cpp:431)
    24. 22 UnityFramework                 0x151d28c CleanupEngine() + 585 (SaveAndLoadHelper.cpp:585)
    25. 23 UnityFramework                 0x152da3c PlayerCleanup(bool) + 701 (Player.cpp:701)
    26. 24 UnityFramework                 0x1c62828 UnityCleanup + 222 (LibEntryPoint.mm:222)
    27. 25 UnityFramework                 0xfcb8 -[UnityAppController applicationWillTerminate:] + 527 (UnityAppController.mm:527)
    28. 26 UIKitCore                      0xe1023c -[UIApplication _terminateWithStatus:] + 196
    29. 27 UIKitCore                      0x139000 -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 112
    30. 28 UIKitCore                      0x5f9d6c -[_UISceneLifecycleMultiplexer forceExitWithTransitionContext:scene:] + 164
    31. 29 UIKitCore                      0xe0aea4 -[UIApplication workspaceShouldExit:withTransitionContext:] + 164
    32. 30 FrontBoardServices             0x47fc4 __63-[FBSWorkspaceScenesClient willTerminateWithTransitionContext:]_block_invoke_2 + 72
    33. 31 FrontBoardServices             0xe19c -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 168
    34. 32 FrontBoardServices             0x47f64 __63-[FBSWorkspaceScenesClient willTerminateWithTransitionContext:]_block_invoke + 128
    35. 33 libdispatch.dylib              0x4300 _dispatch_client_callout + 20
    36. 34 libdispatch.dylib              0x7d48 _dispatch_block_invoke_direct + 284
    37. 35 FrontBoardServices             0xa520 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 52
    38. 36 FrontBoardServices             0xa4a0 -[FBSMainRunLoopSerialQueue _targetQueue_performNextIfPossible] + 240
    39. 37 FrontBoardServices             0xa378 -[FBSMainRunLoopSerialQueue _performNextFromRunLoopSource] + 28
    40. 38 CoreFoundation                 0x3731c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
    41. 39 CoreFoundation                 0x36598 __CFRunLoopDoSource0 + 176
    42. 40 CoreFoundation                 0x34dac __CFRunLoopDoSources0 + 340
    43. 41 CoreFoundation                 0x33a88 __CFRunLoopRun + 828
    44. 42 CoreFoundation                 0x33668 CFRunLoopRunSpecific + 608
    45. 43 GraphicsServices               0x35ec GSEventRunModal + 164
    46. 44 UIKitCore                      0x22c2b4 -[UIApplication _run] + 888
    47. 45 UIKitCore                      0x22b8f0 UIApplicationMain + 340
    48. 46 UnityFramework                 0x138bc -[UnityFramework runUIApplicationMainWithArgc:argv:] + 96 (main.mm:96)
    49. 47 [App Name]                     0x7cac main + 28 (main.mm:28)
    50. 48 ???                            0x1cff2edcc (Missing)
     
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,703
    This crash should be fixed in latest Unity versions.
    This isn't app going to background, it is terminating (possibly OS lacks resources and decided to shut it down). Sending UnityWebRequest during shut down is a bad idea - it will be aborted, very likely before it was sent.
     
  3. marcus-qiiwi

    marcus-qiiwi

    Joined:
    Jul 29, 2013
    Posts:
    22
    We see the same crash in Unity 2022.3.14f1

    Code (CSharp):
    1. Crashed: com.apple.main-thread
    2. 0  libsystem_kernel.dylib         0xa01c __pthread_kill + 8
    3. 1  libsystem_pthread.dylib        0x5680 pthread_kill + 268
    4. 2  libsystem_c.dylib              0x27dd0 raise + 32
    5. 3  UnityFramework                 0x1a5d670 DebugStringToFilePostprocessedStacktrace(DebugStringToFileData const&) + 222 (String.h:222)
    6. 4  UnityFramework                 0x1a5db38 DebugStringToFile(DebugStringToFileData const&) + 222 (String.h:222)
    7. 5  UnityFramework                 0x16db9a8 UnityWebRequestManager::Register(UnityWebRequest*) + 222 (String.h:222)
    8. 6  UnityFramework                 0x16db88c UnityWebRequest::UnityWebRequest(MemLabelId) + 251 (UnityWebRequest.cpp:251)
    9. 7  UnityFramework                 0x1717784 CrashReporting::CrashReporter::SendReport(CrashReporting::CrashReport&) + 461 (CrashReporter.cpp:461)
    10. 8  UnityFramework                 0x1716d88 CrashReporting::CrashReporter::HandleLog(DebugStringToFileData const&, LogType, bool) + 342 (CrashReporter.cpp:342)
    11. 9  UnityFramework                 0x1a5d7dc CallbackArray3<DebugStringToFileData const&, LogType, bool>::Invoke(DebugStringToFileData const&, LogType, bool) + 405 (CallbackArray.h:405)
    12. 10 UnityFramework                 0x1a5d288 DebugStringToFilePostprocessedStacktrace(DebugStringToFileData const&) + 1026 (LogAssert.cpp:1026)
    13. 11 UnityFramework                 0x1531e24 Scripting::LogExceptionFromManaged(ScriptingExceptionPtr, int, char const*, bool, Scripting::LogExceptionFromMangedSettings const*) + 935 (Scripting.cpp:935)
    14. 12 UnityFramework                 0x153093c Scripting::LogException(ScriptingExceptionPtr, int, char const*, bool) + 947 (Scripting.cpp:947)
    15. 13 UnityFramework                 0x152ff04 ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool) + 310 (ScriptingInvocation.cpp:310)
    16. 14 UnityFramework                 0x1532ac4 ScriptingInvocation::InvokeChecked(ScriptingExceptionPtr*) + 72 (ScriptingInvocation.h:72)
    17. 15 UnityFramework                 0x1581118 SerializableManagedRef::CallMethod(Object&, ScriptingMethodPtr) + 60 (ScriptingNativeTypes.h:60)
    18. 16 UnityFramework                 0x153ecbc MonoBehaviour::RemoveFromManager() + 372 (MonoBehaviour.cpp:372)
    19. 17 UnityFramework                 0x133c434 GameObject::ActivateAwakeRecursivelyInternal(DeactivateOperation, AwakeFromLoadQueue&) + 220 (GameObject.cpp:220)
    20. 18 UnityFramework                 0x133c3bc GameObject::ActivateAwakeRecursivelyInternal(DeactivateOperation, AwakeFromLoadQueue&) + 213 (GameObject.cpp:213)
    21. 19 UnityFramework                 0x133c3bc GameObject::ActivateAwakeRecursivelyInternal(DeactivateOperation, AwakeFromLoadQueue&) + 213 (GameObject.cpp:213)
    22. 20 UnityFramework                 0x133c3bc GameObject::ActivateAwakeRecursivelyInternal(DeactivateOperation, AwakeFromLoadQueue&) + 213 (GameObject.cpp:213)
    23. 21 UnityFramework                 0x133c3bc GameObject::ActivateAwakeRecursivelyInternal(DeactivateOperation, AwakeFromLoadQueue&) + 213 (GameObject.cpp:213)
    24. 22 UnityFramework                 0x133c3bc GameObject::ActivateAwakeRecursivelyInternal(DeactivateOperation, AwakeFromLoadQueue&) + 213 (GameObject.cpp:213)
    25. 23 UnityFramework                 0x133c3bc GameObject::ActivateAwakeRecursivelyInternal(DeactivateOperation, AwakeFromLoadQueue&) + 213 (GameObject.cpp:213)
    26. 24 UnityFramework                 0x133c3bc GameObject::ActivateAwakeRecursivelyInternal(DeactivateOperation, AwakeFromLoadQueue&) + 213 (GameObject.cpp:213)
    27. 25 UnityFramework                 0x133c3bc GameObject::ActivateAwakeRecursivelyInternal(DeactivateOperation, AwakeFromLoadQueue&) + 213 (GameObject.cpp:213)
    28. 26 UnityFramework                 0x133c3bc GameObject::ActivateAwakeRecursivelyInternal(DeactivateOperation, AwakeFromLoadQueue&) + 213 (GameObject.cpp:213)
    29. 27 UnityFramework                 0x133c3bc GameObject::ActivateAwakeRecursivelyInternal(DeactivateOperation, AwakeFromLoadQueue&) + 213 (GameObject.cpp:213)
    30. 28 UnityFramework                 0x133c4dc GameObject::ActivateAwakeRecursively(DeactivateOperation) + 247 (GameObject.cpp:247)
    31. 29 UnityFramework                 0x133c998 GameObject::Deactivate(DeactivateOperation) + 519 (GameObject.cpp:519)
    32. 30 UnityFramework                 0x141d4a0 DestroyObjectHighLevel_Internal(Object*, bool) + 1840 (GameObjectUtility.cpp:1840)
    33. 31 UnityFramework                 0x14153d8 CleanupAllObjects() + 431 (SaveAndLoadHelper.cpp:431)
    34. 32 UnityFramework                 0x1415aac CleanupEngine() + 585 (SaveAndLoadHelper.cpp:585)
    35. 33 UnityFramework                 0x1429f6c PlayerCleanup(bool) + 701 (Player.cpp:701)
    36. 34 UnityFramework                 0x1b03b44 UnityCleanup + 222 (LibEntryPoint.mm:222)
    37. 35 UnityFramework                 0x14008 -[UnityAppController applicationWillTerminate:] + 527 (UnityAppController.mm:527)
    38. 36 UIKitCore                      0xe1023c -[UIApplication _terminateWithStatus:] + 196
    39. 37 UIKitCore                      0x139000 -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 112
    40. 38 UIKitCore                      0x5f9d6c -[_UISceneLifecycleMultiplexer forceExitWithTransitionContext:scene:] + 164
    41. 39 UIKitCore                      0xe0aea4 -[UIApplication workspaceShouldExit:withTransitionContext:] + 164
    42. 40 FrontBoardServices             0x47fc4 __63-[FBSWorkspaceScenesClient willTerminateWithTransitionContext:]_block_invoke_2 + 72
    43. 41 FrontBoardServices             0xe19c -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 168
    44. 42 FrontBoardServices             0x47f64 __63-[FBSWorkspaceScenesClient willTerminateWithTransitionContext:]_block_invoke + 128
    45. 43 libdispatch.dylib              0x4300 _dispatch_client_callout + 20
    46. 44 libdispatch.dylib              0x7d48 _dispatch_block_invoke_direct + 284
    47. 45 FrontBoardServices             0xa520 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 52
    48. 46 FrontBoardServices             0xa4a0 -[FBSMainRunLoopSerialQueue _targetQueue_performNextIfPossible] + 240
    49. 47 FrontBoardServices             0xa378 -[FBSMainRunLoopSerialQueue _performNextFromRunLoopSource] + 28
    50. 48 CoreFoundation                 0x3731c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
    51. 49 CoreFoundation                 0x36598 __CFRunLoopDoSource0 + 176
    52. 50 CoreFoundation                 0x34dac __CFRunLoopDoSources0 + 340
    53. 51 CoreFoundation                 0x33a88 __CFRunLoopRun + 828
    54. 52 CoreFoundation                 0x33668 CFRunLoopRunSpecific + 608
    55. 53 GraphicsServices               0x35ec GSEventRunModal + 164
    56. 54 UIKitCore                      0x22c2b4 -[UIApplication _run] + 888
    57. 55 UIKitCore                      0x22b8f0 UIApplicationMain + 340
    58. 56 UnityFramework                 0x17c58 -[UnityFramework runUIApplicationMainWithArgc:argv:] + 96 (main.mm:96)
     
  4. C-Gabriel

    C-Gabriel

    Joined:
    Jan 27, 2016
    Posts:
    119
    I totally agree, but it's not our SDK and we don't even have access to most of the code. To me it doesn't seem to be fixed in the latest Unity versions since we're using Unity 2022.3.14f1, which is the latest 2022LTS version.
     
  5. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,703
    Right, it dies trying to start UnityWebRequest when it's support has already been shut down.
    Isn't there a way to disable the messages? Even though it's third party sdk, it should give you some control over what it does. And it's a bug in that SDK, sending requests on quit is bogus unless you have control over quit sequence, which is not the case for anyone on mobiles.
     
  6. C-Gabriel

    C-Gabriel

    Joined:
    Jan 27, 2016
    Posts:
    119
    I don't think there's a way to prevent the SDK from send the event. I totally understand what you're saying but if there's an analytics SDK, it also makes sense to try and send an event when the session ends or when the app is closes
     
  7. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,703
    Report a bug for it with a repro project.
     
  8. C-Gabriel

    C-Gabriel

    Joined:
    Jan 27, 2016
    Posts:
    119
    we honestly haven't managed to reproduce it locally yet, despite it happening so often. Have you managed to reproduce it @marcus-qiiwi ?
     
  9. Alan-Liu

    Alan-Liu

    Joined:
    Jan 23, 2014
    Posts:
    382
    The crash happens because Unity sends reports while the application is quiting. I submitted a bug report with a minimal reproducible project: IN-62719. It can reproduce the following crash on Windows in Unity 2022.3.14:
    To avoid it, you can disable Cloud Diagnostics before the application quits, for example:
    Code (CSharp):
    1. using System;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5. using UnityEngine.CrashReportHandler;
    6.  
    7. public class Test : MonoBehaviour
    8. {
    9.     private void Awake()
    10.     {
    11.         // WORKAROUND: enable the following code to avoid the crash
    12. #if false
    13.         Application.quitting += () =>
    14.         {
    15.             CrashReportHandler.enableCaptureExceptions = false;
    16.         };
    17. #endif
    18.     }
    19.  
    20.     private void OnDestroy()
    21.     {
    22.         // Causes the application crashes
    23.         throw new InvalidOperationException();
    24.     }
    25.  
    26.     public void OnClick()
    27.     {
    28.         Application.Quit();
    29.     }
    30. }
    31.  
    Update:
    The public link on issuetracker: https://issuetracker.unity3d.com/is...on-is-thrown-with-cloud-diagnostics-activated
     
    Last edited: Dec 18, 2023
    C-Gabriel likes this.