Bug 492167 - After the display turns off and back on again, the system is interactive but the screen doesn't update for 30 seconds
Summary: After the display turns off and back on again, the system is interactive but ...
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (show other bugs)
Version: 6.1.4
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
: 490664 (view as bug list)
Depends on:
Blocks:
 
Reported: 2024-08-25 14:44 UTC by tealdislike
Modified: 2024-11-10 16:06 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.2.0
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tealdislike 2024-08-25 14:44:09 UTC
SUMMARY
Every time around 30 seconds after the screen turns off to save power, once the mouse is moved or keyboard key is pushed, the screen is frozen for 30 seconds, after which it returns to normal and is accepting input and the screen starts updating. Happens on the lock screen and also when not on the lock screen. The bug was also reproducible on fedora and is not reproducible while running the X11 session. 
https://bugs.kde.org/show_bug.cgi?id=462846 is similar, but reports that the issue persists a shorter time and happens only when waking from the lock screen, so I'm not sure if it is the same issue.

STEPS TO REPRODUCE
1. Wait for the screen to turn off after the set time, then wait another 30 seconds or so.
2. Move the mouse or press a key on the keyboard to try and wake up the computer.

OBSERVED RESULT
Screen shows a frozen frame (sometimes the one it showed when the screen went to power save, sometimes one that is right after waking up)  for 30 seconds and is not registering any input.

EXPECTED RESULT
Once you move the mouse or press a key, the inputs should be registered and shown on the display immediately after the monitor turns on.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 6.1.4
KDE Frameworks Version: 6.5.0
Qt Version: 6.7.2
Kernel Version: 6.10.6-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 4 × AMD Ryzen 3 3200G with Radeon Vega Graphics
Memory: 15.5 GiB of RAM
Graphics Processor: AMD Radeon RX 5700

ADDITIONAL INFORMATION
journalctl output when I try to wake the computer (from lock screen):
Aug 25 17:15:34 amarantite kscreenlocker_greet[8763]: pam_systemd_home(kde:auth): New sd-bus connection (system-bus-pam-systemd-home-8763) opened.
Aug 25 17:15:34 amarantite kdeconnectd[1140]: 2024-08-25T17:15:34 org.kde.pulseaudio: No object for name "alsa_output.pci-0000_0a_00.6.analog-stereo.monitor"
Aug 25 17:15:34 amarantite kded6[881]: org.kde.pulseaudio: No object for name "alsa_output.pci-0000_0a_00.6.analog-stereo.monitor"
Aug 25 17:15:34 amarantite plasmashell[940]: org.kde.pulseaudio: No object for name "alsa_output.pci-0000_0a_00.6.analog-stereo.monitor"
Aug 25 17:15:35 amarantite kwin_wayland[711]: kwin_wayland_drm: Presentation failed! Invalid argument
Aug 25 17:15:35 amarantite kwin_wayland[711]: kwin_wayland_drm: atomic commit failed: Invalid argument
Aug 25 17:15:37 amarantite org_kde_powerdevil[989]: Emitting DDCA_Display_Status_Event( 2085.660:  DDCA_EVENT_DPMS_AWAKE, card1-DP-1, dref: Display_Ref[bus /dev/i2c-6], io_path:/dev/i2c-6]
Aug 25 17:15:37 amarantite org_kde_powerdevil[989]: Executed 1 registered callbacks.
Aug 25 17:15:38 amarantite org_kde_powerdevil[989]: dh=Display_Handle[i2c-6: fd=32], Keeping adjusted sleep multiplier 2.00 for SE_POST_WRITE or SE_POST_SAVE_SETTINGS
Aug 25 17:16:05 amarantite kwin_wayland[711]: kwin_wayland_drm: No drm events for gpu "/dev/dri/card1" within last 30 seconds
Aug 25 17:16:12 amarantite kscreenlocker_greet[8763]: Failed to write to the pipe: Bad file descriptor.
Aug 25 17:16:13 amarantite kdeconnectd[1140]: 2024-08-25T17:16:13 default: DataControlOffer: timeout reading from pipe
Aug 25 17:16:14 amarantite kdeconnectd[1140]: 2024-08-25T17:16:14 default: DataControlOffer: timeout reading from pipe


journalctl output after waking up from the desktop:
Aug 25 17:36:58 amarantite plasmashell[940]: org.kde.pulseaudio: No object for name "alsa_output.pci-0000_0a_00.6.analog-stereo.monitor"
Aug 25 17:36:58 amarantite kdeconnectd[1140]: 2024-08-25T17:36:58 org.kde.pulseaudio: No object for name "alsa_output.pci-0000_0a_00.6.analog-stereo.monitor"
Aug 25 17:36:58 amarantite kded6[881]: org.kde.pulseaudio: No object for name "alsa_output.pci-0000_0a_00.6.analog-stereo.monitor"
Aug 25 17:36:59 amarantite kwin_wayland[711]: kwin_wayland_drm: Presentation failed! Invalid argument
Aug 25 17:36:59 amarantite kwin_wayland[711]: kwin_wayland_drm: atomic commit failed: Invalid argument
Aug 25 17:37:00 amarantite org_kde_powerdevil[989]: Emitting DDCA_Display_Status_Event( 3368.291:  DDCA_EVENT_DPMS_AWAKE, card1-DP-1, dref: Display_Ref[bus /dev/i2c-6], io_path:/dev/i2c-6]
Aug 25 17:37:00 amarantite org_kde_powerdevil[989]: Executed 1 registered callbacks.
Aug 25 17:37:01 amarantite org_kde_powerdevil[989]: dh=Display_Handle[i2c-6: fd=32], Keeping adjusted sleep multiplier 2.00 for SE_POST_WRITE or SE_POST_SAVE_SETTINGS
Aug 25 17:37:29 amarantite kwin_wayland[711]: kwin_wayland_drm: No drm events for gpu "/dev/dri/card1" within last 30 seconds

