Search Unity

Linux Build Freezes

Discussion in 'Linux' started by Zilby, Jan 25, 2019.

  1. Zilby

    Zilby

    Joined:
    Jan 25, 2017
    Posts:
    10
    Hey all, have a bug with my linux build where on launch it freezes until you hit 'escape' or 'alt + tab' and return to the application. After that everything works fine. Clicking the app while frozen progresses 1 frame of a particle system on the initial screen, but nothing else. A popup also appears saying that the application became unresponsive when starting.

    Any ideas on what could be causing this? It works fine on Mac and Windows, and there's no platform specific code in the startup scene.

    Build version is 2018.3.2f1
     
    Last edited: Jan 26, 2019
  2. Zilby

    Zilby

    Joined:
    Jan 25, 2017
    Posts:
    10
    So after almost 10 hours of debugging found the issue:
    This was not a code problem, but a loading time issue. My first scene had a component that managed my game's songs, and as such had a list of the songs (a grand total of 6 audioclips) as a public variable that was filled in in the editor.

    Apparently this takes too long to load for the first scene on Linux, causing the OS to think that my game was unresponsive, and thus causing the game to 'freeze' due to the popup (since the game doesn't run in the background). Tried fixing this by instead having my component load the audioclips through a Resources.LoadAll call but to no avail.

    Finally decided to simply add another loading scene before my (really basic) opening save selection scene. Really simple async load with a bar. But it fixes it.

    Code (CSharp):
    1. public class BasicLoad : MonoBehaviour
    2. {
    3.     /// <summary>
    4.     /// The loading bar.
    5.     /// </summary>
    6.     public Slider loadBar;
    7.     /// <summary>
    8.     /// For level loadbar.
    9.     /// </summary>
    10.     private AsyncOperation ao;
    11.  
    12.     void Start()
    13.     {
    14.         StartCoroutine(LoadLevel());
    15.     }
    16.  
    17.     /// <summary>
    18.     /// Loads the level asynchronously
    19.     /// </summary>
    20.     private IEnumerator LoadLevel()
    21.     {
    22.         yield return new WaitForSeconds(0.1f);
    23.         ao = SceneManager.LoadSceneAsync("SaveSelect");
    24.  
    25.         while (!ao.isDone)
    26.         {
    27.             loadBar.value = ao.progress + 0.1f;
    28.             yield return null;
    29.         }
    30.  
    31.     }
    32. }