Crashing

I’m getting semi-random crashes while playing our game (I get like 1-2 per hour) on iOS, typically (maybe it’s always) when changing scenes.

I’m using latest 2021 LTS.

This is the stack trace:

* thread #37, name = 'UnityGfxDeviceWorker', stop reason = EXC_BAD_ACCESS (code=1, address=0xf)

    frame #0: 0x00000002139aa910 IOGPU`-[IOGPUMetalBuffer dealloc] + 192

    frame #1: 0x0000000234062bb0 AGXMetalG14`-[AGXG14FamilyBuffer dealloc] + 76

  * frame #2: 0x0000000105d9f894 UnityFramework`~MetalVersionedBuffer [inlined] Clear at MetalScratchBuffer.h:28:18 [opt]

    frame #3: 0x0000000105d9f888 UnityFramework`~MetalVersionedBuffer at BuffersMetal.mm:20:15 [opt]

    frame #4: 0x0000000105da09f0 UnityFramework`Dispose [inlined] delete_internal<GfxVersionList::Entry> at MemoryMacros.h:202:15 [opt]

    frame #5: 0x0000000105da09d0 UnityFramework`Dispose at GfxVersionList.h:61:13 [opt]

    frame #6: 0x0000000105c3a6e4 UnityFramework`::GarbageCollect() at GfxVersionList.cpp:177:14 [opt]

    frame #7: 0x0000000105c5dcc8 UnityFramework`::GarbageCollect() at GfxVersionManager.cpp:45:46 [opt]

    frame #8: 0x0000000105da44e0 UnityFramework`StartFrame at FrameBufferMetal.mm:815:12 [opt]

    frame #9: 0x0000000105d32ccc UnityFramework`::RunCommand() at GfxDeviceWorker.cpp:0 [opt]

    frame #10: 0x0000000105db2dc4 UnityFramework`GfxDeviceWorkerAutoreleasePoolProxy at GfxDeviceMetal.mm:5750:18 [opt]

    frame #11: 0x0000000105d34468 UnityFramework`::RunExt() at GfxDeviceWorker.cpp:381:5 [opt]

    frame #12: 0x0000000105d2bfac UnityFramework`::RunGfxDeviceWorker() at GfxDeviceWorker.cpp:338:42 [opt]

    frame #13: 0x0000000105920c80 UnityFramework`::RunThreadWrapper() at Thread.cpp:82:14 [opt]

    frame #14: 0x00000002080056b8 libsystem_pthread.dylib`_pthread_start + 148

I don’t know what to do based on this. I do my own custom processing and I use temporary rendertextures, I have been doing this for years and haven’t had issues, but I’m not even sure if it is even related to that?

Also, for what it’s worth, the exact same project had no issues on tvOS.

It seems to be related to multithreaded rendering.

After making a build with multithreaded rendering off and testing for 2 hours with no crashes, which isn’t conclusive but definitely well past the time it took the previous build to crash.

I guess it makes sense, after having to disable multithreaded rendering for Android and multithreading in general for the Editor to stop the constant crashes, maybe I need to accept that unity and threads don’t play well together and it’s time to consider this feature as not existing.

It seems to be related to multithreaded rendering.
yeah the crash happens specifically in the multithreaded-rendering only code path. I cannot comment on the crash itself - it does look weird (which crashes do not? ;-)) and kinda end up in the metal driver code which makes it hard to even reason about possible issues

1 Like