Bug 374740

Summary: Unplugging controller causes 100% usage of one CPU core
Product: [Applications] systemsettings Reporter: tguen <tguenther.dev>
Component: kcm_joystickAssignee: Unassigned bugs mailing-list <unassigned-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: isma.af, tguenther.dev, xnagytibor
Priority: NOR    
Version: 5.27.3   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In: 6
Sentry Crash Report:

Description tguen 2017-01-08 11:08:05 UTC
When in the joystick section of the input settings, unplugging my controller (Sony Dualshock 4) causes 25% CPU usage (quad core CPU -> 100% of one core). Always reproducible.
Comment 1 Christoph Feck 2017-01-10 18:54:08 UTC
Which process?
Comment 2 tguen 2017-01-11 00:04:45 UTC
systemsettings5

It stops using the CPU when I click the 'all settings' button in the top left.
Comment 3 tguen 2021-02-19 08:16:11 UTC
Issue remains in 5.21
Comment 4 Nagy Tibor 2021-10-19 05:48:26 UTC
I can also reproduce this with 5.23. I may be entirely wrong but this is what I see happening:

1. You pull out the joystick cable.
2. Joystick's device file gets nuked.
3. This select call [1] starts always returning immediately without timeouts. No errors thrown.
4. This read call [2] doesn't read anything anymore. No errors thrown.
5. Event loop goes hyperspeed because of the lack of timeouts.

[1] https://invent.kde.org/plasma/plasma-desktop/-/blob/58f29efd5d2975129c07dcdc4a9eb78669c5eb67/kcms/joystick/joydevice.cpp#L292
[2] https://invent.kde.org/plasma/plasma-desktop/-/blob/58f29efd5d2975129c07dcdc4a9eb78669c5eb67/kcms/joystick/joydevice.cpp#L298

No idea about how to properly fix it though.
Comment 5 Nagy Tibor 2022-03-03 19:23:15 UTC
This bug could be a prime candidate for the KDE Eco project. I don't think these kind of busy loops are environmentally-friendly.

I have no hardware to test it however this bug may also affect the thermals and battery life of Valve's Steam Deck. Their user base is more likely to encounter this bug than the usual desktop KDE users for obvious reasons. And imagine unnecessarily spinning a core 100% on a handheld device where every Wh counts...
Comment 6 tguen 2023-03-21 06:37:28 UTC
Issue remains in 5.27.3
Comment 7 Ismael Asensio 2023-12-01 18:03:54 UTC
Should be fixed with the introduction of the new GameController KCM.
It uses a completely different codepath via SDL2.

Please, feel free to reopen if you still can reproduce it after Plasma 6.