https://bugs.kde.org/show_bug.cgi?id=525465

--- Comment #7 from [email protected] ---
Created attachment 198372
  --> https://bugs.kde.org/attachment.cgi?id=198372&action=edit
Patch for the issue.

I can reproduce this on a 500 Hz screen, and I think I found the cause. Patch
attached.

System: Gentoo, KWin 6.7.6, Qt 6.11.3, Wayland, AMD RX 9070 XT (Mesa 26.2.6).
Two screens: DP-1 2560x1440 at 499.949 Hz and HDMI-A-1 1920x1080 at 100 Hz.
With default settings, wobbly feels heavy and damped on DP-1 and normal on
HDMI-A-1.

CAUSE

In src/plugins/wobblywindows/wobblywindows.cpp, prePaintWindow() splits each
frame's time into steps of at most 10 ms (integrationStep) and calls
updateWindowWobblyDatas() once per step. Most of the integration is scaled by
the step length, but two operations run once per step no matter how long the
step is:

    vel.x = acc.x * time + vel.x * m_drag;    // drag factor
    heightRingLinearMean(wwi.velocity, wwi);  // velocity smoothing

Above 100 Hz every frame is one short step, so these run once per frame: about
100 times a second at 100 Hz, but 500 times a second at 500 Hz. The motion is
damped roughly 5x harder. That matches the original report and comment #3,
where maxed stiffness and drag break windows at 60 Hz but only make them jiggle
at 500 Hz.

Between 50 and 100 Hz each frame becomes two steps (60 Hz: 10 + 6-7 ms), so 50,
60, 85 and 144 Hz all land between 100 and 170 drag applications per second.
That is probably why they looked the same in comment #1.

FIX

The attached patch (against 6.7.6) always advances the physics in whole 10 ms
steps and carries leftover time over to the next frame. To keep motion smooth
above 100 Hz, it draws a blend of the last two steps weighted by the leftover
time. updateWindowWobblyDatas() itself is unchanged.

With the patch, every refresh rate behaves the way 100 Hz does today. Two side
effects: 60 Hz gets a little bouncier than now (it currently gets about two
steps per frame), and settings extreme enough to break at 60 Hz will now also
break at 500 Hz, so the same settings give the same result everywhere.

Numbers from a simplified 1-D model of the same integration (one window corner,
default preset, drag at 2000 px/s then release, averaged over 100 release
times). These come from the model, not from measuring the real mesh:

    refresh   bounces today   bounces patched
     60 Hz         7.6             11.1
    100 Hz        11.2             11.2
    144 Hz         7.1             10.2
    240 Hz         4.3             10.8
    500 Hz         2.0             11.2

With the most wobbly preset: 38.5 bounces at 100 Hz vs 8.0 at 500 Hz today, and
38.5 at both with the patch. In the model, a steady drag at 500 Hz moves the
same distance every frame, and the grabbed corner stays within about 3 px of
the cursor at 2000 px/s.

TESTING

With the patch applied, wobbly looks the same on my 500 Hz and 100 Hz screens,
and dragging stays smooth.

The patch applies on top of the Gentoo 6.7.6 package and compiles cleanly.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to