Bug 482717

Summary: On X11 with NVIDIA GPU and KWIN_X11_FORCE_SOFTWARE_VSYNC=1 set, Plasma panel set to Adaptive Opacity causes system stutters when switching virtual desktops or dragging or maximizing windows
Product: [Plasma] kwin Reporter: rickard
Component: platform-x11-standaloneAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED DUPLICATE    
Severity: normal CC: kde, nate, rylos78, xaver.hugl
Priority: NOR Keywords: regression
Version: 6.0.2   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
See Also: https://bugs.kde.org/show_bug.cgi?id=483015
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description rickard 2024-03-07 13:58:09 UTC
SUMMARY
Kwin windows are stuttering when dragging windows or when switching desktops.

STEPS TO REPRODUCE
It does not seem to like having these set:
KWIN_X11_REFRESH_RATE=144000
KWIN_X11_NO_SYNC_TO_VBLANK=1
KWIN_X11_FORCE_SOFTWARE_VSYNC=1

More specifically KWIN_X11_FORCE_SOFTWARE_VSYNC. If i set that to 0 all seems good.
It worked fine in KDE 5.

OBSERVED RESULT
Jerky window movement and jerky Virtual desktop animation scrolling/switchimg.

EXPECTED RESULT
Smooth movement.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: CachyOS - Linux 6.7.8 - KDE 6.0.1
KDE Frameworks Version: 6.0.0
Qt Version: 6.6.2

ADDITIONAL INFORMATION
It does not always happen, the jerky virtual desktop scrolling seems to be present if there are open windows on both desktops.
Main monitor is 144hz, secondary monitor is 60hz.
Comment 1 rickard 2024-03-08 07:52:41 UTC
I am not entierly sure of the root cause here. The Software vsync might have been a false positive,
Comment 2 rickard 2024-03-11 07:43:06 UTC
I am not entierly sure of the root cause here. The Software vsync might have been a false positive,
One theory is that it might be related to when I disable my second monitor and disable composition when I start a game, then enable it again when I am done, then kwin becomes jerky. It might be related to that.
Comment 3 David Edmundson 2024-03-11 10:11:57 UTC
An X11 freeze caused by confused GPU timing was identified and fix. Please reopen if this persists after 6.0.2
Comment 4 rickard 2024-03-13 20:29:59 UTC
Ok, so I found something.
Firefox seems to cause the KWin lag. If I minimize Firefox, Kwin and switching desktops is smooth. If the Firefox window is open, it Kwin windows lags and switching desktops is choppy.

I also noticed if a Window is maximized, the same thing happens.
Comment 5 rickard 2024-03-14 07:31:53 UTC
Also having a Window closer to the bottom bar than this, causes stutter:
https://ibb.co/vdDZJvq

If I drag the window closer to the bottom, it's no longer smooth to switch desktops with the scrolling effect enabled.
Comment 6 rickard 2024-03-14 12:16:33 UTC
Sorry for spamming regarding this.
I think I found the reason now, if the bottom panel Opacity is set to "Adaptive" and a window is close enough to the panel (the drop shadow?), things begin to stutter.
If you set it to anything but "Adaptive", the stutter disappears.
Comment 7 Nate Graham 2024-03-14 18:52:05 UTC
Thanks. Is Firefox in CSD mode? If it is, can you tell it to use the system titlebar and see if that makes the issue go away?

If that works, can you see if the problem happens with any other CSD-using apps like Gedit or Blanket?
Comment 8 rickard 2024-03-14 19:59:42 UTC
It happens with any window when it's close enough to the bottom bar or is maximized. Kcalc, Kate, Konsole etc. Firefox just happend to be close enough to cause the issue, making me think it was Firefox that caused it.

So to summarize:
* Happens when any window is close enough to the bottom bar or is maximized, and the bar is set to adaptive opacity
* It even happens if a window is maximized/or close to the bottom bar on the second desktop and you are on working on desktop 1.
* Setting bar Opacity to translucent or opaque for the bar makes the issue go away.
* It's not related to Vsync at all.

Sorry for the confusion but it really made no sense, when sometimes everythiing was ok and suddenly it wasn't, then it was ok again. When it all really was how the windows were placed.
Comment 9 RyLoS 2024-03-18 19:28:17 UTC
I have a 180Hz monitor and nvidia 4070RTX, all was ultra fluid on plasma5 and getting this stuttering on plasma6. 
I've disabled panel floating mode and set it to opaque, now it is fluid. If i enable both these settings, or 1 of  them, stuttering will come.
Something need to be fixed on the new plasma6 panel.
Comment 10 Nate Graham 2024-03-18 21:54:29 UTC
Rickard, do you have an NVIDIA GPU by any chance?
Comment 11 rickard 2024-03-19 06:19:24 UTC
(In reply to Nate Graham from comment #10)
> Rickard, do you have an NVIDIA GPU by any chance?

Yes, RTX 4070.
KDE 5 did not have this issue, it's a KDE 6 thing.
Comment 12 Nate Graham 2024-03-19 13:49:59 UTC
Thanks a lot!
Comment 13 Nate Graham 2024-03-19 13:51:58 UTC
Does it also happen with the panel set to Opaque but Floating, and then does the lag happen when you perform an action that causes the panel to switch between floating and docked modes?
Comment 14 Nate Graham 2024-03-19 19:12:04 UTC
Ok, it's just Bug 475468.

*** This bug has been marked as a duplicate of bug 475468 ***