Bug 454098

Summary: Choppy video playback on Wayland
Product: [Plasma] kwin Reporter: Patrick Silva <bugseforuns>
Component: performanceAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: mirh, nate, noeerover, postix, xaver.hugl
Priority: NOR    
Version: 5.24.90   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Patrick Silva 2022-05-20 17:06:30 UTC
SUMMARY
I'm not sure if this issue is related to kwin or another thing on my system.
Video playback is choppy like the gear animation of glxgears observed in the following video.
https://youtu.be/2JvS5PtY2MQ
On X11 playback is better but not perfect despite the framerate is 59-60 fps there.


STEPS TO REPRODUCE
1. use Wayland session
2. play a video with VLC or mpv player
3. 

OBSERVED RESULT
choppy video playback

EXPECTED RESULT
fluid video playback

SOFTWARE/OS VERSIONS
Operating System: Arch Linux
KDE Plasma Version: 5.24.90
KDE Frameworks Version: 5.94.0
Qt Version: 5.15.4
Kernel Version: 5.17.9-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 2 × Intel® Celeron® CPU G1820 @ 2.70GHz
Memory: 7,6 GiB of RAM
Graphics Processor: Mesa Intel® HD Graphics
Comment 1 Vlad Zahorodnii 2022-05-24 08:48:14 UTC
Is this regression compared to 5.24?
Comment 2 Patrick Silva 2022-05-24 10:08:30 UTC
No. It's an old issue.
Comment 3 Vlad Zahorodnii 2022-05-25 09:24:35 UTC
Huh, I see. Regardless, it's odd that even not resource demanding apps such as glxgears stutter. Does changing latency policy make things any better?
Comment 4 Patrick Silva 2022-05-25 13:17:55 UTC
(In reply to Vlad Zahorodnii from comment #3)
> Huh, I see. Regardless, it's odd that even not resource demanding apps such
> as glxgears stutter. Does changing latency policy make things any better?

No.
Comment 5 Patrick Silva 2022-08-11 15:17:59 UTC
I can't reproduce the stuttering with glxgears using another user account. Video playback is also better, but it is still stuttering a bit with certain videos even on X11.

Operating System: Arch Linux
KDE Plasma Version: 5.25.4
KDE Frameworks Version: 5.96.0
Qt Version: 5.15.5
Kernel Version: 5.19.0-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 2 × Intel® Celeron® CPU G1820 @ 2.70GHz
Memory: 7,6 GiB of RAM
Graphics Processor: Mesa Intel® HD Graphics
Comment 6 Mike 2022-08-17 14:41:57 UTC
I can repro this but only if I set scaling for my screen to something > 100%, like say 120%.  Playback of regular HD videos stutters greatly, MPV reports many dropped frames and the new FPS tool shows 30fps instead of 60.

My monitor is a TCL 43" HDR TV, 3840x2160@60Hz.  Running wayland session, kwin from git master, MPV from git master as well.

MPV reports (shift+i) really weird scaled resolution, like 6104x2880, not sure where that comes from.

When I switch back to 100% scaling, all works as expected and the FPS tool show 60fps as well as MPV.
Comment 7 Mike 2022-08-17 14:45:04 UTC
I should add, using AmdGPU driver, RX560, I've tried with mpv --no-config and mpv with my normal config, which is vulkan and wayland:

[code]
...
gpu-api=vulkan
gpu-context=waylandvk
vo=gpu-next
ao=pipewire
vulkan-async-compute=yes
af=lavfi=[loudnorm=I=-16:TP=-3:LRA=4]
audio-channels=2
hwdec=auto-copy
...
[/code]
Comment 8 Patrick Silva 2022-08-17 15:07:41 UTC
bug 449951 is related to display scale.
Comment 9 mirh 2024-02-17 15:56:39 UTC
Putting aside that in no way, shape or connotation in the dictionary glxgears could be considered as "video playback", bug 449951 was supposedly addressed in the KDE 6 beta.
Comment 10 Mike 2024-02-17 18:32:59 UTC
Yep, appears fixed in 5.27 (tumbleweed) and for sure is fixed in 6.x.
Comment 11 Nate Graham 2024-02-17 20:37:55 UTC
Great!
Comment 12 Patrick Silva 2024-02-18 20:44:49 UTC
This bug persists on my system. There is a considerable lag when the credits slide in the end of a movie, for example.
On X11, the lag is less noticeable, but it is present too. I can reproduce with a new user account too. I can reproduce with VLC player, mpv, mplayer and gstreamer-based players like Totem and Glide.

va-api is working:

$ vainfo
Trying display: wayland
vainfo: VA-API version: 1.20 (libva 2.20.1)
vainfo: Driver version: Intel i965 driver for Intel(R) Haswell Desktop - 2.4.1
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Simple            : VAEntrypointEncSlice
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileH264MultiviewHigh      : VAEntrypointVLD
      VAProfileH264MultiviewHigh      : VAEntrypointEncSlice
      VAProfileH264StereoHigh         : VAEntrypointVLD
      VAProfileH264StereoHigh         : VAEntrypointEncSlice
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileNone                   : VAEntrypointVideoProc
      VAProfileJPEGBaseline           : VAEntrypointVLD

I have Windows 10 installed on the same computer and the mentioned lag does not exist when playing the same videos on it.

Operating System: Arch Linux 
KDE Plasma Version: 5.93.0
KDE Frameworks Version: 5.249.0
Qt Version: 6.7.0
Kernel Version: 6.7.5-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 4 × Intel® Core™ i5-4670K CPU @ 3.40GHz
Memory: 15,5 GiB of RAM
Graphics Processor: Mesa Intel® HD Graphics 4600
Manufacturer: Gigabyte Technology Co., Ltd.
Product Name: B85M-D3PH
Comment 13 Zamundaaa 2024-05-24 15:51:01 UTC
Git commit 40a9f08dd34948264ba5b533da5373a0a51ad3f1 by Xaver Hugl.
Committed on 24/05/2024 at 15:32.
Pushed by zamundaaa into branch 'master'.

backends/drm: allow up to two composited frames to be pending at the same time

This should improve responsiveness on setups where rendering each frame takes longer
than the refresh cycle of the display.
Related: bug 452119

M  +4    -0    src/backends/drm/drm_output.cpp

https://invent.kde.org/plasma/kwin/-/commit/40a9f08dd34948264ba5b533da5373a0a51ad3f1
Comment 14 Zamundaaa 2024-05-24 15:59:58 UTC
Git commit 192232e8d1736307f93792ea77de80e61f746bd3 by Xaver Hugl.
Committed on 24/05/2024 at 15:59.
Pushed by zamundaaa into branch 'Plasma/6.1'.

backends/drm: allow up to two composited frames to be pending at the same time

This should improve responsiveness on setups where rendering each frame takes longer
than the refresh cycle of the display.
Related: bug 452119

M  +4    -0    src/backends/drm/drm_output.cpp

https://invent.kde.org/plasma/kwin/-/commit/192232e8d1736307f93792ea77de80e61f746bd3
Comment 15 Zamundaaa 2024-05-28 17:29:29 UTC
Beyond keeping compositing responsive, we can't fix video playback issues. If they're still visible with 6.1, please check again if the problem is actually triggered by compositing, or if it's the video player not keeping up with the screen