Bug 453554

Summary: turning one monitor off kills the panel configuration of the second monitor
Product: [Plasma] plasmashell Reporter: Kai Krakow <kai>
Component: generic-multiscreenAssignee: Plasma Bugs List <plasma-bugs>
Severity: normal CC: aleixpol, gronslet, nate, notmart
Priority: NOR    
Version: 5.24.5   
Target Milestone: 1.0   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: configuration completely doesn't match the output

Description Kai Krakow 2022-05-08 20:52:13 UTC

Monitor setup (xrandr dump at the end):

Left main monitor: 4k displayport
* top plasma panel with activity switcher, global menu, date and time, systray
* bottom plasma panel with launch menu, icon window list, desktop switcher

Right small monitor: full HD HDMI connected via DP
* top plasma panel with window list, time, bluetooth applet, volume applet

TV: 4k, HDMI
* clone of left monitor (for couch gaming)

NVIDIA GTX 1660 Ti 6GB with Xorg

Whenever I turn off my main monitor, all its panels move over to the right monitor. The same happens if the TV turns off or goes to sleep. Sometimes (probably before 5.24.5), I can see two overlapping panels at the top (my main top panel plus the simple side monitor panel) but since 5.24.5 the panel moves consistently, replacing the configuration of the right monitor.

This was fine most of the time before 5.24.5 and consistently fine before 5.24.4: The panels were restored when I turned the main monitor back on, only messing up if plasma crashed or shut down before turning the monitor back on.

But now it consistently throws away the plasma configuration of the right monitor: After turning the main monitor back on, I'm left with an empty default desktop on the right monitor, no custom background image, no panels, but all open windows moved to this monitor.

Looking at the output of `qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.dumpCurrentLayoutJS` I can see that each incident adds another panel configuration in `layout.panels` but I have no way of getting it back.

`plasmashellrc` has these lines:

It also had `2=:0.0` followed by `3=DP-1` but I removed that out of desperation. It wasn't present in older backups of my system. It didn't change anything about the behavior, tho.

