- Home /
Windows Standalone crashing silently during scene switching
Hi. I've made a StandaloneWindows64 build of the game. It works completely fine in the editor, and the windows standalone build works with 99% of players, however a few are reporting it crashes when switching scenes.
Attached is the Player.log. Windows 10 Pro 64-bit The application just silently crashes/quits when going from my Splashscreen scene (which is a loading screen) to my main menu scene. It may happen during of an LoadSceneAsync operation or during an UnloadSceneAsync, but I'm not completely sure. I've since added some more Debug statements in a newer build to find out. Scene switching code below:
IEnumerator Async_Load_Level()
{
UIManager.ui_manager.loading_icon.SetActive(true);
UIManager.ui_manager.loading_text.gameObject.SetActive(true);
string active_scene = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name;
DestroyImmediate(UnityEngine.EventSystems.EventSystem.current.gameObject);
AsyncOperation AO = UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(level_to_load);
AO.allowSceneActivation = false;
int progress = (int)(AO.progress * 100f);
while (AO.progress < 0.9f)
{
progress = Mathf.Max(progress, (int)(AO.progress * 100f));
UIManager.ui_manager.loading_text.text = progress + "%";
yield return null;
}
AO.allowSceneActivation = true;
while (AO.progress < 1f)
{
progress = Mathf.Max(progress, (int)(AO.progress * 100f));
UIManager.ui_manager.loading_text.text = progress + "%";
yield return null;
}
UIManager.ui_manager.loading_text.text = "100%";
yield return 0;
UIManager.ui_manager.loading_icon.SetActive(false);
UIManager.ui_manager.loading_text.gameObject.SetActive(false);
UnityEngine.SceneManagement.SceneManager.UnloadSceneAsync(active_scene);
}
link text I noticed the VRAM for this player is very low - 480mb. Could it be unable to allocate enough memory? This could explain why for most players it works, but for a few it doesn't.
EDIT: Solution has been found. After much trial and error, the game no longer crashes during our loading screen, even with steam running. The issue with the graphics driver DOES NOT OCCUR if the graphics API being used is OpenGL. Adding that as an graphics API option to the build, and adding this launch parameter: -force-glcore32 fixed the issue (though for this player's driver, it still didn't like some of the Standard Assets shaders for post-processing).
[1]: /storage/temp/195303-crash-2022-04-18-130509375.zip
Answer by DeeCeptor · Apr 22 at 11:47 PM
EDIT: Solution has been found. After much trial and error, the game no longer crashes during our loading screen, even with steam running. The issue with the graphics driver DOES NOT OCCUR if the graphics API being used is OpenGL. Adding that as an graphics API option to the build, and adding this launch parameter: -force-glcore32 fixed the issue (though for this player's driver, it still didn't like some of the Standard Assets shaders for post-processing).
Answer by rh_galaxy · Apr 20 at 11:12 PM
Since it works on some computers it might be as you say, that the memory is low, but here are two potential problems with your code.
Try
while (!AO.isDone)
instead of
while (AO.progress < 1f)
Try deleting
UnityEngine.SceneManagement.SceneManager.UnloadSceneAsync(active_scene);
It shouldn't be necessary since LoadSceneAsync(level_to_load) makes the old scene unload automatically.
Thanks for the suggestion - that weird part of the code was actually to get around the issue in an earlier version where the progress never went higher than 0.9: https://forum.unity.com/threads/asyncoperation-always-returns-0-or-0-9-coroutine-only-resumes-at-0-9.538258/