Bug 488915

Summary: Standalone widgets related to power management and brightness break after reboot
Product: [Plasma] plasmashell Reporter: Pavel Dobiáš <pavel23dob>
Component: Battery MonitorAssignee: Plasma Bugs List <plasma-bugs>
Status: REOPENED ---    
Severity: normal CC: bosscz312, edwin.frank.loeffler, kde, natalie_clarius, nate, pavel23dob, wheniwasatruestar
Priority: NOR Keywords: regression
Version: 6.1.0   
Target Milestone: 1.0   
Platform: Fedora RPMs   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Widgets placed: Left - after reboot, Right - before reboot

Description Pavel Dobiáš 2024-06-21 18:18:46 UTC
Created attachment 170772 [details]
Widgets placed: Left - after reboot, Right - before reboot

SUMMARY
I am using a laptop with KDE Plasma 6.1.0 and use the Brightness and Color and Battery Monitor widgets to monitor and modify device options like display brightness, battery levels and more. After updating to 6.1.0, those widgets have a serious problem. They do not load any information or options for the devices after reboot. When creating a new widget, they load the information correctly. In the provided screenshot on the left, you can see the widgets placed after rebooting, and on the right before rebooting.

STEPS TO REPRODUCE
1. Create a Battery Monitor/Brightness and Color widget - it shows the correct information and options
2. Reboot the system
3. Observe the created widget - it is in a broken state showing no information about the devices
4. Create a new widget again - it shows the correct information and options

OBSERVED RESULT
The widgets do not show device specific information and options, like display brightness or battery levels.

EXPECTED RESULT
The widgets should show the information and options for the specific devices correctly.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 
KDE Plasma Version: 6.1.0
KDE Frameworks Version: 6.3.0
Qt Version: 6.7.1

ADDITIONAL INFORMATION
Device: MSI Pulse GL66 11UEK
Comment 1 edwloef 2024-06-22 12:00:19 UTC
I have the same issue, on a Lenovo IdeaPad Pro 5i. It seems you can also make the widgets work again by running `plasmashell --replace`
Comment 2 ratijas 2024-06-23 05:05:24 UTC
Do you observe any suspicious activity in the system journal? It seems like PowerDevil service fails to load at all, as indicated by the user-facing error message in the top-right applet on the screenshot.
Comment 3 edwloef 2024-06-23 05:50:14 UTC
The PowerDevil service looks like it doesn't crash, however these p4 journal lines seem to be new compared to when it worked:


Jun 23 07:33:35 arch org_kde_powerdevil[1180]: qt.core.qobject.connect: QObject::disconnect: Unexpected nullptr parameter
Jun 23 07:33:35 arch org_kde_powerdevil[1180]: qt.core.qobject.connect: QObject::disconnect: Unexpected nullptr parameter
Comment 4 ratijas 2024-06-23 19:32:46 UTC
Well, that's not much but that's something. Unfortunately, Qt logs don't show you the whole stacktrace by default, so it could be anywhere.

Is this reproducible on a new user?
Comment 5 edwloef 2024-06-24 16:12:17 UTC
I can't reproduce the issue on a fresh user.
Comment 6 Nate Graham 2024-06-25 23:56:06 UTC
Some questions for you to answer with your current user account that's exhibiting the bug:
1. How many of these widgets do you end up having after reboot? More than one? (Include the one in the system tray)
2. Does the issue reproduce if you make absolutely sure you only have *one* instance of each of these widgets on reboot? E.g. by disabling them from the system tray and only having one of each on the desktop.
3. When it happens, is powerdevil running?
4. Can you get journal logs for it powerdevil, or systemd service status/logs, or a crash log for it, or something of the sort?
Comment 7 Nate Graham 2024-06-26 00:11:49 UTC
*** Bug 489196 has been marked as a duplicate of this bug. ***
Comment 8 edwloef 2024-06-26 05:24:04 UTC
> 1. How many of these widgets do you end up having after reboot? More than
> one? (Include the one in the system tray)

I use exactly one, the Power Management one. If I add the Brightness one it also doesn't work on reboot. Both of them seem to work without a plasmashell restart if they're shown through the system tray, even if the relevant widgets are still present elsewhere, where they don't work.

> 2. Does the issue reproduce if you make absolutely sure you only have *one*
> instance of each of these widgets on reboot? E.g. by disabling them from the
> system tray and only having one of each on the desktop.

Yes, but they do work if shown through the system tray instead of the widget itself. Maybe something is getting loaded too early or too late for the standalone widgets to function properly?

> 3. When it happens, is powerdevil running?

Yes.

> 4. Can you get journal logs for it powerdevil, or systemd service
> status/logs, or a crash log for it, or something of the sort?

https://pastebin.com/xyteMpVb is all the mentions of powerdevil in the logs. No systemd services failed to load.
Comment 9 Nate Graham 2024-06-26 14:53:40 UTC
Thanks. I can reproduce it.
Comment 10 Bug Janitor Service 2024-09-13 18:04:26 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/powerdevil/-/merge_requests/425
Comment 11 Jakob Petsovits 2024-09-19 18:12:59 UTC
Git commit 8e698dbcdc9ce95095ea2739713fde05ca4822f5 by Jakob Petsovits.
Committed on 19/09/2024 at 18:06.
Pushed by jpetso into branch 'master'.

applets/batterymonitor: React to D-Bus service (un)register events

Previously, the "Power and Battery" applet only checked for the
presence of PowerDevil's D-Bus services once when it starts up.
This appears to (mostly?) work for applets embedded in a panel,
but does not work for applets on the desktop itself.
Likely there's a timing issue and applets on the desktop start
sooner than PowerDevil will advertise its services.

