Bug 326332 - On boot and login with ac power battery shows zero when it is full
Summary: On boot and login with ac power battery shows zero when it is full
Status: RESOLVED UPSTREAM
Alias: None
Product: plasma4
Classification: Plasma
Component: widget-battery (show other bugs)
Version: 4.11.2
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-20 16:17 UTC by MikeC
Modified: 2013-10-28 19:03 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Battery indication wrong after boot and login with power cable attached (338.22 KB, Image/jpeg)
2013-10-20 16:19 UTC, MikeC
Details
After unplugging and replugging power cable battery level is correct (339.43 KB, image/jpeg)
2013-10-20 16:20 UTC, MikeC
Details
.xsession-errors (60.46 KB, text/plain)
2013-10-20 16:27 UTC, MikeC
Details

Note You need to log in before you can comment on or make changes to this bug.
Description MikeC 2013-10-20 16:17:43 UTC
Boot with the laptop (Dell Inspiron M4300) running on ac power, and log in to KDE. The battery shows zero charge in the Battery Monitor in the system tray.  Pulling out the dc jack plug to run on internal battery the level recovers to correct within a couple of seconds. Plugging in the dc jack again then shows the correct battery level and that it is connected to ac power.

This occurs with two different kernels - 3.11.6-1 and also 3.12.0-rc6

Reproducible: Always

Steps to Reproduce:
1. Plug in laptop to ac power, boot and login to kde
2.
3.
Actual Results:  
Battery monitor shows zero level incorrectly.

Expected Results:  
Battery monitor should show correct level

Pulling out power cable allows correct battery level within a second or two. Plugging power back in then still shows correct battery level.  So battery level is only incorrect on boot with the power plugged in.

I will attach screenshots showing the incorrect zero level as well as after recovery once the power  cable has been pulled out and plugged back in.
Comment 1 MikeC 2013-10-20 16:19:05 UTC
Created attachment 82972 [details]
Battery indication wrong after boot and login with power cable attached

Screenshot shortly after boot and login
Comment 2 MikeC 2013-10-20 16:20:36 UTC
Created attachment 82973 [details]
After unplugging and replugging power cable battery level is correct

Screenshot showing battery level correct by unplugging and replugging power cable
Comment 3 MikeC 2013-10-20 16:25:46 UTC
In the screenshots attached to this report also displayed is the battery level from /sys/class/power_supply/BAT0/charge_now, which shows that despite the battery showing zero in the monitor widget the system is seeing a correct value.
Comment 4 MikeC 2013-10-20 16:27:14 UTC
Created attachment 82974 [details]
.xsession-errors
Comment 5 MikeC 2013-10-20 16:39:29 UTC
I have just come across this Ubuntu report 

https://bugs.launchpad.net/ubuntu/+source/upower/+bug/1240673

So now I am confused as to whether this is a upower or kde bug?
Comment 6 MikeC 2013-10-20 16:59:37 UTC
The output from upower -d just before and after the unplug/replug of the power cable are:

Prior to unplugging power cable:
$ upower -d
Device: /org/freedesktop/UPower/devices/line_power_AC
  native-path:          AC
  power supply:         yes
  updated:              Sun 20 Oct 2013 17:53:30 BST (39 seconds ago)
  has history:          no
  has statistics:       no
  line-power
    online:             yes

