Bug 509020 - KWin Wayland insufficient performance for video playback vs. Xorg on slow Gemini Lake GPU
Summary: KWin Wayland insufficient performance for video playback vs. Xorg on slow Gem...
Status: REPORTED
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (other bugs)
Version First Reported In: 6.4.4
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-09-02 07:33 UTC by tempel.julian
Modified: 2025-09-26 16:03 UTC (History)
2 users (show)

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


Attachments
kwin performance log (328.22 KB, text/csv)
2025-09-02 15:18 UTC, tempel.julian
Details
stats with ICC correction (72.02 KB, text/csv)
2025-09-26 15:06 UTC, tempel.julian
Details

Note You need to log in before you can comment on or make changes to this bug.
Description tempel.julian 2025-09-02 07:33:53 UTC
SUMMARY

On a slow notebook with Intel Gen 9.5 Gemini Lake graphics, video playback in mpv stutters vs. Xorg uncomposited.

STEPS TO REPRODUCE
1. Use mpv (ideally recent git-master build, including recent libplacebo git-master) to play a 1080p 24fps video on a 1080p 48Hz display with this basic mpv config:

vo=gpu-next
hwdec=vaapi
gpu-api=opengl
sigmoid-upscaling=no
linear-downscaling=no
correct-downscaling=no
cscale=bilinear
scale=bilinear
dscale=bilinear
video-sync=display-resample


2. 
Judge playback result or enable mpv stats overlay with shift + i


OBSERVED RESULT
On Wayland, playback stutters and mpv reports mistimed/delayed frames in its stats.


EXPECTED RESULT
It shouldn't stutter. On uncomposited Xorg fullscreen, playback is without stutter and without tearing. Also on Windows, mpv D3D11 can play such videos with the provided config on the same device without stutter, also in windowed mode.

This used to work also on KWin Wayland, back in the Plasma 5 days with manually configured maximum compositor latency. It shouldn't be related to thermal or power throttling, as power draw during video playback is just 3.5 Watts.

Can test env vars and also patches that work against the stable KWin build, or soon 6.5 beta.


SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Arch kernel 6.16.4
KDE Plasma Version: 6.4.4
KDE Frameworks Version: 6.17.0
Qt Version: 6.9.2
Comment 1 Zamundaaa 2025-09-02 11:38:47 UTC
Please set https://invent.kde.org/plasma/kwin/-/wikis/Environment-Variables#kwin_log_performance_data and record some performance data about KWin's presentation while playing a video that stutters.
Comment 2 tempel.julian 2025-09-02 15:18:45 UTC
Created attachment 184650 [details]
kwin performance log
Comment 3 tempel.julian 2025-09-02 15:25:01 UTC
Hope this helps. I figured it might make sense to test with 59.94Hz/fps video instead, as this triggers more mistimed frames. I also checked again for it to play smoothly on xorg, which it does (with xf86-video-intel DDX at least). mpv stats also don't recognize every single stutter occurrence I can discern visually.
Comment 4 Bug Janitor Service 2025-09-17 03:48:30 UTC
๐Ÿ›๐Ÿงน โš ๏ธ This bug has been in NEEDSINFO status with no change for at least 15 days. Please provide the requested information, then set the bug status to REPORTED. If there is no change for at least 30 days, it will be automatically closed as RESOLVED WORKSFORME.

For more information about our bug triaging procedures, please read https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging.

Thank you for helping us make KDE software even better for everyone!
Comment 5 tempel.julian 2025-09-26 15:06:09 UTC
Not noticing an improvement with 6.4.90. Attaching one more performance log. This time with ICC profile calibration on, which makes the issue more distinct, despite the GPU still not being maxed out and SoC power draw well below its 6W limit.
Comment 6 tempel.julian 2025-09-26 15:06:49 UTC
Created attachment 185294 [details]
stats with ICC correction
Comment 7 Zamundaaa 2025-09-26 15:38:35 UTC
The GPU seems to be doing fine, the majority of dropped frames comes from the commit thread waking up too late (or the atomic commit taking too long):
- total of 942 frames
- dropped 59 frames (6.3%)
    - 52 because of too late commits (5.5%)
    - 4 because of late rendering start (0.42%)
    - 3 because of render times (0.32%)
- 8698us average render time
- 8946us median render time

The max render time is also not exactly great though, at 32ms.

I'm not entirely sure how to attempt to rectify this tbh. Maybe the safety margin calculation needs to be even more conservative... but on your hardware, it's already never even going below 2.5ms.
Still, you can test with setting https://invent.kde.org/plasma/kwin/-/wikis/Environment-Variables#kwin_drm_override_safety_margin to some higher value. 4000 could maybe work.
Comment 8 tempel.julian 2025-09-26 16:03:34 UTC
Setting KWIN_DRM_OVERRIDE_SAFETY_MARGIN=4000 indeed does massively improve the situation.