Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

2017.3.0b6 freezes when entering playmode

Discussion in '2017.3 Beta' started by Peter77, Oct 24, 2017.

  1. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,609
    Every time I press "Play", I see the editor enters play mode and a few frames later, the editor freezes. Windows Task Manager says "Unity.exe is not responding".

    The project did not freeze in 2017.1 nor 2017.2, so this is new to me :)

    Is anyone else seeing such that freezy behavior? Is UT aware of a problem in that area?
     
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,609
    What I found so far, it seems to be related to loading additive scenes, where a timing problem has been introduced in either b5 or b6.

    The original scene loading code looks like this. which causes the editor to freeze while loading the 3rd additive scene:
    Code (CSharp):
    1.  
    2. for(var n = 0; n < SceneIds.Count; ++n)
    3. {
    4.    var sceneName = SceneIds[n].SceneName;
    5.  
    6.    // If the scene is already added (during edit mode), do not load it again
    7.    var existingScene = SceneManager.GetSceneByName(sceneName);
    8.    if(existingScene.IsValid() && existingScene.isLoaded)
    9.        continue;
    10.  
    11.    var asyncOp = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive);
    12.    while(!asyncOp.isDone)
    13.        yield return null;
    14. }
    Adding several yield statements after loading a scene, works around the issue.
    Code (CSharp):
    1. for(var n = 0; n < SceneIds.Count; ++n)
    2. {
    3.    var sceneName = SceneIds[n].SceneName;
    4.  
    5.    // If the scene is already added (during edit mode), do not load it again
    6.    var existingScene = SceneManager.GetSceneByName(sceneName);
    7.    if(existingScene.IsValid() && existingScene.isLoaded)
    8.        continue;
    9.  
    10.    var asyncOp = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive);
    11.    while(!asyncOp.isDone)
    12.        yield return null;
    13.    
    14.    yield return null;
    15.    yield return null;
    16.    yield return null;
    17.    yield return null;
    18.    yield return null;
    19.    yield return null;
    20.    yield return null;
    21.    yield return null;
    22. }
    Is this, by any chance, a known issue? It's probably going to be rather difficult to create a simplified project to reproduce the issue.
     
  3. charlesb_rm

    charlesb_rm

    Joined:
    Jan 18, 2017
    Posts:
    485
    Hi Peter77,
    We are looking with the development team to see if they are aware of the issue and why it happens.
    Stay tuned!
     
    Peter77 likes this.
  4. XRA

    XRA

    Joined:
    Aug 26, 2010
    Posts:
    265
    Noticing a similar issue here, sometimes it freezes, sometimes it doesn't. Haven't tried the multiple yield thing yet!
     
  5. MaddoScientisto

    MaddoScientisto

    Joined:
    Jan 30, 2015
    Posts:
    62
    It's happening to me without additive scene loading, all I have is just two scenes loaded at stat in the editor
     
  6. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,136
    Do any of you have a project that reproduces this behaviour somewhat consistently? If so, please share it with us.
     
  7. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,609
    I tried for hours creating a project to reproduce the issue, but at some point or another, the issue stops occurring.

    While dissecting the real project to create a reproduce, I noticed the game is actually loading another additive scene asynchronously in parallel as well. This "parallel scene" consists of UI elements only. All the yield null's probably cause some timing-changes, so that the loading or awakening of the "parallel scene" does not interfere with the other scene load.

    I changed my code that scenes never load in parallel and this does seem to fix the freeze, didn't occur from then on anymore.

    I also noticed that audio keeps playing normally if the editor froze, it seems only the main thread hangs actually.


    However, I'm not able to provide a stripped project to reproduce the issue. I hope someone else can!
     
    LeonhardP likes this.