Search Unity

Unity Randomly Freezes

Discussion in 'Getting Started' started by xjjon, Jul 12, 2016.

  1. xjjon

    xjjon

    Joined:
    Apr 15, 2016
    Posts:
    612
    Been having trouble with my Unity editor lately. It randomly freezes up and is unresponsive. I cannot close the editor, the only way to get out of it is to end the task and restart it. It doesn't give any errors or anything. I can't seem to reliably recreate the issue either but it happens up to 10 times an hour. I checked the editor logs and nothing seems out of the ordinary.

    The most common thing it crashes for is either when i press 'play' button, or I have the Animation tab open and switch from editor to visual studio. As far as I know there isn't any bad code and such, it crashes on a small project as well, so I don't think it's my game.

    This is extremely annoying. I save often so I don't lose any data, but having to use task manager to end it then restart is just annoying when it's so often.

    Is there something I can do to better diagnose the problem?

    The computer is i7-4702HQ, 16GB ram, nvidia GT 750, Intel HD4600, running windows 10. I thought it might be due to using onboard GPU, but I have tried running with the nvidia card as well, same problems.
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Well, it might be your game if the small project you're testing on has the same bug. It's important to note that when you run a game within the Unity editor, it's running in the same process as the editor itself. So, if you have an infinite loop in your code, this will lock up Unity too.

    You can diagnose that in several ways. One is to connect your project to the debugger (I use MonoDevelop for this), and when it locks up, press the Pause button in the debugger. It should stop and show you where it is in the code.

    If you're on a Mac, you can also use Apple's tools — Activity Monitor, Profiler, Spindump, etc. But these don't give you all that much useful info, because the actual problem is occurring in C# code running within a Mono virtual machine. So the stack mostly contains a bunch of nameless Mono methods.
     
    Kiwasi likes this.
  3. xjjon

    xjjon

    Joined:
    Apr 15, 2016
    Posts:
    612
    Most of the time the editor crashes outside of game test. For example I may be testing the game, then close/end it and tab over to visual studio to edit some code, I'll change a few lines, save it, and try to hop back into Unity but it locks up.

    I don't think it's something to do with the code, like an infinite loop. I meant small project as in new project with a few dummy objects and just some sample scripts.

    I haven't had it crash or freeze during testing, only after exiting, or on the press of 'play' (when it compiles?).

    For my latest crash, here is the last thing on the log:

    Code (csharp):
    1.  
    2. Ignoring 'C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/Advertisements/UnityEngine.Advertisements.dll' because we're compiling for Editor
    3. Ignoring 'C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnityAnalytics/UnityEngine.Analytics.dll' because we're compiling for Editor
    4. Ignoring 'C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnityPurchasing/UnityEngine.Purchasing.dll' because we're compiling for Editor
    5. - starting compile Library/ScriptAssemblies/Assembly-CSharp-Editor.dll, for buildtarget 5
    6. - Finished compile Library/ScriptAssemblies/Assembly-CSharp-Editor.dll
    7. WeaveUnetFromEditor Temp/Assembly-CSharp-Editor.dll
    8. Ignoring 'C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/Advertisements/UnityEngine.Advertisements.dll' because we're compiling for Editor
    9. Ignoring 'C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnityAnalytics/UnityEngine.Analytics.dll' because we're compiling for Editor
    10. Ignoring 'C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnityPurchasing/UnityEngine.Purchasing.dll' because we're compiling for Editor
    11. WeaveAssemblies unityPath= C:/Program Files/Unity/Editor/Data/Managed/UnityEngine.dll
    12. WeaveAssemblies unetPath= C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/Networking/UnityEngine.Networking.dll
    13. Reloading assemblies after finishing script compilation.
    14. Begin MonoManager ReloadAssembly
    15.  
    16.  
    Which is when I tab back into the editor from visual studio. I tried to force close the task so I could open it up in the Debugger but it comes up blank, cause my game is not running at this point?
     
  4. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Hmm, you're right, those symptoms aren't consistent with an infinite loop in the game code.

    It does remind me a bit of a bug that I think was introduced recently (and fixed even more recently than that, in a patch release just a couple weeks ago). It had to do with reloading assemblies, which is what Unity appears to be doing when it freezes for you. So, it may be worth trying the latest patch release and see if that solves the problem.
     
  5. adamt

    adamt

    Joined:
    Apr 1, 2014
    Posts:
    116
    @xjjon

    I have a very similar issue. We use Jenkins to build our game (iOS and Android), running Unity in batch mode. Every once in a while, the build just stalls out. Looking at Activity Monitor, the Unity process is using nearly 0% CPU, and the last log message in Jenkins is what you show on line 14: Begin MonoManager ReloadAssembly.

    We have to Force Quit Unity to get it to stop, and then re-run the build process, which almost always fixes things... for a while. The issue eventually rears its head again. This was never an issue before 5.3.5, but ever since (it just happened again while using 5.3.5p8) it comes up almost once per day, and I have to babysit our build process, else we get builds that hang indefinitely.

    I submitted a bug report, but that was over a month ago and there has been no activity from Unity on it.
     
  6. xjjon

    xjjon

    Joined:
    Apr 15, 2016
    Posts:
    612
    After updating to the latest version of the patch, I believe 5.3.5. p8 we have not had any issues with the editor freezing anymore. Will update if something happens.
     
    JoeStrout likes this.
  7. jc-drile77

    jc-drile77

    Joined:
    Jul 1, 2014
    Posts:
    230
    I´ve been suffering this issue lately too, my Unity version is 5.3.5p5 so I will update to patch 8 as @xjjon said above, lets see if its fixed. Its quite anoying losing scene changes every once in a while.
     
  8. adamt

    adamt

    Joined:
    Apr 1, 2014
    Posts:
    116
    @xjjon

    It seems like our issues are a bit different, unfortunately -- I'm still seeing the issue in 5.3.5p8. Fingers crossed 5.4 fixes things...
     
  9. Reticulatas

    Reticulatas

    Joined:
    Jul 31, 2012
    Posts:
    25