Bug 512155

Summary: Laptop screen does not turn on after turning off external monitor [Wayland]
Product: [Plasma] kwin Reporter: Jackson <bugs>
Component: multi-screenAssignee: KWin default assignee <kwin-bugs-null>
Status: REPORTED ---    
Severity: normal CC: xaver.hugl
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: drm debug log

Description Jackson 2025-11-15 20:17:18 UTC
SUMMARY
On a setup where a laptop screen is off and an external monitor is on, turning the external monitor off while the laptop is awake does not switch to the built-in screen; likewise, putting the computer to sleep, then waking it when no longer connected to the external monitor does not turn on the built-in screen (which necessitates a reboot).

STEPS TO REPRODUCE
1. Connect to the external monitor and set the display configuration to "Switch to external screen".
Either:
2. Turn off or unplug the external monitor from the laptop.
or
2. Put the laptop to sleep and unplug turn off or unplug the external monitor from the laptop.
3. Wake the laptop.

OBSERVED RESULT
The laptop's built-in screen does not turn on.

EXPECTED RESULT
The laptop's built-in screen should turn on.

SOFTWARE/OS VERSIONS
Operating System: Kubuntu 25.10
KDE Plasma Version: 6.4.5
KDE Frameworks Version: 6.17.0
Qt Version: 6.9.2
Kernel Version: 6.17.0-6-generic (64-bit)
Graphics Platform: Wayland
Processors: 12 × 12th Gen Intel® Core™ i5-1235U
Memory: 48 GiB of RAM (46.8 GiB usable)
Graphics Processor: Intel® Iris® Xe Graphics
Manufacturer: LENOVO
Product Name: 21AHCTO1WW
System Version: ThinkPad T14 Gen 3

External monitor: Dell S2722DC (attached to the laptop via USB-C

ADDITIONAL INFORMATION
The biggest problem with this bug is that it does not always happen. After a reboot things work as they should, but will, eventually, fail. Repeatedly (at least a dozen times) turning on and off the monitor does not trigger it, but then after a half-day or day the system no longer switches to the built-in monitor.

After the bug occurs once, the laptop screen will never turn on unless "Switch to laptop screen" is manually selected in the Display configuration selection, and "Switch to external screen" must then manually selected to switch back to the external monitor.

This poses a significant problem when I put the laptop to sleep, then unplug it while asleep as there is no way to interact with the computer. As far as I can tell the keyboard is useless as well: I can't log in and, say use krunner to restart the computer while the built-in screen is off (key presses do not seem to be recognized). The computer definitely wakes up though (the laptop's LED, which blinks when asleep, becomes solid). The only solutions are to reattach the external monitor (which shows nothing, but if the laptop lid is closed and reopened then shows a picture on wake-up) or (if not next to the monitor) force a shutdown of the machine by holding the power button down.

There was never issue like this in previous versions of Kubuntu, in 25.04 and before (so in Plasma 6.3 and earlier). However, I was using X11, and now am using Wayland (since the X11 session was removed upon upgrading). 

I tried to compare system logs when it successfully switches to the laptop screen and not, and did notice a ton of "kwin_wayland_drm: Atomic modeset test failed! Invalid argument" errors when it fails. And I will gladly provide any other necessary information.
Comment 1 Jackson 2025-11-15 20:18:15 UTC
And here is the output of kscreen-doctor -o:

Output: 1 eDP-1 d520fe95-3b4a-4bbe-b174-2442dd599d1d
        disabled
        connected
        priority 0
        Panel
        replication source:0
        Modes:  1:1920x1200@60*!  2:1600x1200@60  3:1600x1200@60  4:1280x1024@60  5:1280x1024@60  6:1024x768@60  7:1024x768@60  8:1280x800@60  9:1280x800@60  10:1920x1080@60  11:1920x1080@60  12:1600x900@60  13:1600x900@60  14:1368x768@60  15:1368x768@60  16:1280x720@60  17:1280x720@60 
        Geometry: 0,0 1920x1200
        Scale: 1
        Rotation: 1
        Overscan: 0
        Vrr: Automatic
        RgbRange: Automatic
        HDR: incapable
        Wide Color Gamut: incapable
        ICC profile: none
        Color profile source: sRGB
        Color power preference: prefer efficiency and performance
        Brightness control: supported, set to 100% and dimming to 100%
        Color resolution: automatic (10), range: [6; 12] bits per color
        Allow EDR: always
