Unity Editor and Player freeze after several minutes of gameplay without leaving any useful log or debugging information.

My game freezes in both the Unity Editor and the Unity Player (developer and normal builds) on both Windows and Mac. The freeze occurs sporadically, at many different points during gameplay with no obvious trigger. I have to force quit to exit the program once it freezes. The only information I get in the logs is:

Receiving unhandled NULL exception

Obtained 10 stack frames.

That appears at the very end of the log file with no information following.

I tried running Unity with the MonoDevelop debugger attached, but could get no information after the game freezes.

I am currently using Unity 2017.2.0f2, but this issue began a few weeks ago when I was using Unity 2017.1.2. I had to switch to a beta release to deal with MonoDevelop incompatibilities with OSX 10.13.

It is unclear to me if this is an error occurring in my code somewhere or something deeper than that, but I’m at a loss at to how to proceed in debugging the issue. Any suggestions would be much appreciated.

Well, it’s difficult to help in this case. Debugging is generally a complex topic that can not always be generalized. The first you can try is use MonoDevelop / VS and attach it as debugger to your UnityEditor. If the game freezes go to your debugger and press “pause”. Now you may be able to step through your code and see where it’s actually stuck.

If that doesn’t work at all for some reason you have to use more general approaches.

The most difficult thing is to narrow down the cause. That means you would have to run the game as often as possible and have a close look what the last actions were in the game right before it freezes.

If it’s completely random or you can’t determine any concrete situation / event / input the only way would be create a copy of your project and simply “cut out” objects and / or code and see if it still happens.