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. Dismiss Notice

Question Very long startup time on mobile

Discussion in 'Editor & General Support' started by a-bottosso, Dec 15, 2020.

  1. a-bottosso

    a-bottosso

    Joined:
    Nov 13, 2015
    Posts:
    22
    Hi everyone,

    I'm experiencing a very long startup time of my mobile game (more than 10 seconds in both Android and iOS) before the splash screen.
    The project is made in Unity 2019.4.11 LTS, using LWRP.

    I already checked some things that could affect this startup time:
    - Resources: I have only the localization asset in my resources folder;
    - Big first scene: The first scene of the game is a really small bootstrap scene, that only instantiate a prefab and start loading the "real" first scene with a loading screen;
    - Preloaded Assets: This list is empty;
    - Preloaded Shaders: This list is empty;
    - Development Build: The buils is not Development Build;
    - Audio with Preload Audio Data: At the moment there's no audio in my game.

    What other things can affect the startup time?
    Any help will be appreciated.
    Thanks,
    Alessio
     
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,444
    I think the [RuntimeInitializeOnLoadMethod] attribute does, depending on what code is being executed in those methods.
     
  3. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    But does the first scene reference anything that's big even if it doesn't actually use it? Because everything referenced in the scene, and everything those things reference, and what those things reference, etc, etc, all gets loaded before the scene starts, even if you never actually use any of it in that scene.
     
  4. a-bottosso

    a-bottosso

    Joined:
    Nov 13, 2015
    Posts:
    22
    Yes, this is the real problem, the first scene reference an object that instantiate another object with references to some heavy scriptable objects.
    Which could be the best way to handle these scriptable objects without a direct reference? They store, for example, the prefab of the 3D models of all the level environments.
     
    Joe-Censored likes this.
  5. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    You could try moving the heavy loading to its own separate scene which you async load in additive mode alongside a main scene. That way your game should be responsive and feel like it is doing something while the player waits for it to be ready to play.

    https://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager.LoadSceneAsync.html