Bug 470329 - Monitor power on / off results in stolen input and broken xwayland clients
Summary: Monitor power on / off results in stolen input and broken xwayland clients
Status: REPORTED
Alias: None
Product: kwin
Classification: Plasma
Component: multi-screen (show other bugs)
Version: 5.27.2
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords: multiscreen, wayland
Depends on:
Blocks:
 
Reported: 2023-05-27 11:12 UTC by Andrei Amuraritei
Modified: 2023-06-06 16:29 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrei Amuraritei 2023-05-27 11:12:54 UTC
SUMMARY
***
CPU: AMD 5950x
GPU: 0a:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Navi 31 [Radeon RX 7900 XT/7900 XTX] [1002:744c] (rev c8) Sapphire Nitro+
System Memory: 32GB DDR4
Display(s): DELL 27" 2560x1440@144 DisplayPort and SAMSUNG 75" 3840x2160@120 HDMI

Debian 12 Bookworm
Kernel: 6.3.3-x64v3-xanmod1 #0~20230517.05b3a98
***

STEPS TO REPRODUCE
1.  Have the HDMI display screen powered off while Displayport screen is Primary and active, powered on
2. Start Steam, start a game from library via Proton (Wine)
3. Play the game normally
4. Turn on the HDMI display from remote, the whole desktop flickers, the game client window moves and freezes (depending on game) and loses input.
5. Need to stop (terminate) the frozen game window client and restart

OBSERVED RESULT
First, desktop flickers and all windows (that maybe are on powered off screen) move to primary screen and then back to screen that was powered on.
It seems some xwayland clients are broken, getting freezed and losing focus.
Focus is lost from active window (screen).

EXPECTED RESULT
Screen powers on and displays the configured desktop for it
No flickering or minimal flickering, no Window moving from active screen to the other and back.
No changing focus from screen to screen.

SOFTWARE/OS VERSIONS
Operating System: Debian GNU/Linux 12
KDE Plasma Version: 5.27.2
KDE Frameworks Version: 5.103.0
Qt Version: 5.15.8
Kernel Version: 6.3.3-x64v3-xanmod1 (64-bit)
Graphics Platform: Wayland
Processors: 32 × AMD Ryzen 9 5950X 16-Core Processor
Memory: 31,3 GiB of RAM
Graphics Processor: AMD Radeon Graphics
Manufacturer: ASUS

ADDITIONAL INFORMATION
Testing on Windows I see a short flicker when trying the same operation of turning a screen on / off but the windows do not move.
Testing on Linux, this happens, have observed this desktop flicker when turning a display on and the current windows getting moved from screen to screen also while trying Fedora 38 KDE Live 1.6.iso.

Not sure if this strictly a KDE Kwin/Plasma issue, I think it's maybe amd/drm something, will raise another issue there.
Comment 1 Andrei Amuraritei 2023-05-27 12:45:14 UTC
I have tested this further with:

Sway wayland, the same game (ex, FFXIV with Wine via Lutris) does not die in that session when turning on the HDMI screen.
Plasma X11, the same game (ex, FFXIV with Wine via Lutris), does not die but the window gets switched (moved?) from fullscreen , where the taskbar is visible at the top and focus on the game stays.

Also tested with an older kernel from Debian, 6.1.0-3-amd64, so maybe not drm/amd related.
Comment 2 Andrei Amuraritei 2023-05-27 13:10:20 UTC
Also tested with Gnome Wayland, shell version 43.4 and the same game (ex, FFXIV with Wine via Lutris), closes like on the KDE Wayland session.

I have also tested running a native Linux version of a game, and it does not close however when the other screen is powered on, desktop flickers and the game window switches from borderless/fullscreen to where taskbar is visible (position top) and game loses focus (input).
Comment 3 Nate Graham 2023-05-31 19:42:15 UTC
> no Window moving from active screen to the other and back.
> No changing focus from screen to screen.
Generally this is caused by X11 or XWayland-using apps that inappropriately try to track the active screen. When a new screen is plugged in, the active screen can change, which can trigger faulty logic in these apps. It's especially common in games, unfortunately.
Comment 4 Andrei Amuraritei 2023-06-02 15:10:17 UTC
Hi Nate, thanks for your input.

The most annoying issue was having the xwayland client getting frozen or dissapearing (in this case a game window). Then focus/input being stolen from the active window.

Since opening this report, I have also done more testing and I do not have the issue of the xwayland window dissapearing. My main guess is that I have cleared my ~/.local/share/kscreen folder and this fixed the issue.

While testing support of amdgpu for the 7900XTX GPU, I guess there was some kscreen configs present that broke xwayland (I have several issues opened on the amdgpu gitlab and currently for Debian 12, support is pretty bad for 7900XTX GPU with current 6.1 LTS kernel).

So, good news, xwayland client does not die anymore, however, when a xwayland client window is active and I power on my SAMSUNG HDMI screen, the input or focus goes away from the active window. I think this is still relevant for this bug report.
I also observe that each time I turn off and on the SAMSUNG screen, xrandr shows me a different XWAYLAND ID, example from XWAYLAND1 to XWAYLAND2 etc. Why does this happen (assuming the screens remain the same, so the active kscreen config does not change)?
Comment 5 Nate Graham 2023-06-02 17:39:15 UTC
Ahhhhhh then this is Bug 466149.

*** This bug has been marked as a duplicate of bug 466149 ***
Comment 6 Andrei Amuraritei 2023-06-02 21:51:35 UTC
Forgot to mention that Plasma was updated to 5.27.5 in the mean time.

Nate, could you detail why you think this is a duplicate of 466149? I am not following that. Or, in my case, for the Wayland session, the primary screen remains primary (DELL) and is always XWAYLAND0 and it is currently set at pos 0x0. Then the other screen is SAMSUNG, at pos +2560 and remains there.

The primary thing does not change as far as I can see, xrandr always says primary is XWAYLAND0 (maybe because it should be fixed with 5.27.5). However as noted, the SAMSUNG screen gets a new XWAYLAND ID every time I power it on.
Comment 7 Nate Graham 2023-06-06 16:29:49 UTC
Ok, maybe it's not that, then.