Search Unity

Loading screen not working - First scene taking too long to load

Discussion in 'Editor & General Support' started by Annundur, Apr 19, 2019.

  1. Annundur

    Annundur

    Joined:
    Dec 18, 2018
    Posts:
    12
    Short version: I'm making a 2D game for Android, I want a custom loading scene when the game starts (Clash Royale style) but no matter what, after the Unity splash screen, there is a 3-5 seconds wait until it loads anything, including the loading screen.

    Long version:
    Hi everyone. I'm developing a 2D game for Android (using Unity 2018.3.2f1), and I've noticed that after the Unity splash screen, the screen turns dark grey and it takes between 3 to 5 seconds to load the first scene of the game (tested on 3 devices).

    I thought it was simply a performance issue (the first scene includes a song, a few DontDestroyOnLoad objects, etc), so I made a loading screen, following this tutorial by Brackeys. I was hoping that, if the game needs 3 seconds to load, at least the user would be seeing a nice progress bar and my logo, instead of an empty grey screen.

    But after making a custom loading screen, with just a few lines of code, the result is the same. The game shows an empty grey screen during 3-5 seconds, then shows my custom loading screen for just half a second, and it immediately loads the first game scene.

    It's like if it was loading at least the two first scenes in the background by itself while showing this grey empty screen, so by the time it actually shows the loading screen, it's useless, as the next scene is already loaded.

    So is there any way to handle this loading time when the app is opened? Maybe this asynchronous loading method only works fine between inner scenes, once the game is already running, and it's not meant to be used at the very beginning?

    Thank you very much for your help.
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Annundur likes this.
  3. Annundur

    Annundur

    Joined:
    Dec 18, 2018
    Posts:
    12
    Hello Joe,

    Thank you very much for your reply. I wasn't aware of this Preload option. I just read about it and went to check it in my project, but it seems it's empty ("Preloaded Assets size: 0") as I've never touched it before.

    Is there any other way I could be preloading assets or anything else, without knowing it? Do you know of anything else that could occur/load prior to the first scene?

    Thank you very much for your help!
     
  4. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,619
    Do you use the Resources folder?
    https://unity3d.com/learn/tutorials/topics/best-practices/resources-folder


    Have you fired up Unity's Profiler already and measured where those 2-3 seconds are being spent? Maybe that gives useful insights to the issue.

    Profiler overview
    https://docs.unity3d.com/Manual/Profiler.html

    Introduction to the Profiler
    https://unity3d.com/learn/tutorials/topics/interface-essentials/introduction-profiler
     
    Joe-Censored likes this.
  5. Annundur

    Annundur

    Joined:
    Dec 18, 2018
    Posts:
    12
    Hello Peter, thank you very much for your reply, I think it gave me really useful information.

    I've never used the Resources folder before, and judging by what I read on that link, I guess I should never used it.

    I wasn't aware of the existence of Unity's Profiler, to be honest. I've been reading about it and using it, and I found that there was something using a (relatively) huge amount of CPU: VSync. After reading about it, I'm not sure if I completely understand what it is, and why could I need it, but I disabled it, and the CPU usage went down to a 5% of what it was using before (I read that some platforms, like iOS, might force me to use it, but I guess I'll deal with that later).

    So I happily exported a new apk, tried it on my Android devices... and sadly the result is exactly the same. About 3 seconds of empty screen before loading anything.

    I attach below a screenshot of my Profiler, before and after disabling VSync, in case it includes some important info I've missed.

    I have about 140 small images included in my Assets (about 20 MB combined) and until now I've been using some of them (about 40) with "Compresion: None" at the Import Settings. I just changed them all to "Compresion: Normal quality", in case it was affecting the performance, but nothing has changed.

    Do you have any other clues about why this could be happening, or how to figure out?

    Thank you very much for all your help, I really appreciate it.

    Profiler.jpg