Bug 464217 - Recorded windows should get frame callbacks even while not visible
Summary: Recorded windows should get frame callbacks even while not visible
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (other bugs)
Version First Reported In: unspecified
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
: 463374 (view as bug list)
Depends on:
Blocks:
 
Reported: 2023-01-12 22:25 UTC by RogueRen
Modified: 2023-01-18 12:24 UTC (History)
4 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description RogueRen 2023-01-12 22:25:09 UTC
SUMMARY
XWayland applications do not continue to run correctly when on a virtual desktop or activity that the Xwayland applocation isn't on. (Massively reduced framerate, choppy audio)
***
NOTE: If you are reporting a crash, please try to attach a backtrace with debug symbols.
See https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***


STEPS TO REPRODUCE
1. Launch a game thay uses Xwayland (i.e. mGBA emulator)
2. Swap to a different virtual desktop

OBSERVED RESULT
Hear audio slow to a choppy mess until you swap back to the same desktop as the game

EXPECTED RESULT
Game continues to run as if it is still on the same desktop with no reduction in fps/audio

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Pop!_OS 22.04 LTS
(available in About System)
KDE Plasma Version: 5.25
KDE Frameworks Version: TBD
Qt Version: TBD

ADDITIONAL INFORMATION
Running Wayland on an AMD RX 6650 XT GPU
Will be coming back to add Framework and Qt version numbers
Comment 1 Nicolas Fella 2023-01-12 22:53:24 UTC
There's similar reports for Gnome: https://bugs.launchpad.net/ubuntu/+source/xwayland/+bug/1906792, https://gitlab.gnome.org/GNOME/mutter/-/issues/1563, which suggests that this is an issue of XWayland
Comment 2 RogueRen 2023-01-12 22:57:11 UTC
(In reply to Nicolas Fella from comment #1)
> There's similar reports for Gnome:
> https://bugs.launchpad.net/ubuntu/+source/xwayland/+bug/1906792,
> https://gitlab.gnome.org/GNOME/mutter/-/issues/1563, which suggests that
> this is an issue of XWayland

Both of those mention having 2 xwayland windows open, I only have 1 open. It could be the same thing, but I haven't had it happen on Gnome with only 1 window open
Comment 3 Zamundaaa 2023-01-13 15:17:49 UTC
Xwayland reduces the refresh rate of a window to 1Hz once it no longer gets frame callbacks, which KWin stops sending if a window is minimized or on another virtual desktop.
If an app misbehaves with that, there's nothing we can do. You might want to report this to https://gitlab.freedesktop.org/xorg/xserver/-/issues though, maybe something can be done on the Xwayland side
Comment 4 RogueRen 2023-01-13 16:47:15 UTC
(In reply to Zamundaaa from comment #3)
> Xwayland reduces the refresh rate of a window to 1Hz once it no longer gets
> frame callbacks, which KWin stops sending if a window is minimized or on
> another virtual desktop.
> If an app misbehaves with that, there's nothing we can do. You might want to
> report this to https://gitlab.freedesktop.org/xorg/xserver/-/issues though,
> maybe something can be done on the Xwayland side

Upon checking that page, they seem tonhave been made aware of this 2 years ago and have ignored it as intentional behavior. Thanks, I'll see if I can get anyone over there to look at it again.
Comment 5 RogueRen 2023-01-13 18:24:05 UTC
(In reply to Zamundaaa from comment #3)
> Xwayland reduces the refresh rate of a window to 1Hz once it no longer gets
> frame callbacks, which KWin stops sending if a window is minimized or on
> another virtual desktop.
> If an app misbehaves with that, there's nothing we can do. You might want to
> report this to https://gitlab.freedesktop.org/xorg/xserver/-/issues though,
> maybe something can be done on the Xwayland side

Upon checking that page, they seem tonhave been made aware of this 2 years ago and have ignored it as intentional behavior. Thanks, I'll see if I can get anyone over there to look at it again.(In reply to Zamundaaa from comment #3)
> Xwayland reduces the refresh rate of a window to 1Hz once it no longer gets
> frame callbacks, which KWin stops sending if a window is minimized or on
> another virtual desktop.
> If an app misbehaves with that, there's nothing we can do. You might want to
> report this to https://gitlab.freedesktop.org/xorg/xserver/-/issues though,
> maybe something can be done on the Xwayland side

According to Xwayland people it's the Wayland compositor's fault, not Xwayland
https://gitlab.freedesktop.org/xorg/xserver/-/issues/1118#note_1722316
Comment 6 Zamundaaa 2023-01-14 01:58:14 UTC
If I read the link correctly, your specific case is that you need the window to not slow down while recording it, right?
That would be a bit of a special case that we can and should fix.
Comment 7 RogueRen 2023-01-14 04:20:50 UTC
(In reply to Zamundaaa from comment #6)
> If I read the link correctly, your specific case is that you need the window
> to not slow down while recording it, right?
> That would be a bit of a special case that we can and should fix.

Yes, and in addition there's something with kwin sometimes not sending frames to OBS (or maybe pipewire since that's what's use for sending video) with window captures of xwayland windows. Not sure if that's related or a separate issue but I figure it's worth mentioning.
Comment 8 Zamundaaa 2023-01-17 15:01:33 UTC
*** Bug 463374 has been marked as a duplicate of this bug. ***
Comment 9 Vlad Zahorodnii 2023-01-18 11:16:51 UTC
Git commit b89009f9e18af6ce9331487f7a6a7308c5e2be26 by Vlad Zahorodnii, on behalf of Xaver Hugl.
Committed on 18/01/2023 at 08:01.
Pushed by vladz into branch 'master'.

plugins/screencast: send frame callbacks if the window is otherwise invisible

If we don't send frame callbacks, the application might stop rendering or
throttle to single digit fps.

M  +1    -1    src/plugins/screencast/windowscreencastsource.cpp
M  +3    -2    src/plugins/screencast/windowscreencastsource.h
M  +40   -0    src/window.cpp
M  +19   -0    src/window.h

https://invent.kde.org/plasma/kwin/commit/b89009f9e18af6ce9331487f7a6a7308c5e2be26