Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Long Android Startup Time

Discussion in 'Android' started by Wolar, May 24, 2019.

  1. Wolar

    Wolar

    Joined:
    Sep 25, 2014
    Posts:
    38
    Hello, we have a problem with long app startup time on the Android. On some very slow/old devices our startup time reaches up to 40 seconds. We have analysed the issue in the past few days and this is what we have come up with.

    What we did was that we have been adding / removing stuff from the project/first scene and run it on device several times to test out the startup time (time since the press of the button to the load of the first scene).

    First scene is basically empty (there are some SDKs initialisation there) and its only purpose is to load next scene.

    Device LG G3 (faster devices are ok, slower are much worse)
    - Unity (empty project) 1-1.5s
    - Firebase (Analytics, Remote Config) - 1.5s
    - Textures (Atlas with 4 2048x2048 textures) - 1.5s
    - TextMeshPro (with fallbacks on CJK fonts which are loaded in startup = 3-4 textures with 1024-2048x2048) - 1s
    - IronSource SDK, Facebook SDK - 0.5-1s
    - Other / Unknown 1-2s
    -------------
    - FirstScene => MainMenu (Prefabs, initialisation, data etc.) - 3s

    It seems that the less code / plugins / models etc. we had in the project the shorter the "Other / Unknown" took but that stuff is not loaded in the first scene, it's loaded in the MainMenu scene or later.

    When I have deleted all the assets / plugins etc. from the project but kept the Project / Quality / Graphics settings, the load time was equal to the Unity empty project.

    So it seems there is something loading / initialising at the startup of the game but we cannot figure out what, there is nothing suspicious in the memory profiler.

    We have no audio so that can't cause the problem. We use IL2CPP, ARMv7, no multithreaded rendering (AR does not supports it) but enabling it didn't help anyway. Scripting and API compatibility both on 4.x (changing API compatibility to 2.0 didn't help as well). We have tried to delete all the shaders as I believe those are loaded at the startup. Nothing really helped.

    So basically I have two questions
    a) Is there something I'm missing out? Mainly in the part where is seems that unused / unreferenced assets or scripts seems to be increasing startup time quite a lot.
    b) Is there something else I might try / do to improve startup time in general?

    Thank you
     
    Novack likes this.
  2. jturner221

    jturner221

    Joined:
    Aug 30, 2017
    Posts:
    17
    I am having a similar issue. Issue present at loading start scene into main menu scene.

    It seems to occur during the unity initialization stage of the scene in creating `gameobjects` Are you seeing this in the profile as well? You can watch the gameobject count rise as your scene is loading.

    It takes our android app 50+ seconds to load. The ios app takes 5-12 seconds to load.
     
    ROBYER1 likes this.
  3. Wolar

    Wolar

    Joined:
    Sep 25, 2014
    Posts:
    38
    I was mainly trying to improve the Startup -> StartScene time and I didn't find the way to properly profile it as I cannot connect profiler to the non-running app, if you have a way to profile it, please let me know. Truth is, speeding up StartScene -> MainMenu could also help us a little bit but I didn't profile it that much.

    What I have found and what might help you (maybe) is, that everything that is referenced by anything gets loaded into the memory even if it's not currently used. This might be pretty slow on low-end Androids.

    For example if you have a MainMenu script in the MenuScene, that references SubMenu Prefab, the SubMenu Prefab references ScriptableObject which references texture(s) for example (this chain might be pretty big), all of this will get loaded to the memory as soon as MenuScene is loaded even though you might never instantiate SubMenu or anything else.

    Also if you have a SpriteAtlas that has multiple textures, referencing just one sprite from that atlas will load all its textures to the memory.

    Same thing applies to the Resouces.Load, as soon as you load something into the memory via this method, everything else that this thing is referencing will be loaded into the memory as well.
     
  4. tkeene_vspatial

    tkeene_vspatial

    Joined:
    May 2, 2017
    Posts:
    4
    I've found that anything that happens in the first frame of rendering can delay that frame being displayed. Everything doing Awake(), Start(), or OnEnable() can increase this time. A workaround I found was to have a scene with only a camera and a script that async loads the next scene after a couple frames, so you can display a logo or loading bar (even if it's going to freeze for a bit while everything loads in).

    Not using Resources folders was also helpful. Unfortunately many Asset Store plugins, and even default Unity Standard Assets, rely on using the Resources. This includes any Packages in the Packages tab of your project, which you can audit with the editor's Search tool by selecting the In Packages filter.

    This is quite annoying on platforms like the Oculus Go, where taking more than 4 seconds to show anything to the user is a VRC/lotcheck violation.
     
  5. el_Guero

    el_Guero

    Joined:
    Sep 15, 2017
    Posts:
    185
    Did you ever resolve this? I have the exact same problem and would appreciate any help.


    I heard that resources load would actually resolve the problem. Not the case?

    Any practical advice on how to resolve this is appreciated. I can’t even put a loading scene first because the black screen delay avoids the UI of the first scene to be loaded.