Bug 423556

Summary: Battery icon sometimes indicates that battery is charging when laptop is unplugged
Product: [Plasma] Powerdevil Reporter: kesarling
Component: generalAssignee: kesarling
Status: RESOLVED UPSTREAM    
Severity: normal CC: 61kylyqt, adeptsmail, agurenko, ancapaula.luca, benoitg, bernie, braxner.michael, daniel-other+kdebug, domy.os+kde, dsunter, d_debnath, kde, kdereport.firehalls, kesarling, meven29, mma444, nate, plasma-bugs, porternw.tmp, postix, presnovnikita, sj13183239007, sudhir, thenerdiestguy
Priority: VHI Keywords: regression
Version: 5.18.7   
Target Milestone: ---   
Platform: Debian stable   
OS: Linux   
URL: https://gitlab.freedesktop.org/upower/upower/-/issues/126
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Snaps of the error
Attachment of the screenshot where the bug is glaring at us

Description kesarling 2020-06-26 18:47:23 UTC
SUMMARY

I am using the latest version of KDE-plasma5 on latest Pop!_OS (20.04). The battery Icon in the tray shows undefined behaviour.

There are 2 states to the behaviour:

1. It shows the change (i.e. power has been plugged in/out about an hour later)

2. It remains in the state it was when I powered on my Laptop even when I disconnect/ plugin. (i.e. if it was plugged in at boot time, it keeps showing 
plugged in even when the cord has been disconnected and vice versa.)

Here I would like to note that whenever I hover in the applet, it shows the
current charge of the battery accurately. However, it fails to recognise the state. Also, when I click on the applet, the widget detects the state accurately. 

The annoying part is when the Laptop gets suspended as the applet cannot recognize the battery level (at times it has suspended at 100% battery)

STEPS TO REPRODUCE
1. Plug in the charger
2. Boot the Laptop
3. See the state of the applet
4. Remove the charging cord

OBSERVED RESULT

Undefined Behaviour of the applet in displaying battery charging/discharging status (as mentioned above)


