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?
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:
for(var n = 0; n < SceneIds.Count; ++n)
{
var sceneName = SceneIds[n].SceneName;
// If the scene is already added (during edit mode), do not load it again
var existingScene = SceneManager.GetSceneByName(sceneName);
if(existingScene.IsValid() && existingScene.isLoaded)
continue;
var asyncOp = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive);
while(!asyncOp.isDone)
yield return null;
}
Adding several yield statements after loading a scene, works around the issue.
for(var n = 0; n < SceneIds.Count; ++n)
{
var sceneName = SceneIds[n].SceneName;
// If the scene is already added (during edit mode), do not load it again
var existingScene = SceneManager.GetSceneByName(sceneName);
if(existingScene.IsValid() && existingScene.isLoaded)
continue;
var asyncOp = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive);
while(!asyncOp.isDone)
yield return null;
yield return null;
yield return null;
yield return null;
yield return null;
yield return null;
yield return null;
yield return null;
yield return null;
}
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.
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!