VR.WaitForGPU lag UNLESS camera is selected in editor
I'm getting giant, regular spikes of "VR.WaitForGPU" - but ONLY when the active camera isn't selected in the hierarchy. If I simply select the camera, my FPS goes from 60-100 up to 200.
I'm running 5.4f1 with a Vive.
I'm also seeing this on 5.4f1. The spikes are very regular, usually up to a time of 16-17 ms. I didn't notice any change from selecting the camera. In the GPU profiler the spikes are attributed to the "Other" category.
I also tried it in Unity 5.3.4f1, and saw similar spikes, though they were attributed to different causes. In the CPU profiler the spikes appears as "S$$anonymous$$mVR_Render.RenderLoop() [Coroutine: $$anonymous$$oveNext]" inside "PlayerEndOfFrame". In the GPU profiler the spikes are attributed to "RenderTexture.SetActive", with the spikes going up to ~20 GPU ms.
I have a GTX 1070 and an A$$anonymous$$D FX-8350. Hopefully this info helps someone figure it out.
Answer by mgc90403 · Jul 18, 2016 at 03:42 AM
Side note - the issue persists upon building. Is there some way to tell Unity to act as if the camera is selected, at runtime?
Answer by MartijnIvory · Jul 27, 2016 at 02:34 PM
Getting the same thing... the spikes are about 16ms. I had not noticed that selecting the camera makes a difference, good catch:)
What could be going on here?
Answer by stack86 · Oct 03, 2016 at 03:31 AM
Yeah this is crazy, I get it too. I hadn't noticed the same lag building though, like mgc mentioned.
To make the issue less annoying (certainly not a fix) I whipped up a script to select the camera whenever you press play (just attach to your camera eye object)
using UnityEngine;
#if DEBUG
using UnityEditor;
#endif
//attach this to the object you want to become selected when 'Play' is pressed in the editor
//purpose: to fix the Unity/VR bug where framerate tanks if camera eye isn't selected
public class SelectedOnPlay : MonoBehaviour {
#if DEBUG
SelectedOnPlay() {
EditorApplication.playmodeStateChanged = HandleOnPlayModeChanged;
}
void HandleOnPlayModeChanged()
{
if (EditorApplication.isPlaying)
{
//select this object
if(Selection.activeObject != gameObject)
Selection.activeObject = gameObject;
}
}
#endif
}
Using this script in the camera gives me 4% increment in fps performance.
Really strange. Definitely see a huge FPS boost when the camera is selected, thanks for the temp fix at least. Running Unity 5.6.1f1 with S$$anonymous$$mVR plugin 1.2.2 for Vive
Edit: Although I notice that when the camera is selected now, the tracking on the controllers is really laggy :(
Edit 2: Actually, it seems that my lag/fps issues were solved by maximizing the game viewport on play (when playing in the editor). Idea suggested by a Valve dev here: https://s$$anonymous$$mcommunity.com/app/358720/discussions/0/357286532028854272/
Your answer
Follow this Question
Related Questions
[SteamVR] Object grabbed by left hand is rotated by 180, grabbed with right one is fine. 0 Answers
SteamVR Circular Drive reversing 1 Answer
Unity 5.3.1p3 - Viewports on Render Textures are warped when Virtual Reality Supported is enabled. 0 Answers
How do i fix my problem with minimizing/maximizing and just opening unity editor windows? 0 Answers