EXPECTED RESULT
Well, do I really need to put anything here? ;)

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: Pop!_OS 
(available in About System)
KDE Plasma Version: 5
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Comment 1 kesarling 2020-06-26 18:48:08 UTC
Created attachment 129706 [details]
Snaps of the error
Comment 2 Kai Uwe Broulik 2020-06-27 08:43:43 UTC
Can you check whether the output of `upower -d` is also falsy? If so, this suggests an issue lower in the stack, also given suspend isn't actually handled by battery monitor.
Comment 3 kesarling 2020-06-27 14:31:49 UTC
The output of `upower -d` is correct. Are you sure this is not a KDE issue? Because this does not happen with Gnome (yeah, I checked this by installing Gnome again)
Comment 4 kesarling 2020-06-27 20:19:51 UTC
(In reply to Kai Uwe Broulik from comment #2)
> Can you check whether the output of `upower -d` is also falsy? If so, this
> suggests an issue lower in the stack, also given suspend isn't actually
> handled by battery monitor.

The wrong displaying does not matter as much as suspending (at times at 100%). Please look into the matter
Comment 5 Nate Graham 2020-07-02 00:38:36 UTC
Works for me, FWIW. I know that's not super helpful for you, but it seems like this is not a universal problem for everyone.
Comment 6 kesarling 2020-07-02 06:50:21 UTC
(In reply to Nate Graham from comment #5)
> Works for me, FWIW. I know that's not super helpful for you, but it seems
> like this is not a universal problem for everyone.

Umm, did you take a look at the screenshot I attached? (Not the U&L question, but at the bottom right corner, where the issue is being seen). Also, what do I do in this case? You know, because I've tried reinstalling even Pop!_OS twice now. Please help as this is really an issue which has been getting on my nerves for about 4 months now. (By the way, this issue was not there before and has occurred after updating.)
Comment 7 kesarling 2020-07-02 06:56:18 UTC
Created attachment 129840 [details]
Attachment of the screenshot where the bug is glaring at us
Comment 8 Nate Graham 2020-07-02 20:14:28 UTC
Yes, I looked at the screenshot. I just can't reproduce it on my own system with my own user account or a new one.
Comment 9 kesarling 2020-07-03 08:15:08 UTC
(In reply to Nate Graham from comment #8)
> Yes, I looked at the screenshot. I just can't reproduce it on my own system
> with my own user account or a new one.

Is something wrong with my hardware in that case? Because this problem actually never occurred before even with KDE. It only started occurring recently. Do I report this to Pop!_OS then?
Comment 10 Nate Graham 2020-07-05 15:17:32 UTC
Just reproduced this. :/
Comment 11 kesarling 2020-07-05 15:28:57 UTC
(In reply to Nate Graham from comment #10)
> Just reproduced this. :/

Great!!! Yay :P !!! Thanks tons for looking into the matter :). Hope it gets fixed soon :D
Comment 12 kesarling 2020-07-06 14:41:31 UTC
(In reply to Nate Graham from comment #10)
> Just reproduced this. :/

Also, please take a look at https://unix.stackexchange.com/a/596984/367116
Comment 13 kesarling 2020-07-16 03:13:58 UTC
Also, if I want to try my hand at fixing the bug, where do I apply?
Comment 14 Nate Graham 2020-07-16 03:15:22 UTC
You don't need to apply anywhere, just fix the bug and send a merge request. :)

https://invent.kde.org/plasma/powerdevil/-/merge_requests

Documentation: https://community.kde.org/Infrastructure/GitLab
Comment 15 kesarling 2020-07-16 03:16:29 UTC
Thanks man. On it now :)
Comment 16 kesarling 2020-07-17 03:02:56 UTC
Oh hey! so the bug wasn't in powerdevil? And has it been fixed in the later versions?(5.18.5+)
Comment 17 Nate Graham 2020-07-17 03:09:22 UTC
It is, I just moved it to the component tracking the powerdevil applet itself.
Comment 18 Stefano 2020-09-10 14:08:09 UTC
Hi everyone, I have a bug that is very similar, except for the conditions of appearance.

In my case, this only happens when the laptop is booted with the AC plugged in. When unplugged, the icon remains (which is not a big issue, but also behaviors are not changed to the desired ones for battery use).

If instead the laptop boots unplugged, plugging in and out works normally.

Also in my case, upower shows the correct information.
Comment 19 Nate Graham 2020-09-10 15:08:49 UTC
I have started to experience this.
Comment 20 Nate Graham 2020-09-10 15:12:10 UTC
The problem seems to be that `pmSource.data["AC Adapter"]["Plugged in"]`, which is used in various places, it continuing to return true after the power cable has ben unplugged, when it should be false.
Comment 21 Nate Graham 2020-09-10 15:20:21 UTC
Data is coming from the powermanagement data engine. The "Plugged in" property doesn't seem to be getting updated when it should be. "Charging" and "Discharging" do get updated, but not "Plugged In".
Comment 22 kesarling 2020-09-10 15:47:18 UTC
I'm getting the feeling that whoever's programmed that part has resorted(??) to UB and has not recognised that ;)
Comment 23 Stefano 2020-09-10 15:48:17 UTC
(In reply to Nate Graham from comment #21)
> Data is coming from the powermanagement data engine. The "Plugged in"
> property doesn't seem to be getting updated when it should be. "Charging"
> and "Discharging" do get updated, but not "Plugged In".

Same here, "Charging" and "Discharging" are correct, "Plugged In" isn't.

And in fact:
Device: /org/freedesktop/UPower/devices/line_power_AC
  native-path:          AC
  power supply:         yes
  updated:              gio 10 set 2020, 17:45:55 (27 seconds ago)
  has history:          no
  has statistics:       no
  line-power
    warning-level:       none
    online:              no
    icon-name:          'ac-adapter-symbolic'
Comment 24 Nate Graham 2020-09-10 16:49:36 UTC
Debugged this a bit with Kai and we think it's a bug in upower itself. I've filed a bug report for them: https://gitlab.freedesktop.org/upower/upower/-/issues/126
Comment 25 Nate Graham 2021-09-24 19:51:42 UTC
*** Bug 442868 has been marked as a duplicate of this bug. ***
Comment 26 Nate Graham 2021-10-19 14:21:23 UTC
*** Bug 361708 has been marked as a duplicate of this bug. ***
Comment 27 Méven Car 2021-10-25 09:04:59 UTC
I believe this needs to be fixed in the kernel drivers.
FYI this is reported at https://bugzilla.kernel.org/show_bug.cgi?id=210425
Comment 28 Nicolas Fella 2021-12-22 20:42:48 UTC
*** Bug 440609 has been marked as a duplicate of this bug. ***
Comment 29 Nicolas Fella 2021-12-22 20:44:22 UTC
*** Bug 447333 has been marked as a duplicate of this bug. ***
Comment 30 Nicolas Fella 2021-12-22 20:45:27 UTC
*** Bug 447327 has been marked as a duplicate of this bug. ***
Comment 31 Nate Graham 2022-01-30 01:51:58 UTC
*** Bug 440609 has been marked as a duplicate of this bug. ***
Comment 32 Nate Graham 2022-02-07 04:49:58 UTC
*** Bug 449728 has been marked as a duplicate of this bug. ***
Comment 33 Nate Graham 2022-02-11 18:14:21 UTC
*** Bug 449937 has been marked as a duplicate of this bug. ***
Comment 34 Nate Graham 2022-02-16 01:30:16 UTC
*** Bug 450126 has been marked as a duplicate of this bug. ***
Comment 35 Nate Graham 2022-03-20 13:47:54 UTC
*** Bug 364260 has been marked as a duplicate of this bug. ***
Comment 36 Nate Graham 2022-05-03 15:17:46 UTC
*** Bug 453139 has been marked as a duplicate of this bug. ***
Comment 37 electw 2022-07-07 17:02:44 UTC
Still an issue in 5.25.2 on Fedora 36. Is there any progress on the issue with upower?
Comment 38 Nate Graham 2022-07-07 17:11:03 UTC
Please don't re-open issues marked as RESOLVED UPSTREAM unless they are found to no longer be upstream issues or are found to be work-around-able in KDE code. See https://community.kde.org/Get_Involved/Issue_Reporting#Understand_what_the_resolution_statuses_mean
Comment 39 Anca Luca 2022-07-13 13:34:21 UTC
I also have the issue on Ubuntu 22.04 with Plasma 5.24.4, Kernel 5.15.0-41-generic .

The flavor of it that I am seeing is that it happens only some times. The times when it works is when I reboot my laptop on battery power. I haven't yet found all cases that cause it to fail, but it definitely does in some cases (and then a reboot on battery is fine).
Comment 40 Nate Graham 2022-12-06 23:44:50 UTC
FWIW the upstream Kernel issue (https://bugzilla.kernel.org/show_bug.cgi?id=210425) seems to finally be fixed for me as of Kernel 6.0.10!
Comment 41 Gurenko Alex 2022-12-07 21:33:51 UTC
(In reply to Nate Graham from comment #40)
> FWIW the upstream Kernel issue
> (https://bugzilla.kernel.org/show_bug.cgi?id=210425) seems to finally be
> fixed for me as of Kernel 6.0.10!

Hm, still happening for me on 6.0.11 (F37) :-(
Comment 42 Nate Graham 2022-12-07 22:29:12 UTC
Interesting, I'm also on F37.

I wonder if it only got fixed for certain hardware? I have a Lenovo ThinkPad X1 Yoga gen 4.
Comment 43 Gurenko Alex 2022-12-08 09:49:30 UTC
(In reply to Nate Graham from comment #42)
> Interesting, I'm also on F37.
> 
> I wonder if it only got fixed for certain hardware? I have a Lenovo ThinkPad
> X1 Yoga gen 4.

Probably yes, however I'm on Lenovo P1 gen2, so it's also Lenovo, but different platform
Comment 44 Yuriy Vidineev 2022-12-28 04:20:41 UTC
Hi. Just want to add my 2 cents: I have the same issue with the latest KDE Neon, Dell Precision 5560 (similar to XPS 15 9510), kernel 6.0.0-1009-oem
Comment 45 jian 2023-11-12 19:46:31 UTC
Happens on my laptop (Dell Inspiron 14 Plus 7420) too, I've tried many distros and all have this problem on Plasma.