Output: 2 DP-1 ca0718b3-1281-4620-a7d1-cc78c376f5bc
        enabled
        connected
        priority 1
        DisplayPort
        replication source:0
        Modes:  18:2560x1440@60*!  19:2560x1440@75  20:2048x1080@60  21:1920x1080@60  22:1920x1080@60  23:1920x1080@60  24:1920x1080@50  25:1600x900@60  26:1280x1024@75  27:1280x1024@60  28:1152x864@75  29:1280x720@60  30:1280x720@60  31:1280x720@50  32:1024x768@75  33:1024x768@60  34:800x600@75  35:800x600@60  36:720x576@50  37:720x576@50  38:720x480@60  39:720x480@60  40:720x480@60  41:720x480@60  42:640x480@75  43:640x480@60  44:640x480@60  45:640x480@60  46:720x400@70 
        Geometry: 0,0 2560x1440
        Scale: 1
        Rotation: 1
        Overscan: 0
        Vrr: Automatic
        RgbRange: Automatic
        HDR: incapable
        Wide Color Gamut: incapable
        ICC profile: none
        Color profile source: sRGB
        Color power preference: prefer efficiency and performance
        Brightness control: supported, set to 100% and dimming to 100%
        Color resolution: automatic (10), range: [6; 12] bits per color
        Allow EDR: unsupported
Comment 2 Jackson 2025-12-05 22:33:21 UTC
I figured out how to consistently reproduce the bug every time.

STEPS TO REPRODUCE
1. Confirm Display Configuration is set to "Switch to external screen" when connected to an external monitor.
2. Wake and then sleep the laptop while *not* connected to the external monitor.
3. Connect the laptop to the external monitor and turn the monitor on.
4. Wake the laptop and log in.[1] 
5. Turn off the monitor or disconnect the laptop.

OBSERVED RESULT
The laptop's built-in screen does not turn on. Even after sleeping and waking it again, the screen will never turn on and the issue is only resolved by a hard restart.

EXPECTED RESULT
The laptop's built-in screen should turn on.

ADDITIONAL INFORMATION
My issue before was that sleeping the laptop while connected to the monitor does not trigger the problem so it seemed inconsistent to me. I have also tested this with an X11 session. The bug never occurs with X11: the laptop's screen always turns on as it should. It is, therefore, some issue with Wayland. In addition, the bug still occurs if the login screen is not set to show after waking from sleep.

I did, at least, discover a sort of workaround. Always wake the laptop *before* connecting it to the external monitor. Then, once the monitor is turned on and plugged in, it will switch properly. If the monitor is first turned on as the laptop wakes, then the bug will appear when the laptop is disconnected again and won't resolve until a reboot.

[1] Often the login screen at this point shows a sign that there is something wrong, namely the circle around the user avatar is missing and the avatar is square; unsure if that is relevant.
Comment 3 Zamundaaa 2025-12-08 00:02:24 UTC
Following those steps, that unfortunately doesn't reproduce the problem for me, the internal display turns on fine. If you can consistently reproduce it, that still helps a lot with debugging though.

Judging by
> kwin_wayland_drm: Atomic modeset test failed! Invalid argument
the driver is rejecting KWin's output configuration, so either there's a bug in KWin or in the driver. Either way, we need to find out why it's getting rejected.
https://invent.kde.org/plasma/kwin/-/wikis/Debugging/Debugging-DRM-issues describes how to enable drm debug logging - enable it, trigger the issue, and then attach the log here.

You can do all of that from ssh as well, ideally you enable debug logging + run dmesg right before unplugging the external monitor, and stop it right afterwards.
One thing you can also test then is if
> killall -9 kwin_wayland
will get your system back to a working state.
Comment 4 Jackson 2025-12-08 20:38:45 UTC
Created attachment 187442 [details]
drm debug log

Thanks for the response, it is appreciated. I wonder why it's only happening on my setup. 

Using killall -9 kwin_wayland does temporarily fix the issue, acting the same as a restart (i.e., it works properly until the laptop sleeps while not connected to the external monitor, then the problem returns). Well, almost the same: for some reason after the killall command the lock screen won't show a "Sleep" option under the password prompt, only "Switch User" (probably not relevant?).

I followed the instructions, hopefully I did it correctly. These are the exact steps I followed:

1. Input into a terminal:
> echo 0x1FF | sudo tee /sys/module/drm/parameters/debug
2. Unplugged the monitor from the laptop.
    (No image appeared on the laptop screen.)
3. Plugged the monitor back into the laptop.
    (At this point there is no image on the built-in screen or external monitor, which is always the case with this issue; I don't think I made that clear earlier. In this state the computer doesn't seem to even recognize keypresses, e.g., can't switch to virtual terminal.)
4. Put the laptop to sleep by closing the lid.
5. Woke the laptop by opening the lid.
    (The external monitor now shows an image and I can get past the lock screen.)
6. Input into a terminal:
> sudo dmesg -w > drm-debug.log

The log is attached, let me know if there's anything else I can provide.
Comment 5 Bug Janitor Service 2025-12-23 03:46:12 UTC
🐛🧹 ⚠️ This bug has been in NEEDSINFO status with no change for at least 15 days. Please provide the requested information, then set the bug status to REPORTED. If there is no change for at least 30 days, it will be automatically closed as RESOLVED WORKSFORME.

For more information about our bug triaging procedures, please read https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging.

Thank you for helping us make KDE software even better for everyone!