-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Fix mouse motion in VRR #12665
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
base: main
Are you sure you want to change the base?
Fix mouse motion in VRR #12665
Conversation
|
Hello and thank you for making a PR to Hyprland! Please check the PR Guidelines and make sure your PR follows them. If your code can be tested, please always add tests. See more here. beep boop, I'm just a bot. A real human will review your PR soon. |
|
If this works for all locked/unlocked hw/sw wayland/xwayland combinations with different games then I'm happy that all the pointer skipping and movement accumulation gets nuked. The accumulation was needed because sending the movement with locked cursor to an xwayland client straight away caused and immediate frame event in return which was treated as a valid new frame from the game and broke VRR. |
aa771e7 to
466690d
Compare
|
I just checked and this definitely does not work correctly with software cursors. |
|
|
|
Two reasons for mouse motion scheduling frames when it shouldn't:
Admittedly that code is in need of some cleanup now, and I'm unsure if Also, maybe the better way is to do this in - if (!skipFrameSchedule)
+ if (!skipFrameSchedule && (!isMouseEvent || !monitor->shouldSkipScheduleFrameOnMouseEvent())) |
eeda66d to
c73e8c1
Compare
|
After more testing, the current status is (for things I tested):
|
|
First of all, thank you @Szwagi for digging deep into this, this is quite literally the only major show-stopper preventing me from gaming on Hyprland. Secondly, I'm not quite able to replicate your above behavior matrix. For me, no matter what, on the latest version of your branch, I'm seeing stuttery camera movement on CS2 with a frame limiter set, though perhaps there's something I'm missing. That being said, It looks like Half-Life 2 works for me with This seems like a real nightmare of an issue for you guys lol, if you want me to validate any further findings on my end let me know. |
|
Dunno if there's any relation, but last I checked, software cursors disable direct scanout regardless of if they're visible or not. Could direct scanout be related to the difference here? |
So I just re-tested this. With both direct scanout and hardware cursors enabled, playing Wayland native CS2 with an FPS limit of 140 on 144 VRR display, I'm still getting the occasional spike to 144 when moving the mouse, causing visible hitching. |
Can't reproduce on NVIDIA, could you share your config? Worth noting that CS2's Edit: |
Ah, I was unaware of that, switching to ManguHud's limiter did fix the issue on wayland. I think I'm still seeing the issue with CS2 in xwayland mode, though it is far less frequent. That being said, it feels amazing in Wayland. |
|
I am unsure if e4013b8 is entirely correct, but it should function the same or better than the frame schedule removed in ee471d1, and without introducing unnecessary frame schedules on mouse motion. From my testing it's only necessary for Firefox which seems to be broken (based on the amount of Firefox hacks)? It also fixes an issue with frames not being scheduled when the surface x/y is not on any monitor. I didn't look hard for the remaining hardware cursor issue yet, but I suspect it might be a bug in Aquamarine. Status to my eye:
|
|
I just pulled and did a test of my own with the 8 combinations when This even fixed the mild VRR flicker I was getting. Good job again on this one, you have no idea how much sanity I was losing testing things before I saw this PR. |
|
e60c987 fixes framerate spiking when changing window focus caused by animations scheduling many thousands of frames per second for animations that aren't visible. I did more research and I don't believe Hyprland is responsible for breaking VRR with hardware cursors and no_break_fs_vrr=1. With an unlocked cursor, Hyprland schedules exactly 125FPS on a 125FPS lock, but my monitor reports 250FPS or an unstable 330FPS coming in depending on the game. It's possible there's still an extra frame scheduled on cursor visibility change. My reports spikes by 1-2FPS, but I couldn't see any extra frame schedules except for the unrelated 37ae610, perhaps monitor getting confused by a lag spike in the game when opening the menu. @vaxerski I think this is all for the issues I found. I will now daily this branch to see if something comes up, but would like to know what you think of this and what the glaring issues are :D |
vaxerski
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in general looks ok just needs some testing yea
| if (scale != 1.0) | ||
| damageBox.scale(scale); | ||
| if (damageBox.empty()) { | ||
| const auto VIEW = WLSURF->view(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some programs like Firefox get empty damageBox here even though they redrew the entire window, ignoring makes it freeze and update only on mouse motion. Old code used getMonitorFromVector(x, y) and scheduled a frame on that monitor, but that breaks when the x, y is not on any monitor, making it freeze
I am unfamiliar with the codebase, so this PR most definitely has plenty of issues I haven't found.
If the actual solution is more complicated than this, I'm unlikely to be of any help, but would love to see this fixed and working as well as this is for me.
Fixes #12032 and this sounds related too #12013.
I will take CS2 on a 360Hz display as an example. When I say FPS measurements I mean what the monitor reports.
Before (the issues):
After:
My idea of what is happening is that
I have tested in CS2 with native Wayland and XWayland. I have also tested in a Wine game running through Gamescope.