I am trying fix a startup load time issue on a mobile project. When the project is built and run on Android, there is a 15-25 second wait (after the Unity Splash screen) before the scene is visible.
The profiler data reveals the most time consuming items are:
Application.WaitForAsyncOperationToComplete : 15609.63 ms
Preload Single Step : 12006.81ms
The scene loaded doesn’t seem too heavy and just contains a low poly environment from the asset store (removed objects out of camera view and set others to static, Tris: 36.6k, Verts 85.0k), 9-10 mobile UI canvases (Screen Space - Overlay) and Firebase SDK. I am profiling on a OnePlus 3 running Android 8.0.0 and using Unity 2019.4.0f1.
Any pointers on understanding the data and fixing the issue would be appreciated!
(Profiler Screenshots Below)
Hi there,
Could you expand the PreloadManager thread in timeline view and check which File.Read samples in there take the most time? If you select those, the selection popup should tell you the file name. It seems like there is some quicker loads in the first 11-12 s and then one long singular load. It could also be initialization of e.g. your canvasses instead of a straight up File.Read. Would be good if you could make a build with Deep Profiling Support enabled just to get all the details on any Scripting samples in there.
Here are some screenshots with the PreloadManager expanded. There are a bunch of recurring File.Read (Screenshot 2) in the first 6000 ms that are either reading “data.unity3d” or “Data/unity default resources”.
The blue bars that take up the first 2000 ms (screenshots 3-5) mostly consist of Text Mesh Pro operations for UI elements, init operations for UI plugins, as well as some initialization done by the Easy Save plugin.
However, the two bars that take up the most time
Loading.IDRemapping Total: 2994.12ms 2320585 Instances
and
Loading.FindInThreadedActivationQueue Total: 12430.40ms 674784 instances
(Screenshot 1) don’t show any File.Read samples below them.
The Data is profiled on an Android Development Build with Deep Profile Enabled.
I have troubleshooted the issue with the unity support team. It seems to be a problem with only Mono builds.
When I switched to IL2CPP the loading time went down to 4-5 seconds for the OnePlus 3 and less than 3 seconds for newer devices.
No prob. Next I would check if you have a lot of audio files included in the build either as part of the project or from a plugin (ie Doozy UI). Some asset store plugins will include sample audio clips in the actual build. Removing them can speed up the load time depending on how many files and file size etc.
No, I never found out the reason (and I was trying to debug for an entire month), but moving all prefabs into a Resources folder at least helped me to get rid of the black screen (yet not the long loading time).
What I did is I put a loading scene and load the main scene async now. This way I have no more black screen and can show during this time my logo or anything else. I then load the Resources when needed. I wished I understood why it’s happening though so I could really debug it completely.
Not sure if this helps anyone for 3 year old post, but I was able to increase my slow startup time by turning off a bunch of colliders and using a coroutine to turn them in void start. It cut my startup from 2 minutes to under 10 seconds. Good luck game making. Used the profiler to figure this out. I was using mostly zero gravity in the rigid body so nothing moved by the way.