Search Unity

Application.LoadLevelAsync causes a huge spike

Discussion in 'Scripting' started by artaka, Feb 23, 2015.

  1. artaka

    artaka

    Joined:
    Feb 19, 2013
    Posts:
    128
    The spike happens right when I start the following coroutine:
    Code (CSharp):
    1. AsyncOperation asyncOp;
    2.  
    3. IEnumerator LoadLevelAsync(string levelToLoad)
    4. {
    5.     Application.backgroundLoadingPriority = ThreadPriority.Low;
    6.     asyncOp = Application.LoadLevelAsync (levelToLoad);
    7.     asyncOp.allowSceneActivation = false;
    8.  
    9.     yield return asyncOp;
    10. }
    Digging through the profiler the spike points to Loading.LockPersistentManager. It's as if the LoadLevelAsync tries to load on the main thread instead of the background thread. This happens in the Editor and on iOS, and Android devices. It's heaviest in the Editor though. I'm using Unity 4.6.3.f1. Is this a Unity bug or am I doing something wrong?
     
  2. artaka

    artaka

    Joined:
    Feb 19, 2013
    Posts:
    128
    Anybody?
     
  3. tao-tao

    tao-tao

    Joined:
    Nov 17, 2012
    Posts:
    14
    seem nobody knew it....
     
  4. wana7262

    wana7262

    Joined:
    Jul 2, 2012
    Posts:
    103
    same problem with me :(
     
  5. artaka

    artaka

    Joined:
    Feb 19, 2013
    Posts:
    128
    Reported this as a bug (#677082). Hopefully it'll be addressed soon.
     
  6. cowtrix

    cowtrix

    Joined:
    Oct 23, 2012
    Posts:
    322
    +1 to this, we've just encountered a similar issue.
     
  7. PedroGV

    PedroGV

    Joined:
    Nov 1, 2010
    Posts:
    415
    I've just experienced a similar issue with Unity5, but it also locks the editor.
     
  8. Tetsuya_OYA

    Tetsuya_OYA

    Joined:
    Jul 20, 2013
    Posts:
    13
    I have same problem.

    >Reported this as a bug (#677082). Hopefully it'll be addressed soon.

    How can I access #677082 on Issue Tracker?
     
  9. HugoZandel

    HugoZandel

    Joined:
    Mar 11, 2014
    Posts:
    52
    I have this problem too but it seems to be random.

    Edit: Would be great if someone from Unity could explain why this is happening and how to make it stop.
     
    Last edited: Aug 14, 2015