Bug 287952 - Battery Monitor widget stops tracking charging state changes after suspend/resume cycle
Summary: Battery Monitor widget stops tracking charging state changes after suspend/re...
Status: RESOLVED FIXED
Alias: None
Product: plasma4
Classification: Plasma
Component: widget-battery (show other bugs)
Version: 4.8.95 (RC1)
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
: 289696 302360 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-12-01 00:03 UTC by Thilo-Alexander Ginkel
Modified: 2015-07-15 19:39 UTC (History)
18 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.9


Attachments
screenshot of battery applet and solid-hardware output (258.59 KB, image/png)
2012-05-22 12:37 UTC, Stefan Schwarzer
Details
Patch for powermanagement plasma engine (2.67 KB, patch)
2012-07-05 18:06 UTC, Lukáš Tinkl
Details
QML battery applet patch (4.05 KB, patch)
2012-07-09 14:45 UTC, Lukáš Tinkl
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thilo-Alexander Ginkel 2011-12-01 00:03:22 UTC
Version:           unspecified (using KDE 4.7.2) 
OS:                Linux

After a suspend/resume cycle (ACPI S3) the Battery Monitor widget effectively stops tracking the battery charging state. The battery level reported through /proc/acpi/battery/BAT{0,1}/state is correct, though.

Reproducible: Always

Steps to Reproduce:
Perform a suspend/resume cycle.

Actual Results:  
The Battery Monitor widget locks in at the last known charge level.

Expected Results:  
The Battery Monitor widget updates as the charge level changes.
Comment 1 Thilo-Alexander Ginkel 2011-12-03 11:33:37 UTC
It is good to know that this has been resolved. Would you mind sharing a pointer to the fix so that I can back-port it into me current distribution release?
Comment 2 Ivan Stetsenko 2012-01-10 14:37:18 UTC
In this particular case the bug is marked as resolved because the KDE team thinks, that the actual root of the bug is not within KDE, but somewhere else (and, because of it, should be fixed by, e.g. kernel developers). However, if I'm restarting plasma after suspend-resume (via killall plasma-desktop && plasma-desktop), the applet starts to work in a correct manner. This shows, that all the underlying machinery works fine, and the bug is probably located within plasma itself.
Comment 3 Thilo-Alexander Ginkel 2012-01-10 20:04:17 UTC
Killing Plasma isn't even necessary - removing and adding the widget from the panel is sufficient for it to catch up.

I hope it is ok if I re-open this bug under these circumstances.