A better way to work is for the applet to monitor the bus for when
the relevant services appear or disappear. When observing a service
registered or unregistered event, the applet gets set up accordingly.

This fixes the race condition for two out of three applet parts
(power profiles, inhibitions) but does not fix battery status;
the data for that is coming from `BatteryControlModel`
in plasma-workspace. A similar fix will have to be implemented there.
Related: bug 489003, bug 492859, bug 492945

M  +88   -12   applets/batterymonitor/plugin/powermanagementcontrol.cpp
M  +10   -2    applets/batterymonitor/plugin/powermanagementcontrol.h
M  +77   -1    applets/batterymonitor/plugin/powerprofilescontrol.cpp
M  +10   -1    applets/batterymonitor/plugin/powerprofilescontrol.h

https://invent.kde.org/plasma/powerdevil/-/commit/8e698dbcdc9ce95095ea2739713fde05ca4822f5
Comment 12 Bug Janitor Service 2024-09-19 19:26:34 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/4729
Comment 13 Bug Janitor Service 2024-09-19 19:26:36 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/4729
Comment 14 Jakob Petsovits 2024-09-20 12:48:39 UTC
Git commit 0979a34248efa8eac087e418a4cf4419549ece0c by Jakob Petsovits.
Committed on 20/09/2024 at 12:26.
Pushed by jpetso into branch 'master'.

components/batterycontrol: React to D-Bus service (un)register events

Previously, the "Power and Battery" applet only checked for the
presence of PowerDevil's D-Bus services once when it starts up.
This appears to (mostly?) work for applets embedded in a panel,
but does not work for applets on the desktop itself.
Likely there's a timing issue and applets on the desktop start
sooner than PowerDevil will advertise its services.

A better way to work is for the applet to monitor the bus for when
the relevant services appear or disappear. When observing a service
registered or unregistered event, the applet gets set up accordingly.

This fixes the race condition for one out of three applet parts
(battery state) but does not fix power profiles & inhibitions;
these were fixed separately in the powerdevil repository
via commit 8e698dbc.
Related: bug 489003, bug 492859, bug 492945

M  +82   -15   components/batterycontrol/batterycontrol.cpp
M  +6    -1    components/batterycontrol/batterycontrol.h

https://invent.kde.org/plasma/plasma-workspace/-/commit/0979a34248efa8eac087e418a4cf4419549ece0c
Comment 15 Bug Janitor Service 2024-09-23 21:46:20 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/powerdevil/-/merge_requests/428
Comment 16 Jakob Petsovits 2024-09-23 21:49:00 UTC
Git commit 5e8cd380806da20d0b12bf97a3629ac70aa2b77c by Jakob Petsovits.
Committed on 23/09/2024 at 21:41.
Pushed by jpetso into branch 'Plasma/6.2'.

applets/batterymonitor: React to D-Bus service (un)register events

Previously, the "Power and Battery" applet only checked for the
presence of PowerDevil's D-Bus services once when it starts up.
This appears to (mostly?) work for applets embedded in a panel,
but does not work for applets on the desktop itself.
Likely there's a timing issue and applets on the desktop start
sooner than PowerDevil will advertise its services.

A better way to work is for the applet to monitor the bus for when
the relevant services appear or disappear. When observing a service
registered or unregistered event, the applet gets set up accordingly.

This fixes the race condition for two out of three applet parts
(power profiles, inhibitions) but does not fix battery status;
the data for that is coming from `BatteryControlModel`
in plasma-workspace. A similar fix will have to be implemented there.
Related: bug 489003, bug 492859, bug 492945

M  +88   -12   applets/batterymonitor/plugin/powermanagementcontrol.cpp
M  +10   -2    applets/batterymonitor/plugin/powermanagementcontrol.h
M  +77   -1    applets/batterymonitor/plugin/powerprofilescontrol.cpp
M  +10   -1    applets/batterymonitor/plugin/powerprofilescontrol.h

https://invent.kde.org/plasma/powerdevil/-/commit/5e8cd380806da20d0b12bf97a3629ac70aa2b77c
Comment 17 Jakob Petsovits 2024-09-23 22:10:50 UTC
Git commit 43ca4f3bf083651c2ac8b803596e3827ed8d5e76 by Jakob Petsovits.
Committed on 23/09/2024 at 21:48.
Pushed by jpetso into branch 'Plasma/6.2'.

components/batterycontrol: React to D-Bus service (un)register events

Previously, the "Power and Battery" applet only checked for the
presence of PowerDevil's D-Bus services once when it starts up.
This appears to (mostly?) work for applets embedded in a panel,
but does not work for applets on the desktop itself.
Likely there's a timing issue and applets on the desktop start
sooner than PowerDevil will advertise its services.

A better way to work is for the applet to monitor the bus for when
the relevant services appear or disappear. When observing a service
registered or unregistered event, the applet gets set up accordingly.

This fixes the race condition for one out of three applet parts
(battery state) but does not fix power profiles & inhibitions;
these were fixed separately in the powerdevil repository
via commit 8e698dbc (master branch) / commit 5e8cd380 (Plasma/6.2).
Related: bug 489003, bug 492859, bug 492945

M  +82   -15   components/batterycontrol/batterycontrol.cpp
M  +6    -1    components/batterycontrol/batterycontrol.h

https://invent.kde.org/plasma/plasma-workspace/-/commit/43ca4f3bf083651c2ac8b803596e3827ed8d5e76
Comment 18 Emily Svobodová 2024-10-20 08:44:19 UTC
The issue is fixed for the Power and Battery widget but persists for the Brightness and Color widget.