Bug 485425 - Running some Wine applications through Xwayland forces constant fullscreen repaints for the rest of the session
Summary: Running some Wine applications through Xwayland forces constant fullscreen re...
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (show other bugs)
Version: 6.0.4
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-04-12 10:26 UTC by fililip
Modified: 2024-08-02 14:35 UTC (History)
9 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description fililip 2024-04-12 10:26:07 UTC
SUMMARY
After running Steam at least once on a KWin session, always-on VRR for desktop breaks entirely, forcing the full refresh rate at all times. Closing Steam, hotplugging the display and/or killing Xwayland after that don't seem to help. Fullscreen VRR for applications continues to work though.

STEPS TO REPRODUCE
1. Launch Steam

OBSERVED RESULT
Desktop VRR is effectively disabled

EXPECTED RESULT
Desktop VRR still works

SOFTWARE/OS VERSIONS
KDE Plasma Version: 6.0.3
KDE Frameworks Version: 6.0.0
Qt Version: 6.6.3
Kernel Version: 6.8.5.arch1-1 (64-bit)
Graphics Platform: Wayland
Comment 1 fililip 2024-05-03 13:03:52 UTC
I've also observed much higher CPU usage with KWin while idle.
Comment 2 Zamundaaa 2024-05-03 13:40:05 UTC
I can see VRR "breaking" when Steam is open, because it's almost constantly updating its window at the full refresh rate, but it works again once I close it or focus a different window that updates with at least 30Hz
Comment 3 fililip 2024-05-03 15:56:03 UTC
Do you exhibit the CPU usage issue though? On my system, kwin_wayland's CPU usage increases by around 8% even after Steam is terminated. Restarting KWin helps.
Comment 4 fililip 2024-05-03 16:00:55 UTC
I've just checked it with the Show Paint effect: before Steam has ever been opened during a session on an empty desktop everything is fine. After Steam has run at least once, the effect constantly triggers, even on the secondary screen.
Comment 5 fililip 2024-05-03 16:09:19 UTC
Running Steam in gamescope seems to mitigate this problem.
Comment 6 fililip 2024-05-03 16:51:55 UTC
Oh, alright, suspecting that it might be relevant, I unloaded the nvidia driver and removed the card from the PCI tree on my PC, everything is 100% fine now.

I do wonder what Steam is doing with nvidia that is causing this though. Regular PRIME offloading does not trigger this, only Steam seems to do so.

Sorry for the trouble!
Comment 7 fililip 2024-05-03 16:56:10 UTC
One final note though, to whom it may concern: on AMD/NVIDIA systems launching Steam has to be done like so:

VK_DRIVER_FILES=/usr/share/vulkan/icd.d/radeon_icd.x86_64.json steam

This also works.
Comment 8 fililip 2024-05-03 17:02:14 UTC
Ah, unfortunately not - I still had the nvidia driver unloaded. The Vulkan driver choice doesn't seem to matter.
Comment 9 fililip 2024-05-03 17:59:44 UTC
I reported the issue to the Steam issue tracker too: https://github.com/ValveSoftware/steam-for-linux/issues/10847
Comment 10 fililip 2024-05-11 15:58:48 UTC
After further testing, this can also happen when any "custom-border"/"custom-window" Xwayland app (such as FL Studio via Wine, Steam, game/mod launchers via Wine, etc.) is launched.

This in turn forces full refresh rate whole-screen on all screens (unless VRR requirements are met, see below). These full repaints are easy to visualize with the Show Paint desktop effect in KWin.

I've also tried removing the nvidia driver again, this time to no avail - FL Studio manages to trigger this behavior even on a single GPU (AMD) setup, so thankfully it seems like it's not an NVIDIA bug after all. (The Steam window itself for some reason manages to work fine on just AMD, but everything falls apart if I launch a game with "custom" windows, like OMSI 2.)

