Search Unity

UnityFramework crashes on iOS w/ latest versions of iOS and Unity Player

Discussion in 'iOS and tvOS' started by aromana, Mar 27, 2021.

  1. aromana

    aromana

    Joined:
    Nov 11, 2018
    Posts:
    137
    Hi, my app is reliably crashing when resuming from sleep (e.g. phone locks) on Unity (2020.3.3f1 LTS) and iOS (14.4.1). The crash only happens on iOS, not Android. It appears to be a bug in UnityFramework.

    It seems the crash occurs while raising an exception due to a network read failing.

    Here's the stacktrace:

    Code (csharp):
    1.  
    2. Thread 49 (crashed)
    3. 0   UnityFramework                     0x000000010b2dddf0 unity_debugger_agent_handle_exception
    4. 1   UnityFramework                     0x000000010b28e358 il2cpp::vm::Exception::PrepareExceptionForThrow(Il2CppException*, MethodInfo*)
    5. 2   UnityFramework                     0x000000010b28e480 il2cpp::vm::Exception::Raise(Il2CppException*, MethodInfo*)
    6. 3   UnityFramework                     0x000000010b24e318 il2cpp_codegen_get_generic_virtual_method_internal(MethodInfo const*, MethodInfo const*) (il2cpp-codegen-il2cpp.cpp:155)
    7. 4   UnityFramework                     0x00000001075f7434 Socket_EndReceive_m46B15199B81401BF6B7B76242C6E3A7E8156749C (System3.cpp:27165)
    8. 5   UnityFramework                     0x00000001075a97a4 NetworkStream_EndRead_mDCD08C532B8346555DD2D31850D15C8A900ECEF5 (System1.cpp:0)
    9. 6   UnityFramework                     0x0000000109ff65c0 U3CU3Ec_U3CBeginEndReadAsyncU3Eb__43_1_m65AE7D6BAE6051695BFB8BAAF6D052B396A67400 (mscorlib21.cpp:0)
    10. 7   UnityFramework                     0x00000001055087ac Func_3_Invoke_m65B591FA71F2C74A3A008BF351FDEA332066CAAB_gshared (Generics47.cpp:0)
    11. 8   UnityFramework                     0x00000001054e04a4 FromAsyncTrimPromise_1_Complete_m6B85E29E801D0524DCD84F9B08FFEBCAB334A19C_gshared (Generics47.cpp:45351)
    12. 9   UnityFramework                     0x00000001054e0234 FromAsyncTrimPromise_1_CompleteFromAsyncResult_mF080153F270CFE90B9394AD66F40C9D1B9A88C61_gshared (ThreadLocalValue.h:44)
    13. 10  UnityFramework                     0x0000000109d43348 AsyncCallback_Invoke_mFCCCB843AEC4B5B3FC89BCED2BA839783920EA47 (mscorlib.cpp:40143)
    14. 11  UnityFramework                     0x000000010767a6dc U3CU3Ec_U3CCompleteU3Eb__27_0_m5C293AC939107CF4960BBA8DFBA174438C2BD359 (ThreadLocalValue.h:44)
    15. 12  UnityFramework                     0x0000000109f4eb24 WaitCallback_Invoke_m8381182A104DD22C5EB4A8425A75821A56B54D09 (mscorlib19.cpp:0)
    16. 13  UnityFramework                     0x0000000109dcd4b8 QueueUserWorkItemCallback_System_Threading_IThreadPoolWorkItem_ExecuteWorkItem_m2CA24B6B431290B744D03EAE7DA993F50703FD52 (ThreadLocalValue.h:44)
    17. 14  UnityFramework                     0x0000000109ee1310 ThreadPoolWorkQueue_Dispatch_mCC5743D99870EC7844CAB3FF3FA7D23A44A4A984 (mscorlib17.cpp:20485)
    18. 15  UnityFramework                     0x0000000109f65838 _ThreadPoolWaitCallback_PerformWaitCallback_mAB4C4A7F6062A442A787F2E57FCAB9E3403D9CA9 (mscorlib19.cpp:0)
    19. 16  UnityFramework                     0x0000000106cadcbc RuntimeInvoker_FalseSByte_t928712DD662DC29BA4FAAE8CE2230AFB23447F0B(void (*)(), MethodInfo const*, void*, void**) (Il2CppInvokerTable.cpp:194013)
    20. 17  UnityFramework                     0x000000010b26f830 worker_thread(void*)
    21. 18  UnityFramework                     0x000000010b2991c0 il2cpp::vm::ThreadStart(void*)
    22. 19  UnityFramework                     0x000000010b27106c il2cpp::os::Thread::RunWrapper(void*)
    23. 20  UnityFramework                     0x000000010b273710 il2cpp::os::ThreadImpl::ThreadStartWrapper(void*)
    24. 21  libsystem_pthread.dylib            0x00000001dce6bcb0 <system symbols missing>
    25. 22  libsystem_pthread.dylib            0x8a291b81dce74778 <system symbols missing>
    26.  

    Any insight on how to debug/troubleshoot/mitigate would be greatly appreciated.
     
    Last edited: Mar 27, 2021
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    Do you have the Script Debugging option enabled in the Player Settings? Based on this call stack, it looks like it might be enabled.

    You may want to try to disable that, and see what happens. I don't think it will correct the crash, but it might help with troubleshooting.

    Based on this call stack, it looks like something is trying to throw a managed exception, then the player crashes while processing that exception. If we can determine what that exception actually is, that might help understand the problem.
     
  3. aromana

    aromana

    Joined:
    Nov 11, 2018
    Posts:
    137
    Thanks for replying! I believe Script Debugging was enabled, as this was a Development build. I've turned that off now and the issue *seems* to have gone away. I'll keep an eye out for it.

    If it is indeed the case that the crash is only present with development builds... how would I even troubleshoot that? I don't think I can repro while connected to Xcode because AFAIK the debugger connection is interrupted when the device is locked... which is a necessary repro step as far as I can tell.
     
  4. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    Interesting - this really sounds like a bug on the Unity side. If you can reproduce it again with the debugger enabled, can you submit a bug report (https://unity3d.com/unity/qa/bug-reporting)?

    It sounds like you are correct, the debugger network connection is being disconnected when the device is locked and is not being reconnected again.

    Also, note that it is possible to enable a development build (e.g. for profiling) without have script debugging enabled. In fact, script debugging will slow down the code, meaning that if you want to profile, you should _not_ have script debugging enabled, as that will throw off your profiler data.
     
  5. aromana

    aromana

    Joined:
    Nov 11, 2018
    Posts:
    137
    I filed a bug with Unity a few days ago, Case 1324839. Let me know if you need anything else from me.
     
  6. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    Excellent, thanks!