- Home /
HUGE Lag Spike on small scene loading!
Hello! I'm working on a small mobile game, which is using only two scenes: Menu and Game scene, alongside with one GameObject with DontDestroyOnLoad (which is only holding a script with some Read-Only color arrays).
Whe transfering between the two scenes though, I am getting a HUUUGE (~10-15 seconds) freeze spike on mobile. Profiler is showing that on the scenes temselves there's like 1000 FPS, but on scene transfer, there is one process - Loading.UpdatePreloading -> Application.WaitForAsynchOperationToComplete - which is taking a huge chunk of time to load.
How can I prevent it? What is this process?
take a look at the Profilers memory consumption. if it loads a lot that also takes time
Unfortunately, the spike occurs on $$anonymous$$obile build, not only in editor. In editor it takes less time (as a computer has a bigger CPU/GPU than on mobile).
Every object you have in scene will be loaded
Every asset that those object have like images will be loaded
Every Awake and enabled Start/OnEnable will be called
In Player Settings > Other Settings you can find list Preloaded Assets. You can add stuff from assets to that list and all of them will be automatically loaded into ram when you start your game.
Answer by Vel_1828 · Feb 08, 2017 at 04:28 PM
OK, everything is fine again - it appears that all music files used in the Game Scene were set to Load at once on Scene Load, while they should be set at Streaming in Import Settings. It's good now, thanks for answers! :)
Thanks for co$$anonymous$$g back to share the solution. I've been caught out by audio performance in the past too - just that one little setting can make a huge difference! :)