Yellow-Dog-Man / Resonite-Issues

Issue repository for Resonite.
https://resonite.com
102 stars 0 forks source link

VSync toggle should stay force-disabled when a VR headset is connected #1927

Closed Zyro1331 closed 2 weeks ago

Zyro1331 commented 2 weeks ago

Describe the bug?

When Resonite is connected to an VR headset, switching back to Desktop mode will not adapt to the main display's refresh rate, which causes VSync to induce very high amounts of unnecessary display latency.

To Reproduce

  1. Start Resonite with a VR headset
  2. Switch to Desktop mode with F8 or Hotswitch
  3. Then enable VSync in Resonite's graphics settings If the bug is occurring, your framerate will remain far below your VR headset's refresh rate, as well as stay below your main monitors refresh rate.

Expected behavior

The settings toggle for VSync needs to be completely disabled when a VR headset is present. Due to the fact that Resonite's renderer needs the framerate to stay limited to the VR Headset's refresh rate.

Screenshots

Here's an example of what occurs when VSync is enabled and disabled. image

(Screenshot of frame-time graph, the orange line is the engine latency, and the blue line is the rendering latency)

Resonite Version Number

Beta 2024.5.3.467

What Platforms does this occur on?

Windows

What headset if any do you use?

Meta Quest 3 (SteamLinkVR) + Desktop

Log Files

MANGOVRG - 2024.5.3.467 - 2024-05-03 03_35_09.log

Additional Context

No response

Reporters

@Zyro1331

Frooxius commented 2 weeks ago

Unfortunately this is not possible.

If VR SDK is active, it takes full control over the framerate and these options are simply ignored by Unity.

Zyro1331 commented 2 weeks ago

If VR SDK is active, it takes full control over the framerate and these options are simply ignored by Unity.

That's the issue, VSync should be ignored but it isn't. Which I feel isn't optimal for Hotswitch users. I keep my VSync enabled intentionally to keep some system resources free for other applications when using pure Desktop mode, but when VR SDK is active, VSync becomes is kind of pointless when your framerate is already capped to your HMD's refresh rate. I'd prefer the setting be ignored or default disabled if another device is using it's own VSync, just like how Resonite behaved before the VSync setting was added.

shiftyscales commented 2 weeks ago

Can you provide context on which headset / VR SDK you are using, @Zyro1331?

I've noticed before that Oculus headsets will clamp the refresh rate to a much lower value while the user is outside of the headset- this results in the low framerate/high frametime output you demonstrated above.

VSync in Resonite was always previously forced on, so the behaviour should be the same as it was before if VSync is on.

Zyro1331 commented 2 weeks ago

Can you provide context on which headset / VR SDK you are using, @Zyro1331?

I've noticed before that Oculus headsets will clamp the refresh rate to a much lower value while the user is outside of the headset- this results in the low framerate/high frametime output you demonstrated above.

VSync in Resonite was always previously forced on, so the behaviour should be the same as it was before if VSync is on.

I am using Steam VR (via SteamLinkVR) with a Meta Quest 3 The clamped framerate becomes far lower when the headset disconnects, forcing the Steam VR to force framerate to below 10 FPS. However this can simply be avoided by keeping the headset connected by disabling the automatic sleep setting and keeping the headset plugged in.

On previous builds, when I Hotswitched back to desktop mode, Unity's VSync would remain off just as normal to reduce render latency. It would stay force-disabled as long as the VR SDK was active. But now on newer builds of Resonite, VSync will stay disabled when Present in VR, but as soon as you Hotswitch to desktop mode, VSync suddenly enables, which is not as it behaved previously.

shiftyscales commented 2 weeks ago

I think you might be misunderstanding/misinterpreting your findings?

In both cases the VR SDK is controlling the framerate/refresh rate. As you pointed out, and as I mentioned above- what is happening is that the VR compositor is clamping the framerate to <10 while the headset is asleep.

Resonite isn't controlling the framerate/refresh rate/VSync at all- it's the VR SDK as Frooxius mentioned above.

Zyro1331 commented 2 weeks ago

Resonite isn't controlling the framerate/refresh rate/VSync at all- it's the VR SDK as Frooxius mentioned above.

I am confident that it is, as the framerate takes a large hit when toggling the setting on or off. Here is a screen recording of the behavior. Including Steam VR's own Frame time graph taking a large hit after VSync is enabled. Note that when VR mode is enabled, the toggle is ignored, as it should be.

https://github.com/Yellow-Dog-Man/Resonite-Issues/assets/49619936/554f2bf8-6cc1-4c66-9cd4-778142e90d07

shiftyscales commented 2 weeks ago

Seeking input from @Frooxius - it does seem like there is some anomalous behaviour here as the above video demonstrates.

Frooxius commented 2 weeks ago

I've looked into this more and we just disable the VSync & Frame limiting when VR is active, it doesn't work with an active VR SDK and seems to misbehave.

This has been released in 2024.5.4.678, thanks!