High CPU Usage when Screen is Locked

Running KDE / Plasma. When I lock my screen, my CPU utilization goes way up, and the fan on my laptop runs at a high speed. How do I stop this?

This is a bit of a long shot, and may no longer apply. A long long time back, the KDE screen locker sometimes burnt a lot of CPU if it was configured to display a clock (System Settings-> Screen Locking → Configure Appearance → Show Clock). Perhaps this has long been resolved, but you might experiment with it, and maybe also with some of the other settings, such as changing to a plain colour background.

It would be worth checking whether something has been logged in the journal (sudo journalctl --boot).

You might also login on a console and use something like htop, top, or other tools to investigate.

I just tried changing to no clock, plain color - no change.

I didn’t see anything interesting in the journal (but it is pretty long, and I am not sure what I am looking for, other than “interesting”).

Top shows that “Xorg_bin” and “kwin_x11” are each using 50+% CPU when the screen is locked.

I have two computers where this is happening. Both have multiple monitors (one laptop with the built-in, a HDMI, and a DisplayPort; one desktop with a VGA and a HDMI). If I unplug the extra monitors, this still happens. If I unplug the extra monitors then reboot, this stops.

I have a two monitor setup (two DP monitors). I tried to look if anything similar was happening on my desktop. Initially thought so, shortly after locking the session the CPU hits the roof, but it’s due to a core dump. For me, plasmashell core-dumps shortly after I ALT-F1 and switch to a console to run htop - which necessitates kwin_x11 --replace & when I resume the session. If I refrain from switching to a console, I don’t get a core-dump and I don’t hear any fans kicking in, so I don’t think I’m experiencing the same problem.

I also remembered some old similar threads, I tracked down a couple:

484323 – High CPU load of kwin_x11 when locking or turning off the screen seems to match my issue.

killing kwin_x11 seems to stop the high CPU (temporary)

Turning off the Compositor seems to stop the high CPU. (But seems to make some menus and pop-ups look “weird”…)

You can toggle compositing programmatically from the command line via dbus:

dbus-send --session --dest=org.kde.kglobalaccel \
  --print-reply \
  --type=method_call \
  /component/kwin  \
  org.kde.kglobalaccel.Component.invokeShortcut \
  string:'Suspend Compositing'

On my desktop running this disables compositing and things look weird. Running it again restores compositing and things look OK again.

You might be able put this in a script for locking the session, if it’s followed by:

loginctl lock-session

I’m not sure how to automatically re-enable compositing when the session is resumed. Maybe a python script could wait for a dbus signal. Perhaps a loop could just sleep polling whether the session is unlocked - I’m not sure how to test for that, but perhaps the state listed by:

loginctl show-session

Do you also see this on Plasma Wayland?

1 Like

I do not see the high CPU issue on Wayland.
(But I have some things that do not work under Wayland, so that is not a “solution” for me.)

What if you try to disable kscreen2. Does it still happens?

What is kscreen2? Where do I find it, and how do I disable it?

(I do not see anything called kscreen2 on my system.)

@Ken23Holloway In an effort to help and clarify, I installed the plasma pattern and you are right kscreen2 is nowhere to be seen in the systemsettings. My apologies.