Search Unity

Main thread deadlock with Unity 2018.3.1f1

Discussion in 'iOS and tvOS' started by jisomark, Jan 17, 2019.

  1. jisomark

    jisomark

    Joined:
    Dec 12, 2013
    Posts:
    10
    Heya,

    I'm currently in the process of upgrading a rather large project into 2018.3.1 from 2018.2.12. I was able to deal with a lot of the problems we had with the upgrading, but now we're left with one that seems to be an engine level bug only on iOS.

    We have a complex asset bundle system with thousands of asset bundles downloaded per request to the clients. Everything is running smoothly with the old Unity and with Android on 2018.3.1, but iOS has a huge problem when it's in the process of unloading the current scene and it's asset bundle and switching to a new one. Unloading the active scene works fine, but when we immediately after that try to unload the asset bundle the scene was from (AssetBundle.Unload(true)), Unity's main thread gets randomly locked out of execution, and the client freezes. the freeze is "permanent" so just by waiting the execution never continues, but pressing the home button on the device so it goes to desktop and returning to the app fixes the problem and execution continues.

    This is obviously a blocker for us, so currently we can't upgrade to the newest Unity. What I'm worried about is that I haven't been able to find any similar reports from these forums or the issue tracker. Is this a known bug and any idea if it's currently being looked at?

    We're seeing this stack when the freeze happens:

    Code (csharp):
    1. 2019-01-14 11:10:42.639897+0200 h4kdev[837:134949] HelpshiftLog:Debug::DEBUG::14:11:10:42.635 | SpaceManager | Unloading scene Closet.
    2. #0    0x0000000103dc5870 in atomic_compare_exchange_weak_explicit<long long, memory_order_acquire_t, memory_order_relaxed_t> [inlined] at /Users/builduser/buildslave/unity/build/./Runtime/Threads/ExtendedAtomicOps-clang-gcc.h:137
    3. #1    0x0000000103dc5858 in ::ReadLock() at /Users/builduser/buildslave/unity/build/./Runtime/Threads/ReadWriteSpinLock.h:116
    4. #2    0x0000000103beaf8c in AutoReadLockT [inlined] at /Users/builduser/buildslave/unity/build/./Runtime/Threads/AutoReadWriteLock.h:10
    5. #3    0x0000000103beaf84 in AutoReadLockT [inlined] at /Users/builduser/buildslave/unity/build/./Runtime/Threads/AutoReadWriteLock.h:10
    6. #4    0x0000000103beaf84 in GetAllocationRoot [inlined] at /Users/builduser/buildslave/unity/build/./Runtime/Profiler/MemoryProfiler.h:305
    7. #5    0x0000000103beaf74 in ::UnregisterAllocation() at /Users/builduser/buildslave/unity/build/./Runtime/Profiler/MemoryProfiler.cpp:303
    8. #6    0x000000010380a360 in ::RegisterDeallocation() at /Users/builduser/buildslave/unity/build/./Runtime/Allocator/MemoryManager.cpp:1986
    9. #7    0x0000000103808910 in ::Deallocate() at /Users/builduser/buildslave/unity/build/./Runtime/Allocator/MemoryManager.cpp:1529
    10. #8    0x00000001034c8b80 in Deallocate [inlined] at /Users/builduser/buildslave/unity/build/./Runtime/mecanim/memory.h:36
    11. #9    0x00000001034c8b74 in ::DeallocateBindings() at /Users/builduser/buildslave/unity/build/./Runtime/Animation/Director/AnimatorControllerPlayable.cpp:735
    12. #10    0x00000001034ccea0 in ::DeallocateResources() at /Users/builduser/buildslave/unity/build/./Runtime/Animation/Director/AnimationPlayable.cpp:56
    13. #11    0x0000000103dd00e4 in ::DestroyPendingPlayables() at /Users/builduser/buildslave/unity/build/./Runtime/Director/Core/PlayableGraph.cpp:354
    14. #12    0x0000000103dcff98 in ::Destroy() at /Users/builduser/buildslave/unity/build/./Runtime/Director/Core/PlayableGraph.cpp:103
    15. #13    0x0000000103dcfbec in ::ProcessPlayStateChanges() at /Users/builduser/buildslave/unity/build/./Runtime/Director/Core/DirectorManager.cpp:343
    16. #14    0x0000000103dcf1f0 in ExecuteStage [inlined] at /Users/builduser/buildslave/unity/build/./Runtime/Director/Core/DirectorManager.cpp:512
    17. #15    0x0000000103dcf1e8 in ::Forward() at /Users/builduser/buildslave/unity/build/./Runtime/Director/Core/DirectorManager.cpp:144
    18. #16    0x0000000103bc436c in ::ExecutePlayerLoop() at /Users/builduser/buildslave/unity/build/./Runtime/Misc/PlayerLoop.cpp:347
    19. #17    0x0000000103bc43c8 in ::ExecutePlayerLoop() at /Users/builduser/buildslave/unity/build/./Runtime/Misc/PlayerLoop.cpp:364
    20. #18    0x0000000103bc45e4 in ::PlayerLoop() at /Users/builduser/buildslave/unity/build/./Runtime/Misc/PlayerLoop.cpp:418
     
  2. devknit

    devknit

    Joined:
    Apr 16, 2014
    Posts:
    12
    It also occurred in 2018.3.5f1.
    In addition to AssetBundle.Unload (true), it also occurs with Destroy () and UnloadUnusedAssets.

    I am in trouble because I already raised the version.
    Is there no way to deal with it?
     
  3. jisomark

    jisomark

    Joined:
    Dec 12, 2013
    Posts:
    10
    We're currently running Unity 2018.3.6, and it's still happening if we try to use Metal rendering on iOS. We're forced to use OpenGLES to prevent the game from ending in a deadlock.
     
  4. devknit

    devknit

    Joined:
    Apr 16, 2014
    Posts:
    12
    Forced OpenGLES but did not fix it.
    We confirmed outbreak with Unity2018.3.6f1 and Unity2018.3.8f1.
     
  5. Zaikman

    Zaikman

    Joined:
    Aug 2, 2011
    Posts:
    17
    @devknit Did you ever figure out what was causing this? We're seeing a similar hang on our title screen when running on the HD version of Apple TV, whereas everything works fine on other iOS/tvOS devices. No crash, but the callstack breaks in a very similar place if you pause the debugger in Xcode.
     
  6. Deleted User

    Deleted User

    Guest

    Was this bug ever resolved? We're seeing this on 2018.3.5.
     
  7. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,620
    Try the latest 2018.4 release, it's basically 2018.3 with a lot of bug fixes:
    https://unity3d.com/unity/qa/lts-releases