Bug 452281

Summary: Application Windows moving randomly from screen to screen and sometimes to other desktops
Product: [Plasma] kwin Reporter: Paul Hands <jphands>
Component: multi-screenAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: nate, xaver.hugl
Priority: NOR    
Version First Reported In: 5.24.4   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Paul Hands 2022-04-05 03:18:25 UTC
SUMMARY

Since a major KDE upgrade a few weeks ago, application windows on my 3 monitor, 4 desktop Plasma machine have been moving at random times to another screen on the same desktop, or less often, to another desktop on the cube.

At first I thought it was to do with screen saver cutting in, but it happens randomly before that happens.

I have 3 4k screens with the leftmost being primary.  After a short (<1 hour) period all app windows in screen 3 suddenly move, usually to the middle screen of the 3, but not always.  Sometimes the windows move to the primary, leftmost screen, and sometimes they have moved to desktop 4.  I have not seen a move desktops 2 or 3.

OpenSuSE Tumbleweed 20220403 (but has been around for a few upgrades).

KDE Plasma Version: 5.24.4
KDE Frameworks Version: 5.92.0
Qt Version: 5.15.2
Kernel Version: 5.16.15-1-default (64-bit)
Graphics Platform: X11
Processors: 24 × AMD Ryzen 9 3900X 12-Core Processor
Memory: 46.9 GiB of RAM
Graphics Processor: AMD DIMGREY_CAVEFISH

ADDITIONAL INFORMATION
The problem makes one of the 3 screens quite unusable.

Problem has persisted across a few SuSE (and at least one kernel) and Plasma updates.  Please let me know if I can help with deeper debugging info - installing debug symbols, etc. 

I did discuss this on the KDE Community Forums, and got an answer that the new release had a lot of new code, but it's been a while.
Comment 1 Nate Graham 2022-04-06 17:47:12 UTC
Is it possible that the signal for one or more of your screens is cutting out, causing the monitor to appear off for a moment? When that happens, KWin re-arranges windows, and there is a probably a bug in that behavior that is being triggered.
Comment 2 Paul Hands 2022-04-06 17:57:29 UTC
(In reply to Nate Graham from comment #1)
> Is it possible that the signal for one or more of your screens is cutting
> out, causing the monitor to appear off for a moment? When that happens, KWin
> re-arranges windows, and there is a probably a bug in that behavior that is
> being triggered.

Hi Nate, and thanks for taking the time to reply.

That's an interesting idea and question!  It's a possibility, as the primary screen sometimes blanks for a moment, but I haven't seen that trigger any rearrangement.   Is there any experiment you think I can do?  Some debug or log setting?

Paul
Comment 3 Nate Graham 2022-04-06 18:45:53 UTC
> the primary screen sometimes blanks for a moment
That seems related indeed.

One last question, before I let the KWin developers take over: does this affect *all* windows, or just certain KDE app windows (e.g. Dolphin, Okular, Gwenview, System Settings, and Discover)?
Comment 4 Paul Hands 2022-04-06 21:06:12 UTC
(In reply to Nate Graham from comment #3)
> > the primary screen sometimes blanks for a moment
> That seems related indeed.
> 
> One last question, before I let the KWin developers take over: does this
> affect *all* windows, or just certain KDE app windows (e.g. Dolphin, Okular,
> Gwenview, System Settings, and Discover)?

Thanks again. Nate.

I did an experiment.  My initial suspicion about the screen energy saver seems at least partially correct.  The timeout was set for 15 minutes, and sure enough, after that time, the screens all went dark....but only for about 15 seconds, when they switched back on without any input events.  On coming back on, all the app windows in the rightmost screen had moved to the middle screen, leaving screen 3 empty.   During the "off" period, I could see the monitors polling their various inputs for a signal, and I wonder if that is causing some weird interaction with the GPU.

I then cut the energy saver period down to 3 minutes, and the situation is totally repeatable.  Switching off the energy saver removes the issue.  I then let the Screen-locking feature in the Workspace Behavior (I use a bunch of Desktop Effects; not sure if that's relevant) section of System Settings cut in, and after getting back in, no windows had moved.

So....I think I can say....

1. The energy saver cut-in is triggering the app window movement to screen 2.  Or the wrongful switching back on is....
2. The energy saver isn't working correctly, as the monitors come back on after about 15 seconds, even with no mouse or keyboard events.
3. The phenomenon isn't application window type specific - it applies to all windows in screen 3....I tested a few: Signal, Konsole, Firefox, Discover, Opera and System Settings.
4. The issue isn't associated with the Screen Lock functionality, just the energy saver.
5. Turning off energy saving hides the issue, but that's not environmentally great.

As before, if I can run any more tests or provide any logs, etc, just let me know.
Comment 5 Nate Graham 2022-04-07 15:43:12 UTC
OK, thanks for the information! I think we have enough information to implicate KWin here, rather than than the X11-specific feature to remember (some) KDE app windows' positions. Seems like the behavior to move windows when screens are connected and disconnected may be getting inappropriately activated and/or doing something buggy in response to screens being inappropriately temporarily turned off during screen locking.

I'll let the KWin developers take it from here.
Comment 6 Zamundaaa 2024-05-24 14:16:06 UTC
KWin now has code to move windows back to where they should be, so this should no longer be a problem
Comment 7 Paul Hands 2024-05-24 21:04:08 UTC
Thanks, Zamundaaa.  What version of kwin should I look out for?
Comment 8 Zamundaaa 2024-05-24 21:09:26 UTC
5.27 had some of it, but sort of incomplete and a bit buggy. It should be fully functional and auto-tested in 6.0.5
Comment 9 Paul Hands 2024-05-24 21:22:52 UTC
(In reply to Zamundaaa from comment #8)
> 5.27 had some of it, but sort of incomplete and a bit buggy. It should be
> fully functional and auto-tested in 6.0.5

Thanks again.  I'm on 6.04, so I'll await 6.,05, and let you know if it's fixed for me.