ValveSoftware / gamescope

SteamOS session compositing window manager

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[bisected] Framerate spikes/screen freezing when moving mouse cursor at high pooling rate

VeilSilence opened this issue · comments

Greetings

  • NixOS 24.05
  • Plasma 6 wayland session.
  • Nvidia rtx 3090. Hardware cursors enabled.
  • 550.78 driver.
  • Gamescope 6f185c7 version

When my mouse is set to an 8000Hz polling rate, every time I see the cursor in-game and move it around the screen, the game basically freezes for about 3-5 seconds (or just straight up crashes) until I stop moving my mouse. At a 1000Hz polling rate, the game no longer freezes, but there is a noticeable framerate/performance drop until I stop moving my mouse.

I bisected the issue to this commit: febcf34. I reverted this commit and built the git version of Gamescope, and it indeed fixed the performance/freezing issue, but I can't click anything in the game now.
Probably commit 7c4438a is the issue, but I couldn't revert this commit and build the Gamescope git version to test it.

This issue probably related to mine also: #1279

Probably commit 7c4438a is the issue

I built gamescope @ 7c4438a and then built gamescope from the commit before it.
And then used ddisasm to disassemble the binaries so I could compare them (with difftastic)
Haven't finished looking thru all the dissassembly, but so far, I can see that just by comparing the assembly for gamescope::CWaylandPlane::Present, it seems that commit 7c4438a has about 6 more mov instructions...
nothing conclusive so far, tho maybe I'll need to do something in wayland_backend.cpp similar to what I did in #1287
I'll have to look more into it...

Oh well, I must apologize for wasting your time.
Problem is still here, I just somehow bisected to wrong commit sadly...
After verifying at least 3 times and even record on video everything, my result of investigations:

Git version gamescope freezing showcase

CPU spikes on cursor move

freezing.mp4

I started bisecting once again.
Gamescope ee02018 commit:

Video showcase. Wrong cursor position, but no framerate spikes. Cursor can interact with game

not.freezeing.Can.interact.with.menus.mp4

Commit 252a189. This is where this problem appears:

Wrong cursor position and frame spikes. Cursor can interact with game

bad.commit.mp4

I was one off of actually problematic commit. In commit 2898cce, my cursor can't interact with game, so framerate was unaffected by this bug...

In the end, I made patch that revert few things from 252a189 commit.
My result on 6f185c7 commit + patch:

Final result. Happy end.

git_revert_patch.mp4

Patch itself

From d0f76adf039f094ea14a2a2b9fe5fc103ab6f968 Mon Sep 17 00:00:00 2001
From: Veil <BoneFeaR@proton.me>
Date: Sun, 19 May 2024 20:54:31 +0300
Subject: [PATCH] Attempt to fix mouse stutters.

---
 src/wayland_backend.cpp | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/wayland_backend.cpp b/src/wayland_backend.cpp
index ddc6c10..fffdb98 100644
--- a/src/wayland_backend.cpp
+++ b/src/wayland_backend.cpp
@@ -1927,13 +1927,13 @@ namespace gamescope
     void CWaylandBackend::Wayland_Keyboard_Enter( wl_keyboard *pKeyboard, uint32_t uSerial, wl_surface *pSurface, wl_array *pKeys )
     {
         m_bKeyboardEntered = true;
-
+
         UpdateCursor();
     }
     void CWaylandBackend::Wayland_Keyboard_Leave( wl_keyboard *pKeyboard, uint32_t uSerial, wl_surface *pSurface )
     {
         m_bKeyboardEntered = false;
-
+
         UpdateCursor();
     }

@@ -2309,8 +2309,8 @@ namespace gamescope
     void CWaylandInputThread::Wayland_Pointer_Frame( wl_pointer *pPointer )
     {
         defer( m_uAxisSource = WL_POINTER_AXIS_SOURCE_WHEEL );
-        double x = m_flScrollAccum[0];
-        double y = m_flScrollAccum[1];
+        float x = m_flScrollAccum[0];
+        float y = m_flScrollAccum[1];
         m_flScrollAccum[0] = 0.0;
         m_flScrollAccum[1] = 0.0;

@@ -2320,6 +2320,9 @@ namespace gamescope
         if ( m_uAxisSource != WL_POINTER_AXIS_SOURCE_WHEEL )
             return;

+        if ( x == 0 && y == 0 )
+        return;
+
         wlserver_lock();
         wlserver_mousewheel( x, y, ++m_uFakeTimestamp );
         wlserver_unlock();
--
2.44.0

I'm new to all this git stuff, and also not code developer, so apologize once again for wrong initial report. Hope this helps.

Does latest master fix the issue for you?

Does latest master fix the issue for you?

Confirm, problem solved.
Thanks.