P.S.: If you think that this is a distribution-specific bug (Kubuntu in my case) introduced by a distribution patch, please let me know. @Ivan: Which distribution are you using?
Comment 4 Ivan Stetsenko 2012-01-10 20:19:02 UTC
(In reply to comment #3)
I'm using Kubuntu 11.10 as well, so yes, it is possible, that the bug is Kubuntu-specific. I'll try to find someone with another distro who can check it.
Comment 5 Donatas Glodenis 2012-02-05 18:39:01 UTC
My computer (Asus A8F running Kubuntu 11.10 with KDE 4.8 from ppa) is also affected. It was also present when I had KDE 4.7.
Comment 6 Thilo-Alexander Ginkel 2012-03-03 11:20:58 UTC
I am not 100% certain, but I think this happens when I unplug the
power connector while my laptop is suspended.
Comment 7 Diggory Hardy 2012-04-15 17:55:07 UTC
Same problem. Saw it on debian, and seeing it now on OpenSUSE, so it's not ubuntu-specific.
Comment 8 Stefan Schwarzer 2012-05-22 12:37:17 UTC
Created attachment 71293 [details]
screenshot of battery applet and solid-hardware output
Comment 9 Diggory Hardy 2012-05-22 14:04:29 UTC
Just to note it seems to be fine now (on 4.8.x).
Comment 10 Myriam Schweingruber 2012-05-22 14:51:42 UTC
Thank you for the feedback, closing.
Comment 11 Dave Lepore 2012-06-14 09:29:59 UTC
this bug is already reproducible in 4.9 beta1 and beta2
Comment 12 Dave Lepore 2012-06-14 09:32:07 UTC
(In reply to comment #11)
> this bug is already reproducible in 4.9 beta1 and beta2

sorry, I meant "again"
Comment 13 Dave Lepore 2012-06-14 09:33:09 UTC
(In reply to comment #11)
> this bug is already reproducible in 4.9 beta1 and beta2

sorry, I meant "again"
Comment 14 Donatas Glodenis 2012-06-14 12:19:59 UTC
It is also still present in 4.8.3 (Kubuntu Precise packages). I am not quite sure there was a period since original reporting when it was not present.
Comment 15 Christian González 2012-06-20 01:55:37 UTC
Same problem here. Fedora 17 x86_64 + KDE 4.8.90 from kde-redhat unstable repo.
Comment 16 Dave Lepore 2012-06-27 20:20:31 UTC
bug still present in 4.8.95
Comment 17 Lukáš Tinkl 2012-07-04 12:47:03 UTC
Looking into it
Comment 18 Csaba Kertész 2012-07-04 23:26:52 UTC
I have been experiencing this problem since I started to use KUbuntu 32 bit (Natty, Oneiric...) on two different laptops (HP 2510p, Dell E6320). Problem seems to be generic because these laptops have totally different hardware, ACPI data are good and updated on the proc file system, but the Battery Monitor never works after resume.
Comment 19 Csaba Kertész 2012-07-05 08:42:12 UTC
Lukáš: if you or somebody else would point out the related sources in the KDE source tree, I can check those files and fix the bug since it is always reproducable on my machines and it is an annoying thing.
Comment 20 Lukáš Tinkl 2012-07-05 18:06:26 UTC
Created attachment 72336 [details]
Patch for powermanagement plasma engine
Comment 21 Lukáš Tinkl 2012-07-05 18:07:13 UTC
It would be cool if you could test the above patch for kde-workspace :)
Comment 22 Rex Dieter 2012-07-06 16:04:45 UTC
I applied your patch, installed the new plasma_engine_powermanagement.so, restarted my session, suspended... and no luck.  the battery applet still seems stuck and not updating charge status. :(
Comment 23 Csaba Kertész 2012-07-06 17:32:40 UTC
I use KDE 4.7.2, so I could not apply exactly the same patch, but the only difference between my KDE version and yours that the disabled DBus reply is async in your case and sync in KDE 4.7.2.  So I used the following:

        setData("Battery", "Has Battery", !batterySources.isEmpty());
        if (!batterySources.isEmpty()) {
            setData("Battery", "Sources", batterySources);
            /* COMMENT
            QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.Solid.PowerManagement",
                                                              "/org/kde/Solid/PowerManagement",
                                                              "org.kde.Solid.PowerManagement",
                                                              "batteryRemainingTime");
            QDBusPendingReply< int > reply = QDBusConnection::sessionBus().asyncCall(msg);
            reply.waitForFinished();
            if (reply.isValid()) {
                //kDebug() << "Remaining time 1:" << reply.value();
                setData("Battery", "Remaining msec", reply.value());
            }
         COMMENT   */
        }

Results: The patch does not effect anything, the same sympthoms are observed before and after. I publish them to see an exact test cases for the problem:

Test case 1:
------------
1. Laptop is not suspended in this case
2. Pull and reconnect the AC power

Result: The Battery Monitor always works correctly

Test case 2:
------------
1. Laptop on AC power
2. Suspend
3. Pull the AC power
4. Resume on battery power

Result: Battery Monitor shows the battery percentage correctly.

Test case 3:
------------
1. Laptop on battery power
2. Suspend
2. Resume on battery power

Result: Battery Monitor does not work, it is stuck at the same battery percentage.
Comment 24 Lukáš Tinkl 2012-07-09 08:54:55 UTC
Csába, upgrade to 4.8, the code is fixed there, this bug is about 4.9/master.
Comment 25 Lukáš Tinkl 2012-07-09 12:14:29 UTC
The bug is in the battery applet (QML) itself, the powermanagement engine itself is correctly updating the battery charge percent and state, even after suspend/resume.
Comment 26 Lukáš Tinkl 2012-07-09 14:45:47 UTC
Created attachment 72402 [details]
QML battery applet patch
Comment 27 Lukáš Tinkl 2012-07-09 16:23:41 UTC
Git commit ec3ef679d7e186b8f2e5d438c42292d6688084bc by Lukas Tinkl.
Committed on 09/07/2012 at 18:21.
Pushed by lukas into branch 'KDE/4.9'.

fix Battery Monitor widget stops tracking charging state changes after suspend/resume cycle

also fix the description to correctly reflect charging/discharging state

M  +3    -2    plasma/generic/applets/batterymonitor/contents/ui/PopupDialog.qml
M  +21   -8    plasma/generic/applets/batterymonitor/contents/ui/batterymonitor.qml

http://commits.kde.org/kde-workspace/ec3ef679d7e186b8f2e5d438c42292d6688084bc
Comment 28 Lukáš Tinkl 2012-07-09 16:27:02 UTC
Git commit cbfaa5161731e0789b348c9a6ebe67e10d49b190 by Lukas Tinkl.
Committed on 09/07/2012 at 18:21.
Pushed by lukas into branch 'master'.

fix Battery Monitor widget stops tracking charging state changes after suspend/resume cycle

also fix the description to correctly reflect charging/discharging state

M  +3    -2    plasma/generic/applets/batterymonitor/contents/ui/PopupDialog.qml
M  +21   -8    plasma/generic/applets/batterymonitor/contents/ui/batterymonitor.qml

http://commits.kde.org/kde-workspace/cbfaa5161731e0789b348c9a6ebe67e10d49b190
Comment 29 Lukáš Tinkl 2012-07-10 08:27:10 UTC
*** Bug 289696 has been marked as a duplicate of this bug. ***
Comment 30 Juan Xavier 2012-12-01 22:36:15 UTC
Still having this problem on 4.9.3 (archlinux).

Reproducible by going into hibernate with the battery unplugged and resuming the system with just the battery on.
Comment 31 Antony Dovgal 2012-12-30 19:44:08 UTC
The bug is still present in 4.8 branch.
Can't find any QML files for Battery Monitor there, so I assume it's done in a different way and there's no way to apply this patch to 4.8.
Is there a chance to get a patch for 4.8? The bug is quite annoying indeed.
Comment 32 Kai Uwe Broulik 2013-01-19 16:38:49 UTC
*** Bug 302360 has been marked as a duplicate of this bug. ***
Comment 33 Israel Saeta Pérez 2013-06-19 07:46:55 UTC
The bug is still present in KDE 4.9.5, using Linux Mint KDE version and Asus A55V laptop.
Comment 34 Clayton Casciato 2013-07-18 22:46:04 UTC
The bug has always been present for me. I'm using KDE 4.10.5 on Arch Linux. I'm rocking a System76 Lemur Ultra (3rd Gen Intel Core i5). If the laptop is plugged in upon resume, there are no issues. However, if it is not plugged in upon resume, it performs the default "critical battery" option. Additionally, the "30 second notification" pops up, obviously 30 seconds before it does anything (in this case, shutdown/hibernate/suspend upon critical action would be the active action).
Comment 35 Leandro Garber 2015-07-15 19:39:15 UTC
This bug is still present in plasma5/plasmashell. I'm using Arch Linux.

If the battery was charging and then I put the laptop to sleep, then unplug it and wake it up, the icon stays blue and the tooltip reads "charging". Clicking on the icon shows correct information but the icon stays the same.

/sys/class/power_supply/BAT1/status is throwing correct results as well

I also think that this bug is causing low battery notifications not to show up.. but I'll check that out