Skip to main content
New Participant
January 10, 2017

Prevent dropping out of application if main thread stalls from loading

Hey there,

I asked this question in the Unity forums but didn't get any luck and this is an Oculus specific issue.

Here are the steps we take to transition levels:
  1. Fade down to black
  2. Unload previous scene if there was one (there is a persistent level though which keeps the camera etc.)
  3. Load the new scene
  4. Fade up from black
This works fine on other platforms such as Vive though bare in mind I am using the SteamVR/OpenVR SDK not the Oculus one. 

On Oculus it seems that the main thread gets stalled during the loading process which causes a frame rate drop which forces a brief drop out of the application. So we fade down to black then it pops white and shows the sensors in front then goes back to black and fades back into the scene. Is there any way to get around this forced behaviour? I can see why the runtime does it to avoid users being in a low framerate app that might causes motion sickness but in this instance it actually makes the problem worse. 

Note that we don't have the option to make the levels/assets loaded any smaller and this occurs even when loading a few small assets additively (as we use a similar technique to the loading routine to bring in additional assets). 

Thank you

This topic has been closed for replies.

8 replies

Inspiring
January 10, 2017
Is this on Gear VR? There is a known issue there, where Unity re-allocates the eye buffers without notifying our SDK for a frame or two. We are refactoring eye buffer management to fix this moving forward. For now, you can avoid it by using Application.LoadLevelAdditive and then explicitly deleting assets from the previous scene.
alexfsAuthor
New Participant
January 10, 2017
Hey, this is on the Rift. It actually works fine on GearVR.
Inspiring
January 10, 2017
Which Unity version? Does it occur with 5.4 or 5.5?
alexfsAuthor
New Participant
January 11, 2017
5.5 
Inspiring
January 11, 2017
> Unload previous scene if there was one (there is a persistent level though which keeps the camera etc.)

Are you sure you aren't deleting the OVRManager instance? If that happens, or if you change the MSAA level, lighting space, or render scale, Unity will reinitialize VR. I would recommend making one persistent, dedicated GameObject with OVRManager.cs attached to it instead of having one on each OVRCameraRig. Can you share output_log.txt from a run where the flash occurs? I'll try and reproduce it here.
Inspiring
January 11, 2017
I can't reproduce this issue with the script code from your Unity Forum thread. I tried with a variety of projects, using OVRScreenFade to perform the fade-from-black. A minimal scene that reproduces the issue would be helpful for debugging on our end.
alexfsAuthor
New Participant
January 12, 2017

vrdaveb said:

> Unload previous scene if there was one (there is a persistent level though which keeps the camera etc.)

Are you sure you aren't deleting the OVRManager instance? If that happens, or if you change the MSAA level, lighting space, or render scale, Unity will reinitialize VR. I would recommend making one persistent, dedicated GameObject with OVRManager.cs attached to it instead of having one on each OVRCameraRig. Can you share output_log.txt from a run where the flash occurs? I'll try and reproduce it here.


Well that's the thing I don't have an OVRManager in the scene, I'm using OpenVR.
So does Oculus drop out of the app on low framerate or is that just an assumption I've made?
In that case It's seems likely that something we're doing is causing a reinitialize though I don't believe we have changed anything you have listed there.
alexfsAuthor
New Participant
January 12, 2017
So in further profiling I found some audio code that was acting strangely and sometimes taking up to 200ms which stalled the main thread and caused a drop. Also found some particle code that looked simple of the surface but actually caused an iteration of the entire particle list. 
Removed the offenders and we no longer get drop outs. Hopefully the issue won't come back!

Cheers