I am not sure that the pulseaudio events are connected in any way.
Comment 1 Nate Graham 2024-08-27 20:55:53 UTC
What kind of screen is it? And is there just one, or are there more than one plugged in?
Comment 2 tealdislike 2024-08-28 15:30:28 UTC
(In reply to Nate Graham from comment #1)
> What kind of screen is it? And is there just one, or are there more than one
> plugged in?

Only one monitor (AOC 24G2W1G3) is plugged in with a DP cable, running at 165 Hz with Freesync off, no color profile, 100% scale.
Comment 3 tealdislike 2024-08-28 17:06:53 UTC
Correction, the mouse and keyboard inputs are registered, only the graphics don't update.
Comment 4 Nate Graham 2024-08-29 19:57:41 UTC
Thanks!
Comment 5 Zamundaaa 2024-09-02 17:34:17 UTC
> kwin_wayland_drm: No drm events for gpu "/dev/dri/card1" within last 30 seconds
This is the culprit: KWin has a blocking wait for pending presentation requests to finish before it changes display configurations (like turning the display on). For some reason this never finishes for you, so it just blocks until it hits the timeout.
Comment 6 tealdislike 2024-09-02 18:12:28 UTC
(In reply to Zamundaaa from comment #5)
Is there any way to try and get to the source of the issue? If I remember correctly, it first appeared some time after plasma 6.0 release, though I'm not sure exactly when.
Comment 7 Bug Janitor Service 2024-09-02 18:31:48 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/6346
Comment 8 Zamundaaa 2024-09-02 19:10:52 UTC
I think it should be fixed by that MR, but it would be great if you could test and verify that it actually fixes the problem
Comment 9 tealdislike 2024-09-02 20:46:43 UTC
Awesome! I will try to test it tomorrow.
Comment 10 tealdislike 2024-09-05 19:26:33 UTC
Unfurtunately I was unable to compile from source or using kdesrc-build (even standard branch, whichever it tries to build by default). I will be able to try this fix once it gets to kde-unstable repos or to arch main repos and will report if the issue is fixed. I don't have the time to figure how to get through these errors currently.
Comment 11 Zamundaaa 2024-09-17 13:49:03 UTC
Git commit 33ad107fa15999f66f4ca9d272c711b8a7080c68 by Xaver Hugl.
Committed on 17/09/2024 at 13:48.
Pushed by zamundaaa into branch 'master'.

backends/drm: fix an edge case for DrmGpu::waitIdle

Polling for drm events works for waiting on pageflip events, but if there's commits
scheduled for future submission, and that fails, no pageflip will ever arrive.
To fix that, this commit ensures at least one commit is actually submitted to the
kernel before polling for pageflip events.

M  +17   -0    src/backends/drm/drm_commit_thread.cpp
M  +8    -0    src/backends/drm/drm_commit_thread.h
M  +4    -3    src/backends/drm/drm_gpu.cpp
M  +3    -3    src/backends/drm/drm_pipeline.cpp
M  +1    -1    src/backends/drm/drm_pipeline.h

https://invent.kde.org/plasma/kwin/-/commit/33ad107fa15999f66f4ca9d272c711b8a7080c68
Comment 12 Zamundaaa 2024-09-17 14:22:23 UTC
Git commit d812f34b993c94ed3e81b53a0d788b9d25cf3a6c by Xaver Hugl.
Committed on 17/09/2024 at 14:22.
Pushed by zamundaaa into branch 'Plasma/6.2'.

backends/drm: fix an edge case for DrmGpu::waitIdle

Polling for drm events works for waiting on pageflip events, but if there's commits
scheduled for future submission, and that fails, no pageflip will ever arrive.
To fix that, this commit ensures at least one commit is actually submitted to the
kernel before polling for pageflip events.

(cherry picked from commit 33ad107fa15999f66f4ca9d272c711b8a7080c68)

Co-authored-by: Xaver Hugl <xaver.hugl@gmail.com>

M  +17   -0    src/backends/drm/drm_commit_thread.cpp
M  +8    -0    src/backends/drm/drm_commit_thread.h
M  +4    -3    src/backends/drm/drm_gpu.cpp
M  +3    -3    src/backends/drm/drm_pipeline.cpp
M  +1    -1    src/backends/drm/drm_pipeline.h

https://invent.kde.org/plasma/kwin/-/commit/d812f34b993c94ed3e81b53a0d788b9d25cf3a6c
Comment 13 Zamundaaa 2024-09-24 12:58:21 UTC
*** Bug 490664 has been marked as a duplicate of this bug. ***
Comment 14 tealdislike 2024-10-10 13:04:09 UTC
I just installed the Plasme 6.2 update and tested it. The issue seems to be fixed now, thanks!
Comment 15 Tobiáš Potoček 2024-11-10 16:06:30 UTC
I have waited a little, but now after a month it seems that the freezes are indeed gone. Kudos to the devs 👏