Bug 476341

Summary: After disabling laptop screen while external screen is connected, re-enabling laptop screen using KScreen KCM (not the applet) makes it lose its Plasma containment until system is rebooted
Product: [Plasma] kwin Reporter: Nate Graham <nate>
Component: multi-screenAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED FIXED    
Severity: major CC: notmart, xaver.hugl
Priority: NOR Keywords: multiscreen, qt6, wayland
Version: master   
Target Milestone: ---   
Platform: Other   
OS: Linux   
See Also: https://bugs.kde.org/show_bug.cgi?id=476340
https://bugs.kde.org/show_bug.cgi?id=476342
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Nate Graham 2023-10-30 20:58:25 UTC
Plasma 6 Wayland, today's git master. GPU hardware is an Intel 10th gen iGPU; drivers are from Mesa 23.1.9.


STEPS TO REPRODUCE
1. Have a laptop (it has a 4k screen normally run at 200% scale)
2. Plug in an external HDMI screen, either directly, or via a DisplayPort dongle (doesn't seem to make a difference)
3. Use the KScreen applet to invoke "Switch to External Screen" mode. The laptop screen correctly turns off.
4. Use the KScreen applet to invoke "Extend to left" or "Extend to right" modes, or use the KScreen KCM to manually mark the laptop screen as "Enabled"


OBSERVED RESULT
The laptop screen turns on, but it's lost its Plasma containment. All I see on it is the banner in the corner, and right-clicking on the black desktop does nothing. 


EXPECTED RESULT
Laptop screen turns on and its Plasma containment is shown.


ADDITIONAL INFORMATION
Restarting plasmashell or switching which display is marked as "Primary" does not fix the issue. It is not clear how to make the laptop display shows its containment again. For this reason, I'm marking the bug as Grave.


Here's the journal log from plasmashell after restarting it:

Oct 30 14:57:10 Liberator systemd[1884]: Starting plasma-plasmashell.service - KDE Plasma Workspace...
Oct 30 14:57:11 Liberator systemd[1884]: Started plasma-plasmashell.service - KDE Plasma Workspace.
Oct 30 14:57:11 Liberator plasmashell[8470]: file:///home/nate/kde/usr6/share/plasma/plasmoids/org.kde.desktopcontainment/contents/ui/main.qml:93: TypeError: Cannot call method 'elementSize' of null
Oct 30 14:57:11 Liberator plasmashell[8470]: file:///home/nate/kde/usr6/share/plasma/plasmoids/org.kde.desktopcontainment/contents/ui/main.qml:192:25: QML FolderViewDropArea (parent or ancestor of QQuickLayoutAttached): Binding loop detected for property "minimumWidth"
Oct 30 14:57:11 Liberator plasmashell[8470]: file:///home/nate/kde/usr6/share/plasma/wallpapers/org.kde.slideshow/contents/ui/main.qml:14:1: QML WallpaperItem: grabToImage: item's window is not visible
Oct 30 14:57:11 Liberator plasmashell[8470]: file:///home/nate/kde/usr6/share/plasma/wallpapers/org.kde.slideshow/contents/ui/main.qml:14:1: QML WallpaperItem: grabToImage: item's window is not visible
Oct 30 14:57:11 Liberator plasmashell[8470]: file:///home/nate/kde/usr6/share/plasma/plasmoids/org.kde.desktopcontainment/contents/ui/main.qml:93: TypeError: Cannot call method 'elementSize' of null
Oct 30 14:57:11 Liberator plasmashell[8470]: file:///home/nate/kde/usr6/share/plasma/plasmoids/org.kde.desktopcontainment/contents/ui/main.qml:192:25: QML FolderViewDropArea (parent or ancestor of QQuickLayoutAttached): Binding loop detected for property "minimumWidth"
Oct 30 14:57:11 Liberator plasmashell[8470]: qml: The backend got an unknown wallpaper provider type. The wallpaper will now fall back to the default. Please check your wallpaper configuration!
Oct 30 14:57:12 Liberator plasmashell[8470]: qml: SystemTray ItemLoader: Invalid state, cannot determine source!
Oct 30 14:57:12 Liberator plasmashell[8470]: kf.windowsystem: KWindowInfo is only functional when running on X11
Oct 30 14:57:12 Liberator plasmashell[8470]: QFont::setPointSizeF: Point size <= 0 (0.000000), must be greater than 0
Oct 30 14:57:13 Liberator plasmashell[8470]: file:///home/nate/kde/usr6/share/plasma/shells/org.kde.plasma.desktop/contents/views/Panel.qml:102:5: QML Connections: Detected function "onActivated" in Connections element. This is probably intended to be a signal handler but no signal of the target matches the name.
Oct 30 14:57:13 Liberator plasmashell[8470]: QObject::startTimer: Timers cannot be started from another thread
Oct 30 14:57:13 Liberator plasmashell[8470]: Connecting to deprecated signal QDBusConnectionInterface::serviceOwnerChanged(QString,QString,QString)
Oct 30 14:57:14 Liberator plasmashell[8470]: inotify_add_watch(/var/lib/samba/usershares) failed: (Permission denied)
Comment 1 Nate Graham 2023-10-30 21:01:35 UTC
Rebooting the computer makes the Plasma containment come back. I assume rebooting KWin itself would do the same. Reducing severity to only Major.
Comment 2 Nate Graham 2023-10-30 21:14:05 UTC
After that reboot, the manifestation of the bug I experienced here is now different: at step 4, the entire system experiences a visual freeze (not a functional freeze; I can still interact with things). If I switch to VT3 and then back to 2, the visual freeze on the external monitor is fixed, but the laptop screen remains visually frozen. See Bug 476342.
Comment 3 Nate Graham 2023-10-30 21:15:13 UTC
After Bug 476340 and Bug 476342 are fixed, I'll re-test this to see if it's still happening as originally described.
Comment 4 Nate Graham 2023-10-30 21:30:33 UTC
Found the way to reproduce it reliably:

1. Have a laptop (it has a 4k screen normally run at 200% scale)
2. Plug in an external HDMI screen, either directly, or via a DisplayPort dongle (doesn't seem to make a difference)
3. Use the KScreen applet to invoke "Switch to External Screen" mode. The laptop screen correctly turns off
4. Open the KScreen KCM (*not* the applet) and manually re-enable the disabled laptop screen
5. Experiencing the freeze described in Bug 476342; switch to another VT and then back to recover

Result: the laptop screen is turned on, but its' lost its containment. So what happens to the Plasma containment is different when enabling that containment's screen from the KCM vs using the applet's "Extend to left" or "Extend to right" feature.
Comment 5 Zamundaaa 2023-11-09 11:42:51 UTC
Git commit c1312a555169c801b2c116a7b333443730092e07 by Xaver Hugl.
Committed on 09/11/2023 at 12:35.
Pushed by zamundaaa into branch 'master'.

backends/drm: fix pageflip events getting lost when outputs get turned off

When a display gets turned off while a pageflip event was still pending, the pending
state gets changed immediately, without waiting for the pageflip event to arrive first.
When this happens, activePending() returns false, and so the pageflip event gets discarded.
This commit changes the logic to only check for activePending() when the pageflip is for a
modeset, avoiding that issue.
Related: bug 476340, bug 476342, bug 437520, bug 475146

M  +10   -2    src/backends/drm/drm_commit.cpp
M  +2    -0    src/backends/drm/drm_commit.h
M  +5    -2    src/backends/drm/drm_pipeline.cpp
M  +2    -1    src/backends/drm/drm_pipeline.h

https://invent.kde.org/plasma/kwin/-/commit/c1312a555169c801b2c116a7b333443730092e07