Bug 474630

Summary: Battery plasmoid could fail to report current power profile
Product: [Plasma] plasmashell Reporter: Weihao Jiang <weihau.chiang>
Component: Power and Battery widgetAssignee: Plasma Bugs List <plasma-bugs-null>
Status: RESOLVED WORKSFORME    
Severity: minor CC: kde, me, natalie_clarius, nate, weihau.chiang
Priority: NOR    
Version First Reported In: git-stable-Plasma/5.26   
Target Milestone: 1.0   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Screen capture of battery plasmoid display issue
DBus recorded with Wireshark

Description Weihao Jiang 2023-09-17 18:42:34 UTC
Created attachment 161680 [details]
Screen capture of battery plasmoid display issue

SUMMARY

Battery plasmoid UI could fail to report current power profile. The slide was immediately updated to a wrong value after releasing the mouse button, while the power profile have been changed. Meanwhile, the plasmoid started by plasmawindowed does not have this problem.

STEPS TO REPRODUCE
1. Click "battery" on the status bar
2. Alter the "power profile" slide

OBSERVED RESULT

The slide reports wrong value, while power profile is actually changed.

EXPECTED RESULT

The slide reports correct value indicating current power profile.

SOFTWARE/OS VERSIONS
Linux: Arch Linux, kernel version 6.5.3-arch-1-1 x86_64, fully updated
Graphics: X11
(available in About System)
KDE Plasma Version: 5.27.8
KDE Frameworks Version: 5.110.0
Qt Version: 5.15.10

ADDITIONAL INFORMATION

The video attached contains:
- values from gdbus introspect ..., on Konsole at the top
- a functioning plasmoid started with plasmawindowed, at the left side
- a problematic plasmoid in the status bar, at the right side

It shows:
- When altering with the plasmawindowed plasmoid, everything works just as expected.
- The status bar plasmoid display is bugged, while power values changed.

No error log was produced when tampering with the problematic plasmoid, but when twitching the functioning one, journalctl reports error:

```
file:///usr/share/plasma/plasmoids/org.kde.plasma.battery/contents/ui/PowerProfileItem.qml:108: TypeError: Type error
```
Comment 1 Nate Graham 2023-09-19 18:13:13 UTC
The slider moving back to the previous setting is an upstream bug; see https://gitlab.freedesktop.org/hadess/power-profiles-daemon/-/issues/106.

It also looks like when you have two instances of the widget, their sliders aren't synced; can you still reproduce that issue with only a single instance of the widget?
Comment 2 Natalie Clarius 2023-09-20 00:31:50 UTC
> It also looks like when you have two instances of the widget, their sliders aren't synced

That's not something I can reproduce.
Comment 3 Weihao Jiang 2023-09-20 08:00:20 UTC
Created attachment 161739 [details]
DBus recorded with Wireshark
Comment 4 Weihao Jiang 2023-09-20 08:01:39 UTC
(In reply to Nate Graham from comment #1)
> The slider moving back to the previous setting is an upstream bug; see
> https://gitlab.freedesktop.org/hadess/power-profiles-daemon/-/issues/106.
> 
> It also looks like when you have two instances of the widget, their sliders
> aren't synced; can you still reproduce that issue with only a single
> instance of the widget?

I don't think it is the upstream bug you mentioned, because powerprofilectl can successfully handle the change. 
- By using `Environment="G_MESSAGES_DEBUG=all"` in power-profiles-daemon.service, the debugging log shows that powerprofilectl detects correct profile and internal ACPI changes are not observed.
- As shown in the attachment "Screen capture of battery plasmoid display issue", gdbus reports correct ActiveProfile value. 
- The instance spawned by plasmawindowed (another instance) can handle it successfully.
So I assume that it's not a problem from powerprofilectl.

Another instance is opened as guided through kde wiki "Plasma/Debugging#Check widgets individually" to check the problem, and the slider issue exists can be reproduced without it. 

By checking DBus messages with WireShark, I observed difference from the normal one and the moving slider widget.

Moving slider one, in status bar
```
76	8.503382	:1.22	org.kde.Solid.PowerManagement	D-Bus	245	setProfile() @ /org/kde/Solid/PowerManagement/Actions/PowerProfile
77	8.510215	:1.61	:1.22	D-Bus	56	-> ''
```

Normal one, started with plasmawindowed
```
192	20.867629	:1.485	org.kde.Solid.PowerManagement	D-Bus	245	setProfile() @ /org/kde/Solid/PowerManagement/Actions/PowerProfile
193	20.905039	:1.61		D-Bus	213	* currentProfileChanged() @ /org/kde/Solid/PowerManagement/Actions/PowerProfile
194	20.905057	:1.61	:1.485	D-Bus	56	-> ''
```

I noticed that the line `currentProfileChanged() @ /org/kde/Solid/PowerManagement/Actions/PowerProfile` is missing from the Moving slider one. Sorry that I'm not familiar with dbus, and I can't understand these values. The dbus I captured are put in the attachments "DBus recorded with Wireshark".
Comment 5 Bug Janitor Service 2023-10-05 03:46:31 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 6 Bug Janitor Service 2023-10-20 03:45:24 UTC
This bug has been in NEEDSINFO status with no change for at least
30 days. The bug is now closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

Thank you for helping us make KDE software even better for everyone!