GNOME Bugzilla – Bug 625019
idle timer not reset when screensaver is enabled
Last modified: 2016-09-13 23:11:34 UTC
Created attachment 166371 [details] local copy of patch From downstream bug report: Gnome Screensaver activates when the Gnome Session Manager's Presence module (gsm-presence.c) sends a StatusChanged signal over DBus. This signal is sent when an idle watch timer expires. When the timer expires and sends the signal, it needs to be reset. One code path to reset it is triggered when the screensaver activates or deactivates. (Notification of this is via DBus message.) Otherwise, resets are triggered by calls from gsm-manager.c that happen when a) the GConf key corresponding to screensaver timeout is changed (e.g., when the user changes the timeout in the preferences dialog), or b) an inhibitor is added or removed (e.g., when you watch a movie in vlc). So, if the screensaver is disabled when the idle timer expires, nothing will be able to reset the idle timer. Furthermore, when the user re-enables the screensaver, the timer is still inactive, so the screensaver won't be called. Only by taking some special action, such as logging out&in, changing the screensaver timeout, or manually activating a screensaver, will the timer be re-activated. I have fixed this by adding a callback in gsm-manager.c that watches for changes to the GConf key corresponding to the screensaver being enabled (/apps/gnome-screensaver/idle_activation_enabled). When this GConf key is changed, the idle watch timer is reset. Original Bug: https://bugs.launchpad.net/ubuntu/+source/gnome-screensaver/+bug/241206/comments/16
I am the original writer of the above patch. While that patch does fix a code path which results in the idle watch timer not being reset, it has not fully fixed this bug. There still appears to be a race condition in which the idle watch timer is sometimes not being reset. Try as I have, I have not been able to isolate the exact reason for it. However, I have a work-around that seems to fix the problem fully. It is the fairly ugly solution of calling reset_idle_watch from within the on_idle_timeout callback. While it might not be elegant, it does guarantee that the idle timeout is always reset. I have tested this patch on two machines for nearly the last 3 months, and not once has my session failed to go idle, and activate the screensaver, when it was supposed to. Furthermore, I have watched for any undesirable behavior from the screensaver or session (such as, screensaver deactivating without activity, session going idle when active, high processor usage, etc.) and have seen no undesirable activity. The following patch does *not* supercede the previous patch. For the full fix, both patches are required. The following patch (as well as the above one) is made against Ubuntu gnome-session 2.30.0-0ubuntu1. I would redo the patch if necessary against your trunk, but I don't know where to get that.
Created attachment 171871 [details] [review] Guarantee idle watch timer is reset every time it times out This patch calls reset_idle_watch from within on_idle_timeout to guarantee that it is reset every time. This fixes a Heisenbug in which sometimes the idle watch timer is not reset, which causes the session to never timeout. Among the other undesirable effects of this bug, the screensaver will never timeout, which risks both security issues and physical damage to monitors.
(In reply to rlange from comment #1) > The following patch does *not* supercede the previous patch. For the full > fix, both patches are required. So, the first patch is clearly obsolete as it depends on gconf. I'm going to mark the second patch accordingly, to remove it from the request queue in the meantime. Sorry for the super slow response time on this. :(
I switched from Gnome 2 (under which this bug was filed) to Unity, to Gnome 3, which I use presently. I haven't observed this bug in years. I suggest it be closed.
OK thanks!