Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Unity keeps freezing when modifying scripts in Play mode

Discussion in 'Editor & General Support' started by Wolfram, Mar 15, 2011.

  1. Wolfram

    Wolfram

    Joined:
    Feb 16, 2010
    Posts:
    253
    Too often during development, I forget to stop a running scene in the Editor when editing scripts with MonoDevelop (or another editor, it's the same result). Unity consistently(*) freezes and I have to kill the process - and of course I lose all local scene changes at the same time.
    The only way to prevent this freeze is if I realize it quickly enough after switching back to Unity from the script editor, and stop the game before Unity finishes compiling the modified script.

    Is this a problem with my installation, or is this known behaviour? If the answer is, "don't edit scripts while a game is running", that solution is, quite simply, not good enough. An application I pay for shouldn't crash during normal work flow, no matter what I do to it :( I have 2-3 freezes/crashes like this every day, and every time I lose work.

    Is there a way to prevent these freezes?

    BTW, I am using the Windows version of Unity Pro - it seems a colleague of mine doesn't have this freezing problem with his Mac verion.

    (*) of course, trying to reproduce this deliberately to generate a testcase doesn't appear to be trivial, since not *every* edit causes a freeze - sometimes it works and I can continue to use Unity (although it usually gets confused, so it isn't really "live editing" and I have to stop and restart the game - but at least it doesn't crash in these cases).

    Thank you very much,
    Regards,
    Wolfram
     
    viesc123 likes this.
  2. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    We don't seem to have an entry for this in the bug database, so it would be great if you could file one (even if you can't always reproduce the bug). Does it happen with specific projects or randomly with any project?
     
  3. Wolfram

    Wolfram

    Joined:
    Feb 16, 2010
    Posts:
    253
    Ah, sorry, somehow I didn't get notified about your post.

    I just submitted a bug about this (Case 395657), please tell me if you need additional infos.
    I'll try again to create a testcase for this, although the problem seems to appear only when I'm NOT trying to deliberately reproduce it... ;-)
     
  4. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    I don't get a freezing on Win7 64 either, but if you change scripts while the application is in play mode, you will get the console total bombed with exceptions right away with a weak computer if the console is open without collapse this could easily lead to a freeze alike behavior
     
  5. Wolfram

    Wolfram

    Joined:
    Feb 16, 2010
    Posts:
    253
    Good idea, but that's not the cause. Unity freezes immediatedly, completely, and with 0% CPU usage. In cases where there is no freeze (for example when I was trying to construct a testcase), I can see the console being bombed, but that doesn't pose a problem on my machine.
     
  6. tarragon

    tarragon

    Joined:
    Dec 28, 2010
    Posts:
    38
    A good way to freeze unity is to have accidental loop in the scripts. By loop, i mean sophisticated version of while(true){};
    It works reliably, it is easy to implement and it never fails.
     
  7. Wolfram

    Wolfram

    Joined:
    Feb 16, 2010
    Posts:
    253
    True, but it doesn't matter what I am changing in the script (which obviously worked before, since the editor *is* in Play mode and responsive), even minor changes. Just to trigger a recompile seems to suffice to cause a lock up.

    Even modifying scripts that are not used in the scene that's currently running cause the freeze.
     
    Last edited: Mar 21, 2011
  8. raptoplob

    raptoplob

    Joined:
    May 24, 2011
    Posts:
    12
    I too am experiencing this problem. In my case it has occurred after I had a bluescreen of death crash, not sure if you had the same wolfram?

    I've uninstalled/reinstalled and removed the files from %APPDATA%\Unity, but still the problem persists.
     
  9. Crocodileshoes

    Crocodileshoes

    Joined:
    Jun 28, 2012
    Posts:
    1
    I had this problem but I'm pretty sure mine was related to some C# specific socket code. I have a socket open listening for UDP data and for some reason it seems to get stuck open, perhaps my destroy method isn't called. If I release the socket Unity seems to wake up again.

    As you can tell from the rather vague description I haven't looked into it in any detail. Playing with the socket (or the program sending the data) seems to clear the freeze.

    Maybe that will be a useful lead :)
     
  10. maclark86

    maclark86

    Joined:
    Jan 21, 2016
    Posts:
    6
    well, i now have this problem in 2018 wiht unity 2017.x. sometimes, changes don't affect it. sometimes, they do. i don't like doing testing out what is causing this, because restarting unity is a pain in the butt.
     
  11. as87dgs6asg0a

    as87dgs6asg0a

    Joined:
    Sep 2, 2013
    Posts:
    10
    hello from 2020, where this is still a problem
     
  12. JonathanCel

    JonathanCel

    Joined:
    Feb 17, 2021
    Posts:
    22
    Checking in from 2021.
    Just started today, resetting via git isn't helping.
     
  13. HofiOne

    HofiOne

    Joined:
    Apr 19, 2021
    Posts:
    66
    possible regression as same happens in 2021.2.1f1 on macOS
    this one is extremely annoying and renders the editor almost unusable
     
  14. Kevin1970

    Kevin1970

    Joined:
    Dec 21, 2017
    Posts:
    10
    2021.1.22f1 it's still doing it, that is if I edit a script (and save it) while in play mode, I can never switch back to the editor as it is in a "Not Responding" state.