We have noticed that the first time any given scene is loaded, it is very slow.
Note we use UnityEngine.SceneManagement.SceneManager.LoadSceneAsync to load our scenes.
We see this in both editor and in a built player (both PC and console platforms). In the case of the editor it will be seen after a computer boot or after a hibernate. In a built player it will be the first time the scene is ever loaded. After that point, even after rebooting the device, the issue will not happen again.
We have noticed that when it does this long load, a lot (if not all) assets in the game are being read. There are some screen shots attached to the bug that show two instances of this.
Is there a way around this? If there is a one time thing that needs to be done for each scene, is there a way to trigger this at a time of our choice? For instance, it would be preferable to trigger this on the initial boot of the game for all scenes so that from that point on, the user experience is good.
From your bug report, it looks like it’s largely the nv_cache where it’s caching the compiled shaders which is more of a driver/OS utility in my understanding. If that’s the case, you can control when that’s done here:
Ah, my misunderstanding. It seems likely related as it’s relying on the shader cache for the seeming subsequent runs. So there’s some initial processing going on in the first passes. Will pass along to gfx folk to comment.
Regardless, the amount it is doing in the subsequent runs is not an issue performance wise. While it would be nice to get rid of that, I’m not too worried about it.
If you look at the other image and the different files that are being read, it’s page after page of assets from the game. I think possibly every asset for the given scene. There must be something that means that it does not need to do this when loading the scene again meaning we don’t see any of them when loading back into the scene.
The strange thing is that in a packaged build, you will not get this initial hit on a fresh boot into the title if you have been into that scene before. It would make more sense in my head if it happened every time you go into a new scene on a fresh boot, but it obviously caches something, somewhere which means that it does not need to do this.
Now if we knew how to trigger this caching for all scenes, an acceptable solution would be to trigger this on the very initial boot of the title. This would mean that by the time the user gets to the front end, they would never see one of these long loads for any scene.