Both Unity Editor (play mode) and Profiler (standalone mode) crashing at same time

Anyone got any ideas for debugging both Unity Editor and Profiler crashing?

Version: 2020.3.16f1.844 Personal

Symptoms:
Both the Editor & Profiler (running in it’s own process) crash, seemingly randomly, when running “explosion” code. The “explosion” code consists of more than 1500 lines of code (I’ve triple-checked to ensure there’s no infinite recursion, confirming with debug output & putting fail-safe logic in all loops). Sometimes the “explosion” code/functionality works great, no issues, sometimes it freezes the editor (forever, without crashing) and sometimes it freezes the editor then crashes after 15 to 45 seconds. I cannot reliably reproduce any of the symptoms. When the profiler doesn’t also crash, I sometimes see physics taking 400+ms per frame for a few seconds, but the call stack doesn’t always include my game code, just Unity calls.

Things I’ve Tried:
Using the Profiler, in both attached and detached (separate process) modes. However, when the Editor crashes quickly so does the profiler (in either mode), which seems bizarre and to suggest a core Unity engine bug (dunno, just guessing).

Slowing down the timeScale (and even setting to 0) in an attempt to catch watch happens right before the crash - didn’t help

Refactoring (many times :slight_smile: the “explosion” code. If I increase the number of StartCoroutine calls (which are used to time explosions and scale the mesh cutting across multiple frames) by using WaitForEndOfFrame instead of WaitForSeconds, then the crashing happens more frequent and quicker (I have fail safe/counter code in the coroutines to ensure recursion doesn’t happen for than 60 times)

Ensuring that I’m not mistakenly/unwantingly setting the timeScale to 0

Checking the logs - I haven’t found anything so far, but I may be missing a dmp file that Unity provides but I can’t find.

Any suggestions greatly appreciated.

UPDATE 2: Finally able to trap the freeze in profiler. I have no idea what’s chocking Unity Physx (for 45+ seconds!) - below are screenshots of 1)profiler, 2)scene view of the explosion in mid explode and 3)Windows Task Manager (not a resource issue, but by the time I got the screen shot the CPU usage had already died down)

Each of the exploding parts has a non-kinematic Rigidbody with an AudioSource (for collision sounds). Can the Unity Physx engine not handle a few dozen parts flying around with explosion force added?!


In case it’s helpful - here’s a short forum discussion with the problem (resizing moving game objects with non-kinematic rigidbodies, while they’re moving &/or colliding) and an example solution:
https://forum.unity.com/threads/advice-on-scaling-explosions-to-prevent-overwhelming-freezing-crashing-physx.1469426/