1. Use a setup like I described above
2. Turn the displayport monitor off which seems to disconnect it from the system (my DP monitor and HDMI TV do that when turning them off, my HDMI monitor doesn't do it and seemingly stays connected/detected)
3. Observe the panels move over to the second screen
4. Turn first monitor back on

After step 4, the panels move back to the monitor just turned back on but step 2/3 seem to have displaced the panel/desktop configuration of the second monitor, and after step 4, plasma will replace it with an empty default configuration.

The panels should be properly restored to their respective original monitors. I guess it's fine and wanted that disconnecting the primary monitor would move panels over to remaining monitors, e.g. for laptop usage. But when I restore the original monitor connection for which I configured the panels, that configuration should be restored, or at least I should have an easy way to choose which panel configuration I want to restore. But in my case, it's gone for good although it still seems to live in the qdbus layout dump (and it's piling up there because I need to recreate the layout multiple times per day).

I think Plasma should store and apply layouts like this:

Store a layout of each monitor, also store a flag if this was made on the primary monitor. If the current monitor is the primary monitor, use the panel layout of the original primary monitor. Otherwise fall back to the layout originally defined for this monitor. Do not remove but swap layouts when the primary layout flag is involved. Move the primary layout flag only when the layout is actively edited.

Operating System: Gentoo Linux
KDE Plasma Version: 5.24.5
KDE Frameworks Version: 5.93.0
Qt Version: 5.15.3
Kernel Version: 5.15.37-gentoo (64-bit)
Graphics Platform: X11
Processors: 20 × 12th Gen Intel® Core™ i7-12700K
Memory: 31.1 GiB of RAM
Graphics Processor: NVIDIA GeForce GTX 1660 Ti/PCIe/SSE2


This behavior was triggered very rarely before 5.24.4, easily triggered with 5.24.4, and consistently triggers with 5.24.5. Given that history of behavior, it's probably some race condition and is not intentional.

My clone monitor layout may play a role in this because I found in older versions some months back, that sometimes plasma panels would be defined for my TV instead of my main monitor (when I disabled the TV, all panels were gone).

I had situations when the panels actually moved to a "third" monitor right of my second monitor. When I used nvidia-settings to place the TV at the right of my second monitor, I would suddenly see panels there. But I saw that only once or twice in the last few weeks, and I could not see it this time.

# xrandr | grep connected
DP-0 disconnected (normal left inverted right x axis y axis)
DP-1 connected 1920x1080+3840+540 (normal left inverted right x axis y axis) 160mm x 90mm
DP-2 disconnected (normal left inverted right x axis y axis)
DP-3 disconnected (normal left inverted right x axis y axis)
HDMI-0 connected 3840x2160+0+0 (normal left inverted right x axis y axis) 1872mm x 1053mm
DP-4 connected primary 3840x2160+0+0 (normal left inverted right x axis y axis) 607mm x 345mm
DP-5 disconnected (normal left inverted right x axis y axis)
Comment 1 Marco Martin 2022-05-09 13:22:51 UTC
are all outputs connected to the internal videocard or there are external DP dongles involved?
Comment 2 Marco Martin 2022-05-09 14:01:40 UTC
in plasmashell itself it doesn't seem that anything have happened between 5.23 and 5.25, wonder in what part the breaking change was.

also, the interested part has been redone completely for 5.25, would be interesting to see how it behaves there
Comment 3 Kai Krakow 2022-05-09 15:21:20 UTC
(In reply to Marco Martin from comment #1)
> are all outputs connected to the internal videocard or there are external DP
> dongles involved?

No dongles but there is one DP-to-HDMI cable. Not sure if that counts as a dongle.

The iGPU card is not active, I'm only using the PCI-e card.

> in plasmashell itself it doesn't seem that anything have happened between 5.23 and 5.25, wonder in what part the breaking change was.

This morning when I turned the monitors back on, all was fine. So it may be some timing issue or something is racing. Or it just created "enough" panels in the qbus javascript dump that it no longer creates new configurations but just chooses from the existing ones. I'll observe it for some time and report back.
Comment 4 Kai Krakow 2022-05-09 15:28:33 UTC
Also, Plasma version is probably not the only thing that changed. The nvidia driver was also updated at least once, and Xorg components were also updated at least once. But I cannot really pin-point that to one of those changes, Plasma version seems to be the strongest indicator.
Comment 5 Kai Krakow 2022-05-18 08:01:33 UTC
It worked for a few days in a row. But yesterday evening and today morning, this happened again and the behavior is quite random:

This time, only the top panel moved to the wrong screen while the bottom panel stood in place. Or maybe it's rather the other way around: Turning my main monitor off probably moves the panels to the other monitor, and when turning it back on, the panels do not properly move back.

The interesting part this time is that the bottom panel behaved properly while the top panel behaved wrong.

Latest 5.24 doesn't fix anything. Let's see if 5.25 solves something.
Comment 6 Kai Krakow 2022-06-17 05:58:50 UTC
Okay, so I'm now on Plasma 5.25 and this original issue seems fixed.

But now, when I turn the monitor back on, the background image of that monitor is gone and completely black. I also cannot right click on the background: no context menu would appear.

The panels are still there, and switching the panels to editing mode doesn't show the additional button bar to change background images, global design etc on that monitor (but it's shown on the others).

Only restarting plasmashell will bring back the background image and context menu function.
Comment 7 Nate Graham 2022-06-17 16:04:12 UTC
Cool, thanks! Can you file a new bug report for the new issue?

Out of curiosity, does the wallpaper show up after 10 seconds or so?
Comment 8 Kai Krakow 2022-06-21 18:33:32 UTC
(In reply to Nate Graham from comment #7)
> Cool, thanks! Can you file a new bug report for the new issue?
> Out of curiosity, does the wallpaper show up after 10 seconds or so?

Re-opened, because unfortunately, the bug is still there:

With the new panel management tool (available from the edit mode), I can now clearly see how panels move to the wrong screen. This usually happens when connected monitors swap positions: 

The last few days, I'm pretty sure I had the following order in the "Drag panels and desktops around" dialog: DP-4, DP-1, HDMI-0 (deactivated).

Today, when I turned my monitors on, the order changed to "DP-4, HDMI-0 (deactivated), DP-1", and the panels have moved to the deactivated screen (but not the background image, that moved to a different screen a few days before already).

Please take note that the background image shows the same bug but moves independently of the panels, so there are probably race conditions. I've set different wallpapers to track this: Both the wallpapers and the panels move to different screens, and they do NOT move the same way: Sometimes only the wallpaper moves to a different screen, sometimes only one panel of a screen moves, sometimes two panels of the same screen move.

At least the panel management tools allows me to simply move panels and wallpapers back to their correct screen.

The system hasn't been rebooted. All I do is turning off the monitors, and one monitor completely disconnects from the graphics card when turned off. So to reproduce it, in the worst case you'll have to physically disconnect the monitor because many monitors keep their connector online when turned off - but one of my monitors doesn't.
Comment 9 Kai Krakow 2022-06-27 07:37:33 UTC
Created attachment 150180 [details]
configuration completely doesn't match the output

Here's an example of messed up content:

As you can see, the panels overlap on the right screen although two of them are supposed to be on the left screen. Also, the left screen shows the background image of the deactivated screen. Dragging the panels back and forth in the editor fixes the panel placement. But dragging the background image will simply leave a black background that is not clickable or interactable anymore until I restart the plasmashell service.

So, no - it's not fixed. I'd even say it shows the exact same behavior in 5.25 as it did in 5.24. Configuration and outputs do not match, panels are in very different locations than what Plasma thinks they should be.

Rarely, I see how all panels disappear when I turn a monitor back on, and then re-appear around 5-10s later if that is what you were asking for. This seems to have the effect that plasma doesn't become confused about the monitor layout. I've last seen that in 5.24 but not yet in 5.25.
Comment 10 Nate Graham 2022-08-05 16:15:37 UTC

*** This bug has been marked as a duplicate of bug 450068 ***