Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Intermitent crash when switching scene with LoadLevelAsync with Unity 5.2.0f3 and 5.2.1f1

Discussion in 'Editor & General Support' started by jimmikaelkael, Sep 21, 2015.

  1. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    783
    Hi,

    I recently updated my project to Unity 5.2.0f3 (from 5.1.3). Everything was fine but I soon discovered I had intermittent crashes when switching scene with LoadLevelAsync.

    The crash were not happening in 5.1.3 and it can strike in both Unity Editor and Standalone build. I don't know if it's project specific and that is why I'm posting here.

    At least it seems to be scene specific as I have 2 scenes in my current project:
    - Level 0 is the main menu,
    - Level 1 is the main game scene.
    The crash happens when switching from Level 1 to Level 0 only, but not everytimes.

    I'm attaching an output log, but despite the fact I've enabled development build and script debugging I don't have any clue exept the stack trace... Otherwise it seems it's crashing when unloading unused serialized files.

    Has anyone noticed the same thing ?
     

    Attached Files:

  2. Polkatuba

    Polkatuba

    Joined:
    Oct 31, 2014
    Posts:
    79
    Hmm... I have had some crashes with my build during scene load. I'm using LoadLevelAsync too.
    The crashes have happened with another machine, but not with the one I'm using for development.
    Unfortunately this all I know about this right now.
     
  3. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    783
    Thank you for the feedback!
    I'm experimenting the crashes on several machines on my side.
     
  4. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    783
    Yesterday I updated to Unity 5.2.1f1 and I get the same intermittent crashes when it's unloading serialized files...
    Would be great to have someone from UT to shed lights on this if possible.
     
  5. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    783
    Anyone ?

    Still get the same anoying crashes during serialized files unload:
    Code (csharp):
    1.  
    2. Unloading 3 Unused Serialized files (Serialized files now loaded: 0)
    3. Crash!!!
    4. ...
    5.  
    I'd like to know, what does this means ?
     
  6. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    783
    Still happen with Unity 5.2.1p2...
     
  7. FuRy

    FuRy

    Joined:
    Apr 16, 2013
    Posts:
    28
    I am also experiencing this issue on 5.2.1p1.
     
  8. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,850
    Do you have a bug number or issue tracker link? Has anyone reported it?
     
  9. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    783
    @karl.jones Not yet it seems... My project is around 20GB so it's a bit too much to send as a repro case. I'm trying to get a repro case from the ground up but once again it seems to be scene specific...
     
  10. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,850
  11. MagicZelda

    MagicZelda

    Joined:
    May 1, 2013
    Posts:
    90
    same problem with me. Its intermitant
     
  12. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    783
    I'm currently doing quite big changes in my open world scene as I want to stream it. I disabled a script that was used by some gameObject to translate their messages printed on screen and it seems the crash has gone.
    I'll investigate further to see if I can find the culprit.
     
    karl_jones likes this.
  13. FundaySoftware

    FundaySoftware

    Joined:
    Sep 16, 2014
    Posts:
    22
    We had this before Unity 5.2 landed. Link here. It had to do with IL2CPP running out of file handles (I think) - but should be fixed now. I havent seen the bug since 5.2 at least. Which platform are you on? our project was iOS.
     
  14. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    783
    On my side I'm on Windows 7 64bit. I don't think it's the same bug, the one I'm getting appears when unloading serialized files.
    The crashes appeared on 5.2 on our side.
     
  15. FuRy

    FuRy

    Joined:
    Apr 16, 2013
    Posts:
    28
    I just moved back to 5.1.3 and don't have an issue anymore.
     
  16. FuRy

    FuRy

    Joined:
    Apr 16, 2013
    Posts:
    28
    Has there been a fix for this yet?
     
  17. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,716
    5.2.2 here, 100% while loading/unloading specific set of prefabs.
    No info in the crash log;
     
  18. holliebuckets

    holliebuckets

    Moderator

    Joined:
    Oct 23, 2014
    Posts:
    496
    I see @karl.jones is here helping, but have you tried loading an empty scene before your next scene? :D It clears the cache and is very useful :)
     
  19. liiir1985

    liiir1985

    Joined:
    Jul 30, 2014
    Posts:
    147
    I'm experiencing similar issues, in my case the editor or player won't crash, sometimes it will start to consume 100% of CPU usage and RAM and freezes the whole system. In my knowledge there's no way for us to use 100% of the CPU resource in our c# code unless we start some custom threads, which isn't the case. I tried to troubleshoot the problem and investigated my code and couldn't find anything.

    I'm not able to reproduce the situation everytime, it happens like once every 10 Scenes, I'll submit a bugreport if I find a way to reproduce it.

    Ps. I'm using 5.2.2
     
  20. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    783
    On my side I do no longer have the problem, this is very strange... Maybe a fact that I cleared the GI cache and wiped baked data to bake it again, I'm not sure.
     
  21. holliebuckets

    holliebuckets

    Moderator

    Joined:
    Oct 23, 2014
    Posts:
    496
    I would definitely suggest loading an empty scene in between scenes. This releases the cache/memory before loading the next scene.
     
  22. Teku-Studios

    Teku-Studios

    Joined:
    Sep 29, 2012
    Posts:
    257
    Usually what we do is loading an empty scene (not actually empty since it contains a "loading" animated sprite, but whatever), call the Garbage Collector to free the memory and then load the next scene asyncronously while the loading icon is shown.

    That's the most convenient way to proceed, I presume.
     
    holliebuckets likes this.
  23. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,716
    In my case, there is no scene. I'm loading/unloading prefabs using Resources.
     
  24. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,850
    Hey lightstriker. Have you filled a bug report? Would be great to have the same prefabs you have that are causing the issues.
     
  25. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,716
    Sadly, it's not possible to send them over. The issue of developing for a third-party who want to keep everything behind closed door. Right now we reverted to 5.1 because we ship next week.
     
  26. StrykerTorstein

    StrykerTorstein

    Joined:
    Mar 13, 2016
    Posts:
    3
    Okay so i was having the same problem but i did a little workaround with bools, what crashed me was everytime i put the Scenemanager.SceneUnload on a void OnTriggerExit it crashed everything, build and editor.

    This is probably good for people looking for a World of Warcraft style level loading :) All it needs is networking

    Here's my workaround:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEngine.SceneManagement;
    4.  
    5. public class InteriorLoad : MonoBehaviour {
    6.  
    7.     [Tooltip("Name of the scene you desire to load.")]
    8.     public string SceneToLoad;
    9.     private bool interiorIsLoaded;
    10.     private bool unlodingInterior;
    11.  
    12.     void Start()
    13.     {
    14.         interiorIsLoaded = false;
    15.         unlodingInterior = false;
    16.     }
    17.  
    18.     void Update()
    19.     {
    20.         if (unlodingInterior)
    21.         {
    22.             SceneManager.UnloadScene(SceneToLoad);
    23.             unlodingInterior = false;
    24.             interiorIsLoaded = false;
    25.         }
    26.     }
    27.  
    28.     void OnTriggerEnter(Collider other)
    29.     {
    30.         if (interiorIsLoaded == false)
    31.         {
    32.             SceneManager.LoadScene(SceneToLoad, LoadSceneMode.Additive);
    33.             interiorIsLoaded = true;
    34.         }
    35.         else
    36.         {
    37.             return;
    38.         }
    39.     }
    40.     void OnTriggerExit()
    41.     {
    42.         if (interiorIsLoaded == true && unlodingInterior == false)
    43.         {
    44.             unlodingInterior = true;
    45.         }
    46.         else
    47.         {
    48.             return;
    49.         }
    50.     }
    51. }
     
  27. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,716
    Also noticed that asking Unity to load the same thing twice in the same frame make it goes insane. For a few dozen frames, it generates ton of garbages.

    However, if I call something only once per frame, it's all fine.
     
  28. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,850
    Could you file a bug report with a simple repro please?
     
  29. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,716
    Nevermind... We had a "Resources.UnloadUnusedAsset" that was taking 50ms and for some reason making everything - physic included - choking like someone who is smoking a car tailpipe.

    To be honest, resources unloading is still a very obscure system that you're never totally sure something was properly unloaded, and that you somehow can unload from 3-4 different way, which doesn't all work for each resource type.