Bug 495400

Summary: Desktop session slows to a crawl on multi-monitor setups while running VR
Product: [Plasma] kwin Reporter: Daniel Well <dantheman22505>
Component: performanceAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: 0xdeadcade, foley2431, jared, nate, xaver.hugl
Priority: NOR    
Version: 6.2.2   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In: 6.2.4
Sentry Crash Report:
Attachments: Bisect log performed on 2024-10-30T18:00:00-05:00

Description Daniel Well 2024-10-26 21:38:15 UTC
So I have 2 1080p displays, a 1440p 360hz monitor, and a Valve Index hooked up to my system. I had no trouble driving all of these at once since about 6.2.1, however with a recent update, once I start up either Monado or SteamVR, it brings my session down to its knees. My cursor remains active, but windows will take seconds to refresh or move around.

STEPS TO REPRODUCE
1. Start Plasma Wayland
2. Have more than one monitor plugged in and a wired HMD
3. Startup SteamVR or Monado

OBSERVED RESULT
VR view remains smooth while desktop session is incredibly sluggish

EXPECTED RESULT
VR view and desktop view remain performant

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: EndeavourOS
KDE Plasma Version: 6.2.2-1
KDE Frameworks Version: 
Qt Version: 6.8.0

ADDITIONAL INFORMATION

I tested on my spare Quest 2 with WiVRn and ALVR, which seemed to work fine. I also unplugged 2 of my monitors to find the session was smooth again, so the problem seems to be exclusive to wired HMDs on multi-monitor setups
Comment 1 Zamundaaa 2024-10-28 19:24:10 UTC
I don't have a second monitor connected at the moment, but with a single screen I can see performance issues while SteamVR is running as well. Seems to be mostly, but not exclusively when I move the cursor.
Comment 2 libjared 2024-10-30 19:56:41 UTC
I can also reproduce this slowdown consistently.
I currently have 1 monitor connected. It can do 144Hz, but I set it to 60Hz in systemsettings. The desktop runs at 60 FPS normally.
I also have a Valve Index connected. Once I start VR (regardless of whether monado acquires the display lease via wayland or xlib), and box highlight the desktop to force repainting, the desktop FPS varies wildly anywhere between 30 and 60 FPS.
I have the "Show FPS" desktop effect enabled to verify this.

While it is true that having multiple monitors all at high refresh rates makes the slowdown much, much worse, it would seem this issue is not strictly exclusive to high-refresh-rate monitors nor multiple monitors.
I can also reproduce this issue regardless of which kernel I'm using; have tested with LTS (6.6.58-1) and stable (6.11.5.arch1-1) kernels.
I do not see any significant or even measurable uptick in CPU nor GPU usage.
I notice that when running the desktop session with X11 instead, no slowdown occurs.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Arch Linux
KDE Plasma Version: 6.2.2-1
KDE Frameworks Version: 6.7.0-1
Qt Version: 6.8.0-1
Wayland desktop, with xwayland also running
GPU: AMD 5700 XTX, amdgpu driver
Comment 3 libjared 2024-10-30 23:25:27 UTC
Created attachment 175383 [details]
Bisect log performed on 2024-10-30T18:00:00-05:00

AFAICT this is a regression in behavior between KWin v6.2.1.1 and v6.2.2.
I added a bisect log.
first bad commit: [b7dbb2845bfe454efe75be8f7f1b1631f50be174] backends/drm: leave all outputs disabled by default, including VR headsets
Comment 4 libjared 2024-11-09 20:50:53 UTC
This issue is still present in kwin 6.2.3.
Comment 5 Zamundaaa 2024-11-10 20:45:47 UTC
*** Bug 496011 has been marked as a duplicate of this bug. ***
Comment 6 Bug Janitor Service 2024-11-10 20:49:27 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/6756
Comment 7 0xdeadcade 2024-11-11 00:59:44 UTC
MR 6756 fixes the issue on my end (Monado, Valve Index, single monitor, amdgpu)
Comment 8 Vlad Zahorodnii 2024-11-14 12:29:27 UTC
Git commit f4d24cce43c59fc3fd57a34be8d43fe3033dd04f by Vlad Zahorodnii, on behalf of Xaver Hugl.
Committed on 14/11/2024 at 12:03.
Pushed by vladz into branch 'master'.

backends/drm: fix DrmGpu::needsModeset check with leased outputs

It just wrongly triggers modesets that will then (at least try to) ignore the
leased-away resources anyways, and regress performance on the other displays.

M  +5    -3    src/backends/drm/drm_gpu.cpp

https://invent.kde.org/plasma/kwin/-/commit/f4d24cce43c59fc3fd57a34be8d43fe3033dd04f
Comment 9 Zamundaaa 2024-11-14 13:27:07 UTC
Git commit 2d543f4a790b93c465caf2eb3504cb2915477924 by Xaver Hugl.
Committed on 14/11/2024 at 12:46.
Pushed by zamundaaa into branch 'Plasma/6.2'.

backends/drm: fix DrmGpu::needsModeset check with leased outputs

It just wrongly triggers modesets that will then (at least try to) ignore the
leased-away resources anyways, and regress performance on the other displays.


(cherry picked from commit f4d24cce43c59fc3fd57a34be8d43fe3033dd04f)

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

M  +5    -3    src/backends/drm/drm_gpu.cpp

https://invent.kde.org/plasma/kwin/-/commit/2d543f4a790b93c465caf2eb3504cb2915477924