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

Load new level Hang/Deadlock/Freeze, somewhat random, lots of detail inside

Discussion in 'Editor & General Support' started by Blorfy, Aug 22, 2013.

  1. Blorfy

    Blorfy

    Joined:
    Aug 28, 2012
    Posts:
    25
    Hi, this is my first post. I am working on a large Unity project, Space Pirates and Zombies 2, and this is my first real blocker in a year of development. All scripts have been checked over the last 15 hours or so trying to track this bug down, so I am certain that this issue is somewhere outside the C# script we are feeding to Unity.

    ]Here are the symptoms:

    Upon loading a new level, between 0-1 seconds after the load the build will freeze. Core 0 will be stuck at 100% load and never recover. It looks like an infinite loop somewhere, but it is not in the script. I think it is a resource loading or unloading issue. There was a core deadlock resolved in version 4.2 that sounded similar to this. This hang happens frustratingly randomly, sometimes on the first level load and sometimes after 100 of them. We have an automated tester running on two machines to try to find commonalities and there are none we can see.

    What we have tried:
    Application.LoadLevel
    Application.LoadLevelAdditive
    Never loading a level and instead using prefabs as levels and deleting objects as needed.
    We are now back to using Application.LoadLevel since it manages the memory the best.

    All three level load methods will eventually hang the same way.

    We have also reproduced this hang/freeze in Unity versions 4.1.3, 4.1.5, 4.2 (current)

    We have also isolated the loading sections. We have a procedurally generated game so we build a level, then build props (procedurally generated buildings and such) and then add the ships. We can load any of these sections individually over and over and we will not hang so we know there isn't some odd infinite procedural construction loop. I even put safety code last night to break after X loops to be sure. We spawn a few thousand items on level load as well so we are pushing the system quite hard.

    We have had some success with disabling all calls to material.SetTexture but this is just a guess since the hang/freeze is so darn random. At the very least the issues comes up much less when we are not setting these textures on object creation.

    We had one freeze that was quite interesting in that the game seemed to hang as part of the level unloading process. Where we would have expected this in the log:

    UnloadTime: 67.956612 ms
    Unloading 3 Unused Serialized files (Serialized files now loaded: 0 / Dirty serialized files: 0)

    Unloading 904 unused Assets to reduce memory usage. Loaded Objects now: 35683.
    Total: 19.584072 ms (FindLiveObjects: 0.945127 ms CreateObjectMapping: 1.523069 ms MarkObjects: 8.583461 ms DeleteObjects: 8.214187 ms)

    the log just ended.

    I am really at a loss and was wondering if anyone else is experiencing the same issue? We obviously cannot ship with this. We have reproduced the hang both on a 6 year old PC running windows XP, and a brand new PC running Windows 7. Exact same problem on both.

    If there is some method to break into Unity execution and get some kind of core stack dump that would be awesome. We just need to figure out what the engine is trying to do when this hang occurs.

    This is likely not a common problem as I said we are really pushing the engine here with thousands of objects being created on the fly out of prefabs and having materials and textures changes, so we may be triggering a bug that is rarely seen but we need to either fix or find a work around for.

    Any help would be greatly appreciated.


    EDIT:
    Ok we found it! Posting here to hopefully help anyone else who runs into this. Long story short. It was the audio. For whatever reason, Native(WAV) loopers with 156kbps compression (didn't try other levels) will cause this hang randomly. If you switch to OGG, the problem goes away. We had to tear apart our entire project to track this down, so hopefully we save someone else the pain.

    Here is a related post we found after we determined the Audio was to blame:
    http://answers.unity3d.com/questions/317590/editor-freezes-while-playing-audio-loop.html

    Happy game building :)
     
    Last edited: Aug 26, 2013
    Simunek likes this.
  2. Simunek

    Simunek

    Joined:
    Jul 15, 2016
    Posts:
    48
    It happend to me too! It does happen with DirectX11 but not with DirectX12.

    I needed DX11... So removing all audiofiles solved the bug.

    Now I have to find out more details...

    My version is 2019.4.9f1. It happend suddenly in 4 years old project when changing graphics pipeline...

    I will add more details soon...
     
  3. JoNax97

    JoNax97

    Joined:
    Feb 4, 2016
    Posts:
    611
    Please start a new thread instead of reviving a 7-year old one.
     
  4. Simunek

    Simunek

    Joined:
    Jul 15, 2016
    Posts:
    48
    It is related :( And I was searching for this for 3 months....
     
  5. JoNax97

    JoNax97

    Joined:
    Feb 4, 2016
    Posts:
    611
    Chances are that, after so much time has passed, the issue is not the same even if it looks similar. In any case, necroing and/or piggybacking on an existing thread to post your own issue is against the rules. Create a new thread and copy the details from this thread you believe are necessary.