So I’ve been using CustomRenderTextures as a convenient way to maintain atlases of textures as part of a multi-stage procedural generation process (with a chain of textures representing different work stages). All was working great until I needed to add another pass (and so another CRT) into my pipeline - I now get a Unity crash with this callstack:
Thread 0 Crashed:: CrBrowserMain Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff6f6bfe3e __pthread_kill + 10
1 libsystem_pthread.dylib 0x00007fff6f7fe150 pthread_kill + 333
2 libsystem_c.dylib 0x00007fff6f61c312 abort + 127
3 com.unity3d.UnityEditor5.x 0x0000000100fd3ae1 HandleSignal(int, __siginfo*, void*) + 81
4 libmono.0.dylib 0x0000000139805de0 mono_chain_signal + 75
5 libmono.0.dylib 0x000000013974d406 mono_sigsegv_signal_handler + 210
6 libsystem_platform.dylib 0x00007fff6f7f1f5a _sigtramp + 26
7 ??? 000000000000000000 0 + 0
8 com.unity3d.UnityEditor5.x 0x00000001009ef891 void std::__introsort_loop<CustomRenderTexture**, long, SortFunctor>(CustomRenderTexture**, CustomRenderTexture**, long, SortFunctor) + 321
9 com.unity3d.UnityEditor5.x 0x00000001009e144a CustomRenderTextureManager::UpdateCustomRenderTextures(dynamic_array<CustomRenderTexture*, 8ul>&, bool) + 122
10 com.unity3d.UnityEditor5.x 0x00000001009e09a4 CustomRenderTextureManager::Update(bool) + 404
11 com.unity3d.UnityEditor5.x 0x0000000100c304ad InitPlayerLoopCallbacks()::postLateUpdateUpdateCustomRenderTexturesRegistrator::Forward() + 93
12 com.unity3d.UnityEditor5.x 0x0000000100c315d3 PlayerLoop() + 1283
13 com.unity3d.UnityEditor5.x 0x00000001019a6d67 PlayerLoopController::UpdateScene(bool) + 567
14 com.unity3d.UnityEditor5.x 0x00000001019a742a PlayerLoopController::EnterPlayMode(bool) + 682
15 com.unity3d.UnityEditor5.x 0x00000001019a21e6 PlayerLoopController::SetIsPlaying(bool) + 278
16 com.unity3d.UnityEditor5.x 0x00000001019a1a35 Application::TickTimer() + 4069
17 com.apple.Foundation 0x00007fff49da6659 __NSFireTimer + 83
18 com.apple.CoreFoundation 0x00007fff47c66dd4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
If I comment out the Update call for the new CRT it works. OR if I comment out a different CRT from my chain then that can run too. So it would seem to be related to how many CRTs I have chained and/or some problem with the inferred dependencies between them (which are totally linear although there are some stages where two earlier CRTs are associated with later materials).
I first saw this under 2017.3.1p2 but I’ve also tried 2017.4.1f1 and 2018.1.0b13 which also crash just the same. Interestingly under 2018.2.0b1 I do NOT see the crash and my app runs, although I don’t really want to have to rely on such an early Beta (plus some other assets I’m using aren’t ready for this one yet).
Unless anyone can see a solution I feel like I have no choice but to try and rework my pipeline to use less CRTs, otherwise I’m completely stuck. Of course if someone with access to the Unity source could see the cause of the crash from the above callstack and suggest a workaround that would be much appreciated!