Device: /org/freedesktop/UPower/devices/battery_BAT0
  native-path:          BAT0
  vendor:               SMP
  model:                DELL XD7368
  serial:               3261
  power supply:         yes
  updated:              Sun 20 Oct 2013 17:53:35 BST (34 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               fully-charged
    energy:              57.72 Wh
    energy-empty:        0 Wh
    energy-full:         57.72 Wh
    energy-full-design:  57.72 Wh
    energy-rate:         0.0111 W
    voltage:             12.644 V
    percentage:          0%
    capacity:            92.4615%
    technology:          lithium-ion
  History (charge):
    1382288010  0.000   unknown
  History (rate):
    1382288011  0.011   fully-charged
    1382288010  0.000   unknown

Daemon:
  daemon-version:  0.9.22
  on-battery:      no
  on-low-battery:  no
  lid-is-closed:   no
  lid-is-present:  yes
  is-docked:       no

Then monitoring upower --monitor when the cable is unplugged and replugged:

upower --monitor
Monitoring activity from the power daemon. Press Ctrl+C to cancel.
[17:56:18.973]  device changed:     /org/freedesktop/UPower/devices/battery_BAT0
[17:56:18.973]  device changed:     /org/freedesktop/UPower/devices/line_power_AC
[17:56:19.861]  device changed:     /org/freedesktop/UPower/devices/battery_BAT0
[17:56:20.874]  device changed:     /org/freedesktop/UPower/devices/battery_BAT0
[17:56:21.132]  device changed:     /org/freedesktop/UPower/devices/battery_BAT0
[17:56:21.863]  device changed:     /org/freedesktop/UPower/devices/battery_BAT0
[17:56:22.872]  daemon changed:
[17:56:22.872]  device changed:     /org/freedesktop/UPower/devices/battery_BAT0
[17:56:23.863]  device changed:     /org/freedesktop/UPower/devices/battery_BAT0
[17:56:30.179]  daemon changed:
[17:56:30.179]  device changed:     /org/freedesktop/UPower/devices/battery_BAT0
[17:56:30.179]  device changed:     /org/freedesktop/UPower/devices/line_power_AC
[17:56:30.851]  device changed:     /org/freedesktop/UPower/devices/battery_BAT0
[17:56:31.865]  device changed:     /org/freedesktop/UPower/devices/battery_BAT0
[17:56:32.860]  device changed:     /org/freedesktop/UPower/devices/battery_BAT0
[17:56:33.868]  device changed:     /org/freedesktop/UPower/devices/battery_BAT0
[17:56:34.859]  device changed:     /org/freedesktop/UPower/devices/battery_BAT0
[17:56:35.865]  device changed:     /org/freedesktop/UPower/devices/battery_BAT0
^C
[root@lapmike3 ~]# upower -d
Device: /org/freedesktop/UPower/devices/line_power_AC
  native-path:          AC
  power supply:         yes
  updated:              Sun 20 Oct 2013 17:56:30 BST (21 seconds ago)
  has history:          no
  has statistics:       no
  line-power
    online:             yes

Device: /org/freedesktop/UPower/devices/battery_BAT0
  native-path:          BAT0
  vendor:               SMP
  model:                DELL XD7368
  serial:               3261
  power supply:         yes
  updated:              Sun 20 Oct 2013 17:56:35 BST (16 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               fully-charged
    energy:              52.1367 Wh
    energy-empty:        0 Wh
    energy-full:         57.72 Wh
    energy-full-design:  57.72 Wh
    energy-rate:         24.2202 W
    voltage:             11.959 V
    percentage:          97%
    capacity:            92.4615%
    technology:          lithium-ion
  History (charge):
    1382288182  97.000  discharging
    1382288116  0.000   unknown
  History (rate):
    1382288192  24.220  fully-charged
    1382288191  36.886  fully-charged
    1382288182  24.220  discharging
    1382288116  0.011   fully-charged
    1382288116  0.000   unknown

Daemon:
  daemon-version:  0.9.22
  on-battery:      no
  on-low-battery:  no
  lid-is-closed:   no
  lid-is-present:  yes
  is-docked:       no
Comment 7 MikeC 2013-10-20 19:33:57 UTC
In my systemd journal these may indicate where the problem lies but is the origin in the upower package or kernel:

Oct 20 17:55:16 lapmike3 upowerd[818]: (upowerd:818): UPower-Linux-WARNING **: energy 57.720000 bigger than full 53.368800
Oct 20 17:55:16 lapmike3 upowerd[818]: (upowerd:818): GLib-GObject-WARNING **: value "108.000000" of type 'gdouble' is invalid or out
Oct 20 17:55:16 lapmike3 upowerd[818]: (upowerd:818): GLib-GObject-WARNING **: value "108.000000" of type 'gdouble' is invalid or out
Oct 20 17:55:16 lapmike3 systemd[1]: Started Daemon for power management.
Oct 20 17:55:16 lapmike3 upowerd[818]: (upowerd:818): GLib-GObject-WARNING **: value "108.000000" of type 'gdouble' is invalid or out
Oct 20 17:55:17 lapmike3 upowerd[818]: (upowerd:818): GLib-GObject-WARNING **: value "108.000000" of type 'gdouble' is invalid or out
Oct 20 17:55:18 lapmike3 upowerd[818]: (upowerd:818): GLib-GObject-WARNING **: value "108.000000" of type 'gdouble' is invalid or out
Oct 20 17:55:19 lapmike3 upowerd[818]: (upowerd:818): GLib-GObject-WARNING **: value "108.000000" of type 'gdouble' is invalid or out
Oct 20 17:55:20 lapmike3 upowerd[818]: (upowerd:818): GLib-GObject-WARNING **: value "108.000000" of type 'gdouble'
Comment 8 MikeC 2013-10-21 09:35:58 UTC
Further comparison between acpi, upower and /sys/proc/xx output before and after the power cable has been replugged indicates that there is a bug in the upower package. The key output is as follows:

Immediately after boot the result of the commands are as follows:

[mike@lapmike3 ~]$ acpi -b
Battery 0: Full, 100%
[mike@lapmike3 ~]$ upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep percentage
    percentage:          0%
[mike@lapmike3 ~]$ cat /sys/class/power_supply/BAT0/charge_*
4808000
5200000
5200000

and after unplugging and replugging the power cable the same commands give:
[mike@lapmike3 ~]$ acpi -b
Battery 0: Full, 100%
[mike@lapmike3 ~]$ upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep percentage
    percentage:          95%
[mike@lapmike3 ~]$ cat /sys/class/power_supply/BAT0/charge_*
4808000
5200000
5200000

So it is upower that is incorrectly reporting the battery percentage immediately after boot and presumably that is the parameter that the KDE widget is using. I will test once I have access to the new version of upower 0.9.23 and if the problem remains will then report upstream.
Comment 9 Kai Uwe Broulik 2013-10-22 20:56:10 UTC
Thanks very much for triaging it down.
As I can see on your upower -d output this is an upstream upower issue since we just use the value upower provides. And if upower says the battery is empty, we can't tell if it's not.
Please go ahead and file a bug against upower and/or test with a newer version if available. :-)
Comment 10 MikeC 2013-10-23 13:35:00 UTC
OK Kai, I will test as soon as the newer upower package becomes available in archlinux, and then will report back here. If upower 0.9.23 does not provide a fix then I will report upstream and add a comment to this thread.
Comment 11 MikeC 2013-10-24 20:54:42 UTC
This evening the problem is resolved after the following archlinux packages were updated:
( 1/15) upgrading curl                                                          [##############################################] 100%
( 2/15) upgrading dialog                                                        [##############################################] 100%
( 3/15) upgrading faad2                                                         [##############################################] 100%
( 4/15) upgrading jasper                                                        [##############################################] 100%
( 5/15) upgrading lcms2                                                         [##############################################] 100%
( 6/15) upgrading libarchive                                                    [##############################################] 100%
( 7/15) upgrading libmad                                                        [##############################################] 100%
( 8/15) upgrading libmng                                                        [##############################################] 100%
( 9/15) upgrading lua51-socket                                                  [##############################################] 100%
(10/15) upgrading qt4                                                           [##############################################] 100%
(11/15) upgrading shadow                                                        [##############################################] 100%
(12/15) upgrading util-linux                                                    [##############################################] 100%
New optional dependencies for util-linux
    python: python bindings to libmount [installed]
(13/15) upgrading systemd                                                       [##############################################] 100%
(14/15) upgrading sysvinit-tools                                                [##############################################] 100%
(15/15) upgrading systemd-sysvcompat                                            [##############################################] 100%

The battery indication in the KDE widget is now working perfectly normally, even though upower was not among the updates!  Hence this is resolved but not for the reason I expected! I don't know which of the packages in the list above made the fix but all is well (this was confirmed on a second and different laptop which was exhibiting the same issue - a Dell D610).
Comment 12 MikeC 2013-10-28 19:03:13 UTC
It turned out that there was still a battery indication problem due to a bug in upower in the situation where the battery was "over"full.  This is now resolved fully in the archlinux package version upower 0.9.23-2.

The upstream report where this was discussed is at https://bugs.freedesktop.org/show_bug.cgi?id=70952