GNOME Bugzilla – Bug 349842
does not detect changed ac state during suspend or hibernate
Last modified: 2012-03-16 11:04:09 UTC
Please describe the problem: When the AC state changes while the computer is in hibernated or suspended state, gnome-power-manager will not detect the change the next time the system is resumed. Not only does it show wrong information in the icon, for example: it will show that you are running on AC power while you actually are running on batteries), it will not warn you if battery is running out, and will not run the right action you have configured to do when battery is running out. Steps to reproduce: 1. Hibernate computer while connected to AC 2. Disconnect AC 3. Resume computer Actual results: gnome-power-manager still acts like you are running on AC Expected results: show you are running on batteries, warn user is battery runs out, and suspend or hibernate as user has instructed to do in settings. Does this happen every time? Yes Other information: Filed for Mandriva as http://qa.mandriva.com/show_bug.cgi?id=23603
Do you get output from 'lshal -m | grep battery' after you have hibernated?
Currently the gnome-power-manager is showing that I'm connected to AC adapter (which is correct), but the tooltip is showing: Computer is running on battery power Laptop battery 55 minutes until charged (34%) I guess the inconsistencies are clear :-) Ten minutes ago, gnome-power-manager suspended my system, alhtough I have set it not to suspend when running on AC. lshal -m | grep battery seems to hang. part of strace: gettimeofday({1157205151, 623931}, NULL) = 0 writev(3, [{"l\1\0\1\36\0\0\0\22\0\0\0\237\0\0\0\1\1o\0&\0\0\0/org/"..., 176}, {"\31\0\0\0battery.reporting.current\0", 30}], 2) = 206 gettimeofday({1157205151, 646980}, NULL) = 0 poll([{fd=3, events=POLLIN, revents=POLLIN}], 1, 25000) = 1 read(3, "l\2\1\1\4\0\0\0\'\1\0\0.\0\0\0\6\1s\0\5\0\0\0:1.48\0\0"..., 2048) = 68 read(3, 0x804fa38, 2048) = -1 EAGAIN (Resource temporarily unavailable) I guess that seems to be a hal or dbus problem?
Hm, I guess the previous comment should be ignored, could it be that it takes somes time before lshal -m gives some output? I got this now # lshal -m Start monitoring devicelist: ------------------------------------------------- acpi_BAT0 property battery.remaining_time = 2882 (0xb42) acpi_BAT0 property battery.charge_level.rate = 30936 (0x78d8) acpi_BAT0 property battery.charge_level.current = 18550 (0x4876) acpi_BAT0 property battery.voltage.current = 12075 (0x2f2b) acpi_BAT0 property battery.reporting.rate = 30936 (0x78d8) acpi_BAT0 property battery.reporting.current = 18550 (0x4876) afterwards, it seems to hang, but maybe that's normal because it's monitoring until you press Ctrl-C?
Hmm. Can you do: killall gnome-power-manager gnome-power-manager --verbose --no-daemon And then try to get the laptop into this confused state. Please then attach the output spew to this bug please.
Created attachment 72618 [details] gnome-power-manager verbose log
Some explanation about the log: - When gnome-power-manager was started, the machine was running on batteries - I suspend the machine at about 16:48:33 - When it has gone to sleep, I wake it up (about half a minute later) Notice that it correctly detects that the batter is not discharging anymore: [battery_kind_cache_debug_print] gpm-power.c:505 (16:49:06): discharge 0 remaining 0 But: [gpm_power_get_status_summary] gpm-power.c:1300 (16:49:06): tooltip: Computer is running on battery power Laptop battery fully charged (97%) and immediately thereafter: [battery_status_changed_primary] gpm-manager.c:1999 (16:49:06): Laptop battery is not discharging
Forgot to add that I plugged in AC adapter while the machine was sleeping, so the real situation after wake-up is that it's not running on batteries anymore.
Does this happen with 2.16.0?
Yes, this is with Mandriva Cooker 2007.0, which contains 2.16.0 now.
Are you stopping the hal service when you suspend and restarting it when you resume? This might be a "feature" in the Mandrake suspend scripts.
Yes, Mandriva restarts hal after wake-up from suspend. Why would this be any problem? I cannot understand why gnome-power-manager first succeeds in detecting the correct state, while immediately thereafter, it says the completely opposite.
Because restarting HAL whilst resuming is a bad idea IMO. HAL will not broadcast events if it is not running, and it looks like you are hitting the race where: kernel resume hal is stopped kacpid sends events {g-p-m resumes at some point} {hal is fully started (takes a couple of seconds)} Why do you restart HAL when you resume? It works fine on all the fedora and ubuntu systems I've tried so I don't think it's working around any HAL bugs. If you comment out the HAL restart, does everything work okay? Richard.
OK the hal restarting might not be needed and as I don't know much about it I won't comment on it :) However, I remember you have code to handle hal stopping/coming back, so I think there is an issue somewhere. For now some time, but I don't know if this is a new bug as I changed laptop and this might be why I didn't face it before, after resume battery state is only updated once, and then gets updated once each time I restart hal but not while it is running. I noticed that after resume, gnome-power-manager tries to connect 2 times to hal, and finds the same battery twice (and exposes me it twice, but without updating it sate) : [dbus_name_owner_changed] gpm-dbus-system-monitor.c:86 (23:17:46): emitting name-owner-changed : :1.18 (:1.18->) [dbus_name_owner_changed] gpm-dbus-system-monitor.c:86 (23:17:46): emitting name-owner-changed : :1.18 (:1.18->) [dbus_name_owner_changed] gpm-dbus-system-monitor.c:86 (23:17:50): emitting name-owner-changed : :1.19 (->:1.19) [dbus_name_owner_changed] gpm-dbus-system-monitor.c:86 (23:17:50): emitting name-owner-changed : :1.19 (->:1.19) [dbus_name_owner_changed] gpm-dbus-system-monitor.c:86 (23:17:50): emitting name-owner-changed : org.freedesktop.Hal (->:1.19) ** (gnome-power-manager:26265): DEBUG: emitting daemon-start [gpm_hash_new_kind_cache] gpm-power.c:1711 (23:17:50): creating cache [gpm_hash_new_device_cache] gpm-power.c:1745 (23:17:50): creating cache [coldplug_all] gpm-hal-monitor.c:439 (23:17:50): coldplugging all devices [gpm_hal_device_watch_propery_modified] gpm-hal.c:860 (23:17:50): Device is already being watched for PropertyModified: /org/freedesktop/Hal/devices/acpi_BAT0 [watch_add_battery] gpm-hal-monitor.c:285 (23:17:50): emitting battery-added : /org/freedesktop/Hal/devices/acpi_BAT0 [hal_battery_added_cb] gpm-power.c:1591 (23:17:50): Battery Added: /org/freedesktop/Hal/devices/acpi_BAT0 [add_battery] gpm-power.c:1521 (23:17:50): adding /org/freedesktop/Hal/devices/acpi_BAT0 [gpm_hal_device_get_int] gpm-hal.c:613 (23:17:50): No property battery.remaining_time on device with id /org/freedesktop/Hal/devices/acpi_BAT0 [gpm_hal_device_get_string] gpm-hal.c:570 (23:17:50): No property info.vendor on device with id /org/freedesktop/Hal/devices/acpi_BAT0 [battery_kind_cache_update] gpm-power.c:997 (23:17:50): 1 devices of type Batterie d'ordinateur portable [battery_kind_cache_update] gpm-power.c:1035 (23:17:50): emitting battery-status-changed : Batterie d'ordinateur portable [get_stock_id] gpm-manager.c:427 (23:17:50): Trying CRITICAL icon: primary, ups, mouse, keyboard [get_stock_id] gpm-manager.c:451 (23:17:50): Trying CHARGING icon: primary, ups [get_stock_id] gpm-manager.c:468 (23:17:50): Trying PRESENT icon: primary, ups [gpm_power_get_icon_from_status] gpm-power.c:906 (23:17:50): got filename: gpm-primary-charged [tray_icon_update] gpm-manager.c:510 (23:17:50): Going to use stock id: gpm-primary-charged [gpm_tray_icon_set_image_from_stock] gpm-tray-icon.c:213 (23:17:50): Setting icon to gpm-primary-charged [gpm_power_get_status_summary] gpm-power.c:1300 (23:17:50): tooltip: L'ordinateur est branché sur le secteur Batterie d'ordinateur portable complÚtement chargée (98%) [battery_status_changed_primary] gpm-manager.c:1999 (23:17:50): Batterie d'ordinateur portable is not discharging [battery_kind_cache_debug_print] gpm-power.c:495 (23:17:50): Device : Batterie d'ordinateur portable [battery_kind_cache_debug_print] gpm-power.c:497 (23:17:50): number 1 design 47520 [battery_kind_cache_debug_print] gpm-power.c:499 (23:17:50): present 1 last_full 27440 [battery_kind_cache_debug_print] gpm-power.c:501 (23:17:50): percent 98 current 27050 [battery_kind_cache_debug_print] gpm-power.c:503 (23:17:50): charge 0 rate (raw) 0 [battery_kind_cache_debug_print] gpm-power.c:505 (23:17:50): discharge 0 remaining 0 [battery_kind_cache_debug_print] gpm-power.c:507 (23:17:50): capacity 0 [gpm_hal_device_watch_propery_modified] gpm-hal.c:860 (23:17:50): Device is already being watched for PropertyModified: /org/freedesktop/Hal/devices/acpi_AC [gpm_hal_device_watch_condition] gpm-hal.c:939 (23:17:50): Device is already being watched for NewCondition: /org/freedesktop/Hal/devices/acpi_SLPB [gpm_hal_device_watch_propery_modified] gpm-hal.c:860 (23:17:50): Device is already being watched for PropertyModified: /org/freedesktop/Hal/devices/acpi_SLPB [gpm_hal_device_watch_condition] gpm-hal.c:939 (23:17:50): Device is already being watched for NewCondition: /org/freedesktop/Hal/devices/acpi_PWRF [gpm_hal_device_watch_propery_modified] gpm-hal.c:860 (23:17:50): Device is already being watched for PropertyModified: /org/freedesktop/Hal/devices/acpi_PWRF [gpm_hal_device_watch_condition] gpm-hal.c:939 (23:17:50): Device is already being watched for NewCondition: /org/freedesktop/Hal/devices/acpi_LID [gpm_hal_device_watch_propery_modified] gpm-hal.c:860 (23:17:50): Device is already being watched for PropertyModified: /org/freedesktop/Hal/devices/acpi_LID [gpm_hal_device_watch_condition] gpm-hal.c:939 (23:17:50): Device is already being watched for NewCondition: /org/freedesktop/Hal/devices/platform_i8042_i8042_Kbd_Port_logicaldev_input [gpm_hal_device_watch_propery_modified] gpm-hal.c:860 (23:17:50): Device is already being watched for PropertyModified: /org/freedesktop/Hal/devices/platform_i8042_i8042_Kbd_Port_logicaldev_input [battery_kind_cache_update_all] gpm-power.c:1059 (23:17:50): Updating all device types [battery_kind_cache_update] gpm-power.c:997 (23:17:50): 1 devices of type Batterie d'ordinateur portable [battery_kind_cache_update] gpm-power.c:1035 (23:17:50): emitting battery-status-changed : Batterie d'ordinateur portable [get_stock_id] gpm-manager.c:427 (23:17:50): Trying CRITICAL icon: primary, ups, mouse, keyboard [get_stock_id] gpm-manager.c:451 (23:17:50): Trying CHARGING icon: primary, ups [get_stock_id] gpm-manager.c:468 (23:17:50): Trying PRESENT icon: primary, ups [gpm_power_get_icon_from_status] gpm-power.c:906 (23:17:50): got filename: gpm-primary-charged [tray_icon_update] gpm-manager.c:510 (23:17:50): Going to use stock id: gpm-primary-charged [gpm_power_get_status_summary] gpm-power.c:1300 (23:17:50): tooltip: L'ordinateur est branché sur le secteur Batterie d'ordinateur portable complÚtement chargée (98%) [battery_status_changed_primary] gpm-manager.c:1999 (23:17:50): Batterie d'ordinateur portable is not discharging [get_stock_id] gpm-manager.c:427 (23:17:50): Trying CRITICAL icon: primary, ups, mouse, keyboard [get_stock_id] gpm-manager.c:451 (23:17:50): Trying CHARGING icon: primary, ups [get_stock_id] gpm-manager.c:468 (23:17:50): Trying PRESENT icon: primary, ups [gpm_power_get_icon_from_status] gpm-power.c:906 (23:17:50): got filename: gpm-primary-charged [tray_icon_update] gpm-manager.c:510 (23:17:50): Going to use stock id: gpm-primary-charged [gpm_power_get_status_summary] gpm-power.c:1300 (23:17:50): tooltip: L'ordinateur est branché sur le secteur Batterie d'ordinateur portable complÚtement chargée (98%) [dbus_name_owner_changed] gpm-dbus-system-monitor.c:86 (23:17:50): emitting name-owner-changed : org.freedesktop.Hal (->:1.19) ** (gnome-power-manager:26265): DEBUG: Trying to connect already connected hal ** (gnome-power-manager:26265): DEBUG: emitting daemon-start [coldplug_all] gpm-hal-monitor.c:439 (23:17:50): coldplugging all devices [gpm_hal_device_watch_propery_modified] gpm-hal.c:860 (23:17:50): Device is already being watched for PropertyModified: /org/freedesktop/Hal/devices/acpi_BAT0 [watch_add_battery] gpm-hal-monitor.c:285 (23:17:50): emitting battery-added : /org/freedesktop/Hal/devices/acpi_BAT0 [hal_battery_added_cb] gpm-power.c:1591 (23:17:50): Battery Added: /org/freedesktop/Hal/devices/acpi_BAT0 [add_battery] gpm-power.c:1521 (23:17:50): adding /org/freedesktop/Hal/devices/acpi_BAT0 [gpm_hal_device_get_int] gpm-hal.c:613 (23:17:50): No property battery.remaining_time on device with id /org/freedesktop/Hal/devices/acpi_BAT0 [gpm_hal_device_get_string] gpm-hal.c:570 (23:17:50): No property info.vendor on device with id /org/freedesktop/Hal/devices/acpi_BAT0 [battery_kind_cache_update] gpm-power.c:997 (23:17:50): 2 devices of type Batterie d'ordinateur portable [battery_kind_cache_update] gpm-power.c:1035 (23:17:50): emitting battery-status-changed : Batterie d'ordinateur portable [get_stock_id] gpm-manager.c:427 (23:17:50): Trying CRITICAL icon: primary, ups, mouse, keyboard [get_stock_id] gpm-manager.c:451 (23:17:50): Trying CHARGING icon: primary, ups [get_stock_id] gpm-manager.c:468 (23:17:50): Trying PRESENT icon: primary, ups [gpm_power_get_icon_from_status] gpm-power.c:906 (23:17:50): got filename: gpm-primary-charged [tray_icon_update] gpm-manager.c:510 (23:17:50): Going to use stock id: gpm-primary-charged [gpm_power_get_status_summary] gpm-power.c:1300 (23:17:50): tooltip: L'ordinateur est branché sur le secteur Batterie d'ordinateur portable complÚtement chargée (98%) [battery_status_changed_primary] gpm-manager.c:1999 (23:17:50): Batterie d'ordinateur portable is not discharging [battery_kind_cache_debug_print] gpm-power.c:495 (23:17:50): Device : Batterie d'ordinateur portable [battery_kind_cache_debug_print] gpm-power.c:497 (23:17:50): number 2 design 95040 [battery_kind_cache_debug_print] gpm-power.c:499 (23:17:50): present 1 last_full 54880 [battery_kind_cache_debug_print] gpm-power.c:501 (23:17:50): percent 98 current 54100 [battery_kind_cache_debug_print] gpm-power.c:503 (23:17:50): charge 0 rate (raw) 0 [battery_kind_cache_debug_print] gpm-power.c:505 (23:17:50): discharge 0 remaining 0 [battery_kind_cache_debug_print] gpm-power.c:507 (23:17:50): capacity 0 [gpm_hal_device_watch_propery_modified] gpm-hal.c:860 (23:17:50): Device is already being watched for PropertyModified: /org/freedesktop/Hal/devices/acpi_AC [gpm_hal_device_watch_condition] gpm-hal.c:939 (23:17:50): Device is already being watched for NewCondition: /org/freedesktop/Hal/devices/acpi_SLPB [gpm_hal_device_watch_propery_modified] gpm-hal.c:860 (23:17:50): Device is already being watched for PropertyModified: /org/freedesktop/Hal/devices/acpi_SLPB [gpm_hal_device_watch_condition] gpm-hal.c:939 (23:17:50): Device is already being watched for NewCondition: /org/freedesktop/Hal/devices/acpi_PWRF [gpm_hal_device_watch_propery_modified] gpm-hal.c:860 (23:17:50): Device is already being watched for PropertyModified: /org/freedesktop/Hal/devices/acpi_PWRF [gpm_hal_device_watch_condition] gpm-hal.c:939 (23:17:50): Device is already being watched for NewCondition: /org/freedesktop/Hal/devices/acpi_LID [gpm_hal_device_watch_propery_modified] gpm-hal.c:860 (23:17:50): Device is already being watched for PropertyModified: /org/freedesktop/Hal/devices/acpi_LID [gpm_hal_device_watch_condition] gpm-hal.c:939 (23:17:50): Device is already being watched for NewCondition: /org/freedesktop/Hal/devices/platform_i8042_i8042_Kbd_Port_logicaldev_input [gpm_hal_device_watch_propery_modified] gpm-hal.c:860 (23:17:50): Device is already being watched for PropertyModified: /org/freedesktop/Hal/devices/platform_i8042_i8042_Kbd_Port_logicaldev_input [battery_kind_cache_update_all] gpm-power.c:1059 (23:17:50): Updating all device types [battery_kind_cache_update] gpm-power.c:997 (23:17:50): 2 devices of type Batterie d'ordinateur portable [battery_kind_cache_update] gpm-power.c:1035 (23:17:50): emitting battery-status-changed : Batterie d'ordinateur portable [get_stock_id] gpm-manager.c:427 (23:17:50): Trying CRITICAL icon: primary, ups, mouse, keyboard [get_stock_id] gpm-manager.c:451 (23:17:50): Trying CHARGING icon: primary, ups [get_stock_id] gpm-manager.c:468 (23:17:50): Trying PRESENT icon: primary, ups [gpm_power_get_icon_from_status] gpm-power.c:906 (23:17:50): got filename: gpm-primary-charged [tray_icon_update] gpm-manager.c:510 (23:17:50): Going to use stock id: gpm-primary-charged [gpm_power_get_status_summary] gpm-power.c:1300 (23:17:50): tooltip: L'ordinateur est branché sur le secteur Batterie d'ordinateur portable complÚtement chargée (98%) [battery_status_changed_primary] gpm-manager.c:1999 (23:17:50): Batterie d'ordinateur portable is not discharging [get_stock_id] gpm-manager.c:427 (23:17:50): Trying CRITICAL icon: primary, ups, mouse, keyboard [get_stock_id] gpm-manager.c:451 (23:17:50): Trying CHARGING icon: primary, ups [get_stock_id] gpm-manager.c:468 (23:17:50): Trying PRESENT icon: primary, ups [gpm_power_get_icon_from_status] gpm-power.c:906 (23:17:50): got filename: gpm-primary-charged [tray_icon_update] gpm-manager.c:510 (23:17:50): Going to use stock id: gpm-primary-charged [gpm_power_get_status_summary] gpm-power.c:1300 (23:17:50): tooltip: L'ordinateur est branché sur le secteur Batterie d'ordinateur portable complÚtement chargée (98%) ** (gnome-power-manager:26265): DEBUG: rescanning buttons So, I think there is something wrong with hal proxy code and even if not restarting hal at suspend time can be a simple workaround, there is really a bug . Maybe the issue is only that daemon-start is emitted while already connected, so coldplugging is done again without proper initialization but that's only a wild guess as I did not look into the code recently.
Can you try with CVS HEAD or 2.17.1? I recently re-wrote all the proxy code to be bullet proof in a new module.
Created attachment 73008 [details] log when restarting Hal with CVS version The behaviour changed but the result did not improve. Looks like coldplugging of devices no longer occurs after reconnecting, and events are still not received. This log is when just restarting hal, as the log is the same when suspending.
No events are recieved? Do you get events from "lshal -m" on the console after restarting (i.e. is it hal not sending the events, or g-p-m not listening) R.
lshal -m shows the events, so g-p-m is not listening to them
Created attachment 73020 [details] [review] test patch Can you try applying this patch to head please. This seems to make g-p-m "do the right thing" on startup. You were right btw, g-p-m was sending a proxy false signal on connection and disconection! This patch should bullet proof everything. Richard.
Great ! Now works fine for me :)
2006-09-19 Richard Hughes <richard@hughsie.com> * src/gpm-hal-monitor.c: * src/gpm-hal.c: * src/gpm-hal.h: Bullet-proof the hal interface so we automatically connect up the device DeviceCondition and PropertyChanged on HAL restart. This fixes #349842 where HAL wasn't detecting the charge correctly on resume. Thanks to Pascal Terjan for help with the bug. * src/gpm-proxy.c: Fix a silly typo where we were emmiting PROXY_STATUS FALSE on both connection and disconnection. THANKS for all your help with fixing this. Richard.
Is it possible to fix this problem in 2.16 branch?
Frederik, the proxy code in 2-16 is pretty rubbish (i.e. it doesn't use the GpmProxy generic class) but I do still think it's an important fix. If I get a chance this week I'll try to backport the changes.
Thanks for trying to backport this patch to 2.16 branch
Pacho, are you able to the the 2-16 cvs branch for me?
Created attachment 75209 [details] [review] Force watching a device even if we where already I have a dirty patch here for 2.16 that I was planning to apply to Mandriva package if you don't write a beautiful one :-) It juste enforces watching the device in all cases as I don't know a simple way to know that we are re-attaching to Hal.
Pascal, what about just clearing hal->priv->watch_device_property_modified on the hal proxy lost?
Hmm I feel stupid :-)
(In reply to comment #24) > Pacho, are you able to the the 2-16 cvs branch for me? > Sorry, I am not a programmer :'(
Created attachment 75310 [details] [review] Empty the lists on disconnect Better like this
Thats for that Pascal. Does that fix the resume state issue for you? If the answer is yes then please commit to 2-16. Thanks.
It fixes it for me. I'll create a Mandriva package for it tonight so that frederik can test it before I commit.
Commited
As noted already on the Mandriva bugzilla, this bug is not fixed completely. Start up computer on batteries, suspend to disk, connect it to AC, and wake up the computer. The gnome-power-manager icon will correctly show that it is connected to AC power, but the tooltip still says we are running on batteries! This seems still the same behaviour I mentioned in comment #6.
Frederik, are you using a >= 0.5.8 HAL, a kernel >= 2.6.19rc2 and gnome-power-manager >= 2.16.2? Richard.
[frederik@nova Mandriva]$ rpm -q gnome-power-manager hal gnome-power-manager-2.16.1-2mdv2007.1 hal-0.5.8.1-3mdv2007.1 [frederik@nova Mandriva]$ uname -a Linux nova 2.6.17.13-tmb-desktop-1mdv #1 Mon Sep 11 00:45:16 CEST 2006 i686 Intel(R) Pentium(R) M processor 1.86GHz GNU/Linux The gnome-power-manager 2.16.1 RPM I'm using, containts the patch by Pascal Terjan. Why would I need Linux > 2.16.19rc2? Simply restarting gnome-power-manager, fixes the tooltip problem, so it does not seem kernel related... How come the tooltip is inconsistent with the icon? Are there two different code paths for determining the AC state in gnome power manager?
Does this bug still apply with the latest 2-18 code and a new kernel? Thanks.
(In reply to comment #34) > Frederik, are you using a >= 0.5.8 HAL, a kernel >= 2.6.19rc2 and > gnome-power-manager >= 2.16.2? > > Richard. > I have tested with a 2.6.20 kernel and the problem persists, but I don't have hal-0.5.8, seems that there are some problems: http://bugs.gentoo.org/show_bug.cgi?id=151495
I am reopening this issue as the question in comment #36 has been answered in comment #37. Also I'm marking both patches as committed as per comment #20 and comment #32.