Misterious drop in performance when scene is loaded a second time

Hi guys, i’m facing a strange problem with my current project.
I’m working on a custom viewer for stereoscopic cubemaps and I’m developing for Gear VR (S6).

The app is composed by 2 scenes, a light-weight “home” scene, with some lowpoly 3d elements and a minimal GUI, and a second scene, the real “viewer”.
In the second scene a custom script loads 10 cubemaps (5 for the left eye, 5 for the right) and displays themes using 2 skyboxes, swtiching between left/right in the onPreRender function.

So far so good. The system works, performance is great, ram loads seem manageable.

The problem arises when i load again the first scene; performance drops, and i get 15 FPS in the VERY SAME scene where i was making 60 FPS “until a load ago”!
The problem is there every time i load the first scene after the second; if i stay in the first scene, or if i swap between two “twin” home scenes, performances stay great.

This is the profiler on the Home scene, the first time:

This is the profiler on the second scene, the Viewer (notice the high ram usage for the cubemaps)

And this is the profiler when i load again the first scene. DISASTER! 99.9% of time waiting for frames:

I’m currently loading the scene with a basic SceneManager.LoadScene (), no Additive or dontDestroyOnLoad or other strange things. I’ve tried forcing the unload of unused assets with no luck.
I’m trying to follow the Unity / Oculus guidelines for VR as closely as possibile.

Am i doing something wrong? What should i check?

I’m quite new at programming in unity, expecially for VR. every bit of help will be greatly appreciated!
let me know if you need more info or other data.

thank you so much,
marco

I’ve experienced issues where it loaded multiple scenes on top of each other even though I requested the mode = LoadSceneMode.Single enum.

In my case, I solved it by not loading scenes but I was lucky enough that I could work around it. Take a look at the Hierarchy to see if it’s doing that. I’m guessing you may done that, since you’ve gotten as far as profiling, but if you see stacked scenes, that would be the cause.

Unity changed the way they handle scene loading very recently.
From this: Unity - Scripting API: Application.LoadLevel
To this: Unity - Scripting API: SceneManagement.SceneManager.LoadScene

To test to see if it’s a bug introduced by this, you could try an earlier version of Unity. Before doing that though, you might want to try using the deprecated method (LoadLevel) to see if the problem is still there.

Curious what you find. Good luck!

-=Grig

I think i finally solved the issue!
In the second scene i was playing around with the VrSettings.renderScale parameter, which was not reset to the original value of 1 when loading the Home scene the second time. A very trivial error!