Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visual input delay when running exclusive fullscreen with vsync on #77596

Closed
vpellen opened this issue May 28, 2023 · 7 comments
Closed

Visual input delay when running exclusive fullscreen with vsync on #77596

vpellen opened this issue May 28, 2023 · 7 comments

Comments

@vpellen
Copy link

vpellen commented May 28, 2023

Godot version

v4.0.3.stable.official [5222a99]

System information

Windows 11, GTX 3070ti
(Note: I have experienced similar behavior on a laptop running Windows 10 and a GTX 1050ti)

Issue description

When running a project in exclusive fullscreen mode with vsync enabled, I experience a notable delay in my inputs - feels like a couple of frames. This is most obvious when having an object follow the mouse cursor - the object lags behind the cursor - but it's perceptible with all visual responses to input. I've also done some superficial tests with audio, and there seems to be no perceptible delay there, so I suspect this is a rendering issue rather than an input issue.

The most responsive mode seems to be exclusive fullscreen with vsync off.
When not in exclusive fullscreen mode, vsync appears to have no perceptible difference for me, which is slightly curious.

Possibly related to #35220?

Steps to reproduce

Setting the window to exclusive fullscreen and enabling vsync is all that seems to be required, but this may be heavily platform dependent, so I've included an MRP.

Minimal reproduction project

vsync_delay.zip

@Calinou
Copy link
Member

Calinou commented May 29, 2023

This is a duplicate of another issue, but I can't find it right now.

Note that in general, some delay is expected when making a sprite follow the mouse cursor, especially with V-Sync enabled. See https://docs.godotengine.org/en/stable/tutorials/rendering/jitter_stutter.html#input-lag for guidance on reducing input lag.

I wonder if this is related to the NVIDIA driver automatically using DXGI for Vulkan applications. Can you try opening the NVIDIA Control Panel, going to Manage 3D Settings then change the Vulkan window mode to prefer native Vulkan? It should be towards the end of the list of options.

Also, can you reproduce this after switching to the Compatibility rendering method in the top-right corner of the editor?

When not in exclusive fullscreen mode, vsync appears to have no perceptible difference for me, which is slightly curious.

Does input lag feel comparable to fullscreen + V-Sync in windowed mode without V-Sync?

@vpellen
Copy link
Author

vpellen commented May 30, 2023

Note that in general, some delay is expected when making a sprite follow the mouse cursor, especially with V-Sync enabled. See https://docs.godotengine.org/en/stable/tutorials/rendering/jitter_stutter.html#input-lag for guidance on reducing input lag.

True, but this isn't stuttering or the kind of delay I'd expect from a standard vsync. This is an actively perceptible delay of a couple of frames. Actually, maybe I should boot up Unity and see if it also has the weird vsync delay.. For that matter, I should check on an exported project to see if maybe it's some weird editor issue.

I wonder if this is related to the NVIDIA driver automatically using DXGI for Vulkan applications.

Nope. Cycled through the settings, no impact.

Also, can you reproduce this after switching to the Compatibility rendering method in the top-right corner of the editor?

Yep, persists in compatibility rendering mode. Actually tried that before posting, should have mentioned it. Is that still running on OpenGL? I didn't keep close track of the migration.
.. Actually, I wonder if this is reproducible on 3.6?

When not in exclusive fullscreen mode, vsync appears to have no perceptible difference for me, which is slightly curious.

Does input lag feel comparable to fullscreen + V-Sync in windowed mode without V-Sync?

Nope, input lag severity can be neatly summarized as:
Exclusive Vsync > Windowed Vsync == Windowed non-vsync > Exclusive non-vsync
That is, I get worse input delay in exclusive vsync than I get in windowed mode, and windowed mode's input delay is both minor (slightly worse than exclusive non-vsync but otherwise passable) and seemingly unaffected by vsync (both windowed vsync and windowed non-vsync are equivalent). Exclusive vsync is anomalously worse. Maybe I should try to test for screen tearing, actually...

Oh, and I am running two monitors, but that doesn't seem to be impacting it either.

If you have more ideas for tests let me know, but I might also do some more testing of my own.

@vpellen
Copy link
Author

vpellen commented May 30, 2023

Did some testing, windowed mode with vsync off has no tearing, which is curious. It makes me wonder if Godot is doing something like triple buffering in fullscreen, and windowed mode is just forcing standard vsync for some inexplicable reason?

I wonder how much of this is caused by modern Windows trying to be "Helpful".

@vpellen
Copy link
Author

vpellen commented May 30, 2023

So I did some basic testing in Godot, and the issue exists in export builds and in version 3.5.2 with both GLES 2 and GLES 3. This was about what I expected and told me very little (except that this is a longstanding issue, whatever it is) and so I decided to try and see what would happen if I attempted to recreate the behavior in Unity.

In my initial testing, Unity gave mixed results: Lag felt ever so slightly worse than it did in Godot windowed, but was consistent in exclusive fullscreen. Where things got interesting was when I decided to change Graphics APIs. By default, Unity used D3D11. But when I switched the renderer to OpenGL or Vulkan, I got the exact same input delay that I got in Godot. That is, it was generally fine outside of exclusive fullscreen, but exclusive fullscreen made it lag. This makes me wonder if it's a strange NVidia issue, because I've seen this behavior on two separate machines, and the only link is that they both had NVidia GPUs running recent (10/11) versions of windows.

I still have no idea what the hell is going on here, but since I'm cursed to be afflicted by anomalous bugs, I might as well keep digging. I'll post more if info if I uncover any.

@Calinou
Copy link
Member

Calinou commented May 30, 2023

Is that still running on OpenGL? I didn't keep close track of the migration.

Yes 🙂

@vpellen
Copy link
Author

vpellen commented Jun 13, 2023

I have managed to reproduce this issue a third time.

In SDL.

Hell, in SDL, the delay was just as bad in windowed mode as it was in fullscreen, which makes me think that OpenGL and Vulkan, for whatever reason, has this delay as standard behavior on some systems, and the only reason it lags less in windowed mode in Godot is because windowed mode isn't vsyncing properly, which would align somewhat with the odd stuttering I've been experiencing... but I digress.

In any event, while there may be some esoteric workaround for whatever the hell it is I'm experiencing, I suspect this is most likely some ass-backwards driver issue with no clean fix. If I ever get to the bottom of this in a productive manner, I'll post an update. Until then, I'm flagging this as "Not Planned".

My sympathies to the poor bastard seven years in the future reading through this in the desperate hopes that it'll solve his obscure input latency problem. May you find the peace you seek.

@vpellen vpellen closed this as not planned Won't fix, can't repro, duplicate, stale Jun 13, 2023
@vpellen
Copy link
Author

vpellen commented Aug 24, 2023

For anybody who stumbles across this at some point: I seem to have solved this problem by setting the vsync type to mailbox and manually limiting the FPS to my monitor's refresh rate. This not only eliminated the latency issues I was having but also cleaned up some stuttering I was running into. I have no idea why this works, and at this point I don't especially care. YMMV.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants