Bug 480367 - Desktop sluggish/laggy after resume from suspend
Summary: Desktop sluggish/laggy after resume from suspend
Status: REPORTED
Alias: None
Product: kwin
Classification: Plasma
Component: performance (show other bugs)
Version: 5.27.10
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
: 480292 (view as bug list)
Depends on:
Blocks:
 
Reported: 2024-01-26 15:39 UTC by Wouter Bijlsma
Modified: 2024-08-04 19:06 UTC (History)
5 users (show)

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


Attachments
KWin info (6.76 KB, text/plain)
2024-02-12 20:50 UTC, Marcel Hasler
Details
X11 info (82.06 KB, text/plain)
2024-02-12 20:50 UTC, Marcel Hasler
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Wouter Bijlsma 2024-01-26 15:39:55 UTC
Suspending (sleeping) a Lenovo Yoga Slim 7 (14APU8) laptop with Ryzen 7640S / Radeon 760M results in poor graphics KDE desktop performance after resuming from sleep.

Recently s2idle (modern standby) has been fixed for this laptop, which requires an ACPI SSDT workaround to be able to suspend, see [1] for more information. The performance problem after suspending appears to be KDE specific and not related to the original ACPI issue in this laptop.

Description of the problem:
  * Computer functions normal after suspend, but all graphics interactions are sluggish as if running at ~20fps, even just moving the mouse cursor
  * Occurs both on Wayland and X11
  * Logging out then logging back in or restarting KWin using `kwin --replace` fixes the problem (but loses all open applications on Wayland). 
  * Gnome on the same machine does not exhibit this problem, suspends/resumes just fine
  * No obvious CPU hogging processes are seen after suspend, also laptop doesn't run hot, and e.g. compile tasks have identical timings before/after suspend, suggesting this is more likely a GPU or synchronization issue

I have tried to enable KWin debug logging  using `QT_LOGGING_RULES="kwin_*.debug=true"`  in my shell profile, but no log messages are written to `~/.local/share/sddm/wayland-session.log` at all. Neither `journalctl -f` or `dmesg` provide any clues what is going on. I would like to be able to debug this but I have no idea how/where KWin/Plasma is supposed to write log/debug info to.


STEPS TO REPRODUCE
1. Log in using SDDM
2. Suspend using either menu or `systemctl suspend`
3. Resume by pressing power button

OBSERVED RESULT
Desktop UI rendering is sluggish as if running at reduced framerate

EXPECTED RESULT
Desktop UI performance is the same as before suspending

Operating System: Arch Linux 
KDE Plasma Version: 5.27.10
KDE Frameworks Version: 5.114.0
Qt Version: 5.15.12
Kernel Version: 6.7.1-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 12 × AMD Ryzen 5 7640S with Radeon 760M Graphics
Memory: 13,4 GiB of RAM
Graphics Processor: AMD Radeon Graphics
Manufacturer: LENOVO
Product Name: 83AA
System Version: Yoga Slim 7 14APU8

ADDITIONAL INFORMATION
[1] https://gitlab.freedesktop.org/drm/amd/-/issues/2812#note_2242326
Comment 1 Doug 2024-01-28 06:39:31 UTC
*** Bug 480292 has been marked as a duplicate of this bug. ***
Comment 2 Marcel Hasler 2024-02-12 20:49:41 UTC
Same here on a Ryzen 7 7840HS / Radeon 780M. Simply restarting compositing by hitting ALT+SHIFT+F12 twice makes thing work again as expected. This is on X11.

I have a 120 Hz display. Looking at the FPS counter I normally see a refresh rate between 100-115 (which I know shouldn't be considered reliable). After waking from suspend the counter is stuck at 60 and all animations/movements are slow and jerky. 3D apps like glxgears still report 120 FPS, though. I have also tried setting the display to 60 Hz but get the same result, just with the counter stuck at 30.

I also tried uninstalling xf86-video-amdgpu and using the modesetting driver instead, but that makes no difference.

I'll attach my KWin/X11 info.
Comment 3 Marcel Hasler 2024-02-12 20:50:12 UTC
Created attachment 165786 [details]
KWin info
Comment 4 Marcel Hasler 2024-02-12 20:50:32 UTC
Created attachment 165787 [details]
X11 info
Comment 5 Marcel Hasler 2024-02-19 19:37:54 UTC
BTW, I also have a ThinkPad E14 with a 60 Hz display and Ryzen 7 5825U / Radeon Graphics here running an almost identical system which does *not* show this behavior.
Comment 6 Marcel Hasler 2024-02-24 20:01:18 UTC
I investigated this issue a bit further and at least in my case, running under X11, it turned out to be related to TearFree rendering.

Without any custom configuration in place, i.e. 'xrandr --props' reports 'TearFree: auto', I get the behavior as described above. As I understand it, since I don't have any scaling or rotation enabled, this means TearFree is actually disabled.

If I temporarily enable TearFree with 'xrandr --output eDP --set TearFree on', the problem goes away immediately and the FPS counter shows approx. 120 Hz, as expected. If I disable it again the problem returns just as before with the FPS capped to 60 Hz.

What's even stranger is that if I suspend my laptop just once with TearFree on, the problem goes away permanently, even if I then disable it again, at least until I log out and back in.

So the solution for me is to enable TearFree permanently by creating a configuration file /etc/X11/xorg.conf.d/20-amdgpu.conf with 'Option "TearFree" "true"'.
Comment 7 kde.aerospace405 2024-08-04 19:06:08 UTC
This happens for me on Wayland, KDE 6.1.3.