However, this is probably intended behavior anyway (the minimum refresh rate requirement for VRR is not enforced prior to launching these apps, see https://bugs.kde.org/show_bug.cgi?id=483240, starting one of them "makes it work"). I'll just stick to nested compositing, the Wine Wayland driver and gamescope wherever I can - I'd like to retain full kernel LFC if possible.

The only real issue with these repaints is the relatively "high" CPU usage they cause (compared to when they aren't present).
Comment 11 fililip 2024-05-13 21:24:37 UTC
I've found a reliable reproducer: Yume Nikki on Steam (free). After running the game, the fullscreen repaints are forced on all screens.
Comment 12 Aleksander 2024-05-13 21:25:01 UTC
This bug can be also triggered via launching "Yume Nikki" (free game) from Steam.
Comment 13 Piotr Mazur 2024-05-23 12:29:38 UTC
I am experiencing the same issues without running , just running apps that are not wayland native. The apps i have identified so far are :

* All IntelliJ related products (unless i chose JDK-23 and enable experimental wayland support - the app is no longer listed in xlsclients then, and the problem is not present)
* Smath (a mathcad-like application using mono)

I suspect that probably every app that is listed when i run the "xlsclients" command causes this problem

Like i mentioned before running these apps causes sudden slowdown of the entire desktop after some time (like a minute or two). Closing these apps does not resolve the issue. The kwin_wayland process takes around 15% of CPU time, even when showing only wallpaper, but the UI slows down considerably more than these 15% in my opinion.

When i enable the "Show FPS" desktop effect (i do not know why "show paint" effect does not work for me) the "Paint amount" rises to constant 100% and does not go down even if i close every window. 

Issuing "kwin_wayland --replace" solves the issue but also restarts every other application.
Comment 14 Piotr Mazur 2024-05-23 12:41:11 UTC
I fotgot to add that i am working on hybrid intel/nvidia graphics card but i have the nvidia device removed in udev rules (it was causing suspend/resume problems for me) so it is behaving like only the intel card is present (core i7 11gen)
Comment 15 fililip 2024-05-23 19:16:14 UTC
Changing the window open/close animation to another mode/disabling and re-enabling it (or, to be safe, disabling and re-enabling all desktop effects one by one) seems to fix this issue entirely.
Comment 16 Piotr Mazur 2024-05-23 21:37:55 UTC
I can confirm that when the issue is present and i changed the window open/close animaton to "Fade" the problem immiediately went away (i could also confirm this on the paint amount graph via the "show fps" desktop effect). So there is a way to get rid of it other than restartin kwin_wayland.
What is more - since i changed the window open/close animation i havent been able to reintroduce the problem in the same kwin session so far...
Comment 17 fililip 2024-05-24 01:39:55 UTC
Does switching back to the Glide effect bring the issue back for you? For me it does; I have to use Scale.
Comment 18 Piotr Mazur 2024-05-25 09:07:06 UTC
As for me, changing the desktop effect back to glide does not re-enable the problem, at least not immiediately. But for now i have not been able to experience the issue when the window open/close animation is set to "Fade" - this does not mean it will not happen, it may be a pure quicidence.
But i can confirm that changing the animation does fix the issue, it have used this method multiple time s when testing.
I will post my findings here if the effect also occurs when using other animations.
Comment 19 David Edmundson 2024-06-04 10:11:03 UTC
*** Bug 486535 has been marked as a duplicate of this bug. ***
Comment 20 Daniel Morgan 2024-06-04 11:42:53 UTC
(In reply to fililip from comment #17)
> Does switching back to the Glide effect bring the issue back for you? For me
> it does; I have to use Scale.

I was experiencing something very similar with kwin_wayland suddenly going up to a constant 30-40% CPU. Switching the animation from scale to fade immediately lowered CPU usage to normal. Thanks for the workaround! It's much less painful than having to log out and back every time.
Comment 21 Luca Carlon 2024-06-15 13:17:27 UTC
Hello, I was affected by this issue as well. I could reproduce it by simply using VLC or Joplin.

Approximately 10 days ago I read this discussion and I switched the effect from scale to fade. This immediately fixed the problem. Then I immediately switched back to scale and I've been testing for these 10 days. I was not able to reproduce this anymore. It seems 100% fixed so far.
Comment 22 Bug Janitor Service 2024-07-02 17:28:14 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/6035
Comment 23 Zamundaaa 2024-07-02 22:00:41 UTC
Git commit 64d70029ec74083cb6f481c84dd824a5f4f9aa18 by Xaver Hugl.
Committed on 02/07/2024 at 21:52.
Pushed by zamundaaa into branch 'master'.

plugins/glide: drop references to closed windows if they're not animated

Otherwise the window might still be referenced from the opening animation, which
can lead to the effect wrongly keeping a reference to the window and staying active.

M  +8    -12   src/plugins/glide/glide.cpp

https://invent.kde.org/plasma/kwin/-/commit/64d70029ec74083cb6f481c84dd824a5f4f9aa18
Comment 24 Bug Janitor Service 2024-07-02 22:05:42 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/6037
Comment 25 Zamundaaa 2024-07-02 22:43:40 UTC
Git commit ac217c244db439fe3058222c6555f8f3587bae7f by Xaver Hugl.
Committed on 02/07/2024 at 22:05.
Pushed by zamundaaa into branch 'Plasma/6.1'.

plugins/glide: drop references to closed windows if they're not animated

Otherwise the window might still be referenced from the opening animation, which
can lead to the effect wrongly keeping a reference to the window and staying active.


(cherry picked from commit 64d70029ec74083cb6f481c84dd824a5f4f9aa18)

Co-authored-by: Xaver Hugl <xaver.hugl@gmail.com>

M  +8    -12   src/plugins/glide/glide.cpp

https://invent.kde.org/plasma/kwin/-/commit/ac217c244db439fe3058222c6555f8f3587bae7f
Comment 26 fililip 2024-08-02 14:35:27 UTC
I re-tested and Glide works fine now in 6.1.3, thanks!