Search Unity

[Help!] UNITY HANGS ALOT

Discussion in 'Editor & General Support' started by junestone, Mar 13, 2018.

  1. junestone

    junestone

    Joined:
    May 30, 2017
    Posts:
    42
    For a year, with all Unity versions from 5.6.x to 2017.3.x. The issue went as follows:

    1) When Unity Editor is in a Play mode. Change cs script in an external editor like vscode, PRESS Ctrl+S,
    Seconds later, Unity hangs for a while, then all Buttons & UGUI controls lost response, clickable but not calling the binded onClick methods. It seems some of the MonoBehaviour is crashed at runtime.

    2) When Unity Editor is in a Play mode, sometimes it HANGS itself. Without any code change, or click the UI, it just had a chance to crash as in 1).

    Please investigate this problem, interestingly, when crash happened, no breakpoint could be hit. It just went mad. BUT, this only happens inside Unity Editor, not device player.
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Does this happen with a new/empty project?
     
  3. junestone

    junestone

    Joined:
    May 30, 2017
    Posts:
    42
    nope. an empty project runs fine.
    My project contains a lot of png/jpg files.
    https://github.com/kbengine/kbengine_unity3d_plugins
    And im using this plugin which uses multithreading for socket network.
     
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    You would need to troubleshoot to find what is causing the issue by adding components to the empty project until it reproduces (would be one way). If it is the plugin causing the issue, you would likely want to contact the author.
     
  5. junestone

    junestone

    Joined:
    May 30, 2017
    Posts:
    42
    When this issue occurred, how can I analyze the log or something that can trace the error?
    I viewed the log, everything seems fine but some MonoBehaviour suddenly crashed and objects get lost.
     
  6. junestone

    junestone

    Joined:
    May 30, 2017
    Posts:
    42
    Unfortunately, the author says it's been widely used and nobody encountered this issue.
    So, I need to find a way to debug.

    It happens only inside editor, does it mean if anything cost too much cpu time to finish, or blocked the Editor thread then Unity will lost Monobehaviour objects?
     
  7. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    No, does not mean that. So you've narrowed down the issue to this single plugin? When you add it to a new project, it behaves the same way?
     
  8. junestone

    junestone

    Joined:
    May 30, 2017
    Posts:
    42
    No, I created a simple Scene in the same project, without adding the plugin. This issue also occurs.
    Anything stops the Editor from responding for a while can definitely cause that as I mentioned in the post.

    But if I create a new project from scratch this won't happen.

    My project contains a lot of resource files, that's the significant difference.
     
  9. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    You need to determine when and where it starts to occur. It doesn't occur for a new project, so you need to add your assets one at a time until the issue occurs so you can narrow it down.
     
  10. Also it is a good idea to check your memory. Sudden hangs and crashes can be a symptom of some faulty memory modules, especially when you're dealing with high demand memory usage, like your project. It may not the root cause, but it can be. Been there, done that, learned from it. :)
     
  11. Artaani

    Artaani

    Joined:
    Aug 5, 2012
    Posts:
    423
    But this is not allowed. You should not edit your scripts while editor in the play mode, because after script edited, it will be automatically recompiled, and existed instance of game will be corrupted. You need to stop play mode and launch it again in order to get new code to work.

    Since it is a play mode, any script in your project may cause this problem. For example infinite loop. Keep your profiler open, it may helps to detect an error.
     
  12. junestone

    junestone

    Joined:
    May 30, 2017
    Posts:
    42
    I almost deleted everything except the loginScene left in the project.
    Problems remains on Mac, when anything changed there will be a "Appdomain unloaded" event called.
    Something is unloading the appdomain and all static variables become null.
    Im digging deeper into this issue, to reoccur it without recompiling code like case 2) in previous post.
     
  13. junestone

    junestone

    Joined:
    May 30, 2017
    Posts:
    42
    Appdomain unloaded is called before this happens. I almost deleted everything except the root scene. Problem remains.