Bug 490664

Summary: Plasma 6 desktop sometimes freezes after connecting an external monitor
Product: [Plasma] kwin Reporter: Tobiáš Potoček <tobiaspotocek>
Component: wayland-genericAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED DUPLICATE    
Severity: normal CC: boris.v.petrov, kde, xaver.hugl
Priority: NOR    
Version First Reported In: 6.1.2   
Target Milestone: ---   
Platform: Fedora RPMs   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Output of journalctl --user -u plasma-kwin_wayland -b just after a freeze occurred
Another instance of freeze
Output of journalctl -k
KWin logs before freeze

Description Tobiáš Potoček 2024-07-22 19:02:52 UTC
STEPS TO REPRODUCE
1. Connect an external monitor to my laptop while signed in into Plasma. The screen may or may not be locked.

OBSERVED RESULT
Sometimes (maybe in 25% cases?) the desktop freezes (= becomes unresponsive). It happens just as I connect the screen, that means immediately.

In some cases, the frozen state is only temporary and after ~10 seconds I can resume using the system normally, in other cases the system freezes completely and I need to hard-reset it. There is no crashing involved.

While frozen, the screen content becomes static (both on the laptop screen and the external screen) and it does not seem to react to any input (for example, pressing Caps Lock won't toggle the indicator light). However, unless completely frozen, the laptop goes to sleep if I close the laptop lid (the power diode starts slowly flashing, which is how the laptop indicates sleeping). If I wake it up, it resumes to the frozen state.

EXPECTED RESULT
I connect an external monitor and the desktop environment is immediately responsive.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Fedora Linux 40
KDE Plasma Version:  6.1.2
KDE Frameworks Version: 6.3.0
Qt Version: 6.7.2
Kernel: 6.9.9-200.fc40.x86_64
Graphics Platform: Wayland

Using Lenovo Thinkpad T14s with AMD Ryzen 7 PRO 7840U.

ADDITIONAL INFORMATION
- My laptop is Lenovo Thinkpad T14s with AMD Ryzen 7 PRO 7840U.
- The monitor is a recent Thinkvision model, connected via USB-C. Not sure if that happens also over HDMI.
- Disconnecting the external screen works fine. Also once the external screen is successfully connected, I works reliably (no issues of this kind).
- This behavior started with Plasma 6. It was fine in Plasma 5 (also Wayland). I did not report it earlier as I considered to be an early Plasma 6 issue to be ironed out soon, but unfortunately it persists even with Plasma 6.1.
Comment 1 Tobiáš Potoček 2024-07-22 19:03:47 UTC
If you give me instructions, I'm happy to share logs / error output.
Comment 2 David Edmundson 2024-07-25 11:46:52 UTC
After this happens can I have a log of 

journalctl --user -u plasma-kwin_wayland -b
Comment 3 Tobiáš Potoček 2024-07-25 12:33:43 UTC
Thanks for the instructions. Will share the log the next time this happens.
Comment 4 Tobiáš Potoček 2024-07-29 08:06:08 UTC
Created attachment 172099 [details]
Output of journalctl --user -u plasma-kwin_wayland -b just after a freeze occurred

Just experienced a freeze after connecting my monitor. See the log attached. I captured it just as the screen became operational.
Comment 5 Tobiáš Potoček 2024-08-05 06:14:17 UTC
Created attachment 172289 [details]
Another instance of freeze

I examined the log and I'm not sure if there is anything useful.

The following lines indicate some sort of problem:

Aug 05 08:06:37 thinkTobin kscreenlocker_greet[378693]: qt.qpa.wayland: Could not create EGL surface (EGL error 0x3000)
Aug 05 08:06:37 thinkTobin kscreenlocker_greet[378693]: pam_unix(kde:auth): authentication failure; logname=tobik uid=1000 euid=1000 tty= ruser= rhost=  user=tobik
Aug 05 08:06:37 thinkTobin kscreenlocker_greet[378693]: QEventLoop: Cannot be used without QApplication
Aug 05 08:06:38 thinkTobin kscreenlocker_greet[378693]: Failed to write to the pipe: Bad file descriptor.

But, they seem to be linked to screenlocking and the freeze happened only after I had already unlocked the screen successfuly.

Then there is this line, but that happens literally all the time:

Aug 05 08:07:37 thinkTobin kwin_wayland[3116]: kwin_wayland_drm: atomic commit failed: Invalid argument

Finally, this line is probably most relevant:

Aug 05 08:08:07 thinkTobin kwin_wayland[3116]: kwin_wayland_drm: No drm events for gpu "/dev/dri/card1" within last 30 seconds

But that just says "no events"... which kind of corresponds to the environment being frozen.
Comment 6 Tobiáš Potoček 2024-08-05 06:30:26 UTC
Created attachment 172290 [details]
Output of journalctl -k

Attaching also journalctl -k output.

I'm not seeing anything weird, that would immediately catch my attention.

What's happening is that:
- 08:07:37 I connect my monitor via USB-C
- I receive the last kwin_wayland_drm: atomic commit failed: Invalid argument
- 08:07:37-39 a bunch of USB peripherals get connected (they are attached to the monitor via a hub)
- Nothing
- 08:08:07 No drm events for gpu "/dev/dri/card1" within last 30 seconds
- The environment resumes
Comment 7 Tobiáš Potoček 2024-08-05 06:31:45 UTC
(In reply to Tobiáš Potoček from comment #6)
> they are attached to the monitor via a hub

Small correction: the monitor itself acts as a hub. My mouse and keyboard are connected to the hub.
Comment 8 Bug Janitor Service 2024-08-20 03:47:30 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!
Comment 9 Boris Petrov 2024-08-25 10:44:23 UTC
Hi,

Although my setup is a bit different, I believe I have run (multiple times) into the same issue. In my case, it doesn’t happen directly on connecting the external display, but seemingly randomly after some time using it.

I may go about a few reboots, over multiple days, without it happening, and then, with no obvious pattern I can discern, everything freezes and I have to hard-reset. It is particularly inconvenient when it happens during a NixOS update as performing a hard-reset doesn’t complete the generation and the system is mostly broken.

My hardware is:
- Laptop: Lenovo Legion 5
- CPU: AMD Ryzen 5 4600H
- GPU: using Integrated Graphics, though the system has an RTX 2060

My software is:
- OS: NixOS 24.05
- KDE Plasma Version: 6.0.5
- KDE Frameworks Version: 6.2.0
- Qt Version: 6.7.2
- Kernel: 6.6.46
- Graphics Platform: Wayland

For the specifics:
- I connect to the external display using HDMI, not USB C
- I don’t use a hub, everything is directly connected to the laptop

I will attach the logs that seem relevant.
Comment 10 Boris Petrov 2024-08-25 10:45:52 UTC
Created attachment 172933 [details]
KWin logs before freeze
Comment 11 Boris Petrov 2024-08-25 10:48:26 UTC
A slight addition which may be irrelevant, but the freeze happened roughly 5 minutes after the last log. There isn’t anything right before the freeze.
Comment 12 Tobiáš Potoček 2024-08-25 13:13:36 UTC
FWIW I also did have one recent instance of the freeze happening completely randomly, without the external monitor connected at all.

But connecting the monitor is the most usual trigger.
Comment 13 Tobiáš Potoček 2024-09-10 17:39:42 UTC
Just a friendly ping 🙏 

Today I experienced another freeze, which I did not recover from and had to hard shut down the whole laptop. I'm frequently connecting and disconnecting external screens at work and this has serious impact on my productivity.
Comment 14 Zamundaaa 2024-09-24 12:58:21 UTC
I'm reasonably certain that this is the same as bug 492167, which will be fixed in 6.2.0. If it does still happen for you in 6.2, just reopen this!

*** This bug has been marked as a duplicate of bug 492167 ***
Comment 15 Tobiáš Potoček 2024-09-24 14:45:23 UTC
Okay, thanks a lot! Fingers crossed for 6.2 then.
Comment 16 Boris Petrov 2024-09-24 15:13:58 UTC
Thanks as well!
Comment 17 Boris Petrov 2024-12-29 20:29:41 UTC
Hi! I have been daily-driving Plasma 6.2 for over a month now and I’m happy to report that the bug on my end is gone. Many thanks for fixing it, it’s so much better now!