- Home /
Debug an occasional freeze
I've had an occasional freeze that has been occurring for a long time and cannot find the source nor any way to find it. Debug.log isn't helpful as it doesn't function during the freeze - since everything locks up. Monodevelop debugging mode also doesn't help as I don't know where it is occurring, so I don't know where to set breakpoints.
The bug itself only occurs randomly. Sometimes I can run the program for 30 minutes without a freeze, sometimes it freezes after 10 seconds.
I've tried disabling sections of code, but since no user action "provokes" the crash as far as i can tell (right now the only input is camera movement), i can't attempt to get it to crash on-demand. Since it occurs maybe once every 10-20 minutes of running, there's really no way to know if the problem was in my disabled code or if it just decided not to crash.
I've dug through the code looking for possible infinite loops, but I don't use do/while at all, nor do I manually alter my iterating variables in for/loops
Since there's no user-conditions which prompt the freeze and no indication that it's going to freeze (framerate doesn't drop before it or anything, it's just out of nowhere) I can't even begin to guess what's causing the problem. I was hoping the problem is just the unity editor, but it freezes in stand-alone exes too.
Has anyone a solution to this problem, or any suggestions of what to try to track down this frustrating freeze?
These kinds of bugs are just terrible. I don't know how extensively you are using the OnEnable()
and OnDisable()
functions. But I would recommend that for every script you enable you could write:
void OnEnable() { Type t = typeof(this); Debug.Log(t.ToString() + " enabled"); }
With this you can narrow it down to which component is enabled lastly before the occurring freeze. I posted this as a comment since I have not tested the above code and does not know if it is working :) But I think you get the idea. Also it might be good checking out the error logs that unity creates: http://docs.unity3d.com/$$anonymous$$anual/LogFiles.html
I'm not using OnEnable/OnDisable very much, so this would be of limited utility, but it's a good idea.
Your answer
Follow this Question
Related Questions
print(); to console problem - beginner 0 Answers
Step/Iterative Debugging 1 Answer
How to catch Unity values in Android EDI ? 0 Answers
Getting variables from c# to js 2 Answers