Search Unity

[5.3] Crash when Application.LoadLevel is called on Awake()

Discussion in 'Editor & General Support' started by ekt, Dec 13, 2015.

  1. ekt

    ekt

    Joined:
    Jul 9, 2012
    Posts:
    26
    repro steps:
    • Have two (empty) scenes added to the scene list in build settings
    • On the first scene, have this script running:
    Code (CSharp):
    1. public class FirstScene : MonoBehaviour
    2. {
    3.     void Awake()
    4.     {
    5.         DontDestroyOnLoad(gameObject);
    6.         Application.LoadLevel("SecondScene");
    7.     }
    8.  
    9.  
    10.     void OnGUI()
    11.     {
    12.         if (GUILayout.Button("Button that will generate the crash"))
    13.         {
    14.             var obj = new GameObject("IWillNeverSeeTheLight");      
    15.         }
    16.     }
    17. }
    18.  
    as soon as you hit the button the ide crashes

    Case 753478 with repro project on FogBugz
    https://fogbugz.unity3d.com/default.asp?753478_hfaj8dk3vnq6mq4t
     
  2. SteenLund

    SteenLund

    Unity Technologies

    Joined:
    Jan 20, 2011
    Posts:
    456
    Thanks

    we will look into this
     
  3. SteenLund

    SteenLund

    Unity Technologies

    Joined:
    Jan 20, 2011
    Posts:
    456
    This should already be fixed. The fix will probably ship in 5.3.0p1 or p2
     
  4. ekt

    ekt

    Joined:
    Jul 9, 2012
    Posts:
    26
    nice
    thank you
     
  5. rebelincontrol

    rebelincontrol

    Joined:
    May 19, 2015
    Posts:
    19
    @ekt as a temporary fix I found moving SceneManager.LoadScene/Application.LoadLevel into Start worked for me.
     
  6. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    796
    Still a problem for us, p4
     
  7. SteenLund

    SteenLund

    Unity Technologies

    Joined:
    Jan 20, 2011
    Posts:
    456
    @Prodigga

    Can you share a project that reproduces the issue or file a bug and post the number here.
     
  8. ndruha

    ndruha

    Joined:
    Jun 5, 2015
    Posts:
    1
    Confirmed, crashes in Unity 5.3.1f1 in the Editor in Windows 8 with the above mentioned code. Sometimes it doesn't crash from the first attempt, but when stopping project in the Editor and pressing Play a few more times, it crashes.

    I also got it crash with as simple code as this, just with quickly pressing Play and Stop around 20-50 times.
    1. void Awake()
    2. {
    3. Application.LoadLevel("SecondScene");
    4. }

    It also crashes when using instead
    SceneManager.LoadScene("SecondScene", LoadSceneMode.Single);

    The workaround that seems to work, is to start coroutine, skip one frame, and load the scene from there.
     
    Last edited: Jan 27, 2016
  9. SteenLund

    SteenLund

    Unity Technologies

    Joined:
    Jan 20, 2011
    Posts:
    456
    I have finally been able to reproduce. When reproducing bugs I always work on debug builds and 99.9% of the time, this is good enough.

    This time it turns out the bug only reproduces on an optimized release build. I am working on finding the problem and getting it fixed.
     
    josh_s_dev and ndruha like this.
  10. Howard-Day

    Howard-Day

    Joined:
    Oct 25, 2013
    Posts:
    124
    Was there ever a solution to this? This looks exactly like an issue we're seeing in the Unity 5.4.0B21 beta. :/
     
  11. ladyonthemoon

    ladyonthemoon

    Joined:
    Jun 29, 2015
    Posts:
    236
  12. Howard-Day

    Howard-Day

    Joined:
    Oct 25, 2013
    Posts:
    124
    The correct answer is that multithreaded rendering breaks and crashes unity in beta21 builds using canvas. Thanks!
     
  13. SteenLund

    SteenLund

    Unity Technologies

    Joined:
    Jan 20, 2011
    Posts:
    456
    @Howard Day
    Ok, that makes sense, because the issue discussed in this thread was fixed long time ago
     
unityunity