After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 609720 - Can sometimes miss idle reset alarm, causing display to blank when it shouldn't do
Can sometimes miss idle reset alarm, causing display to blank when it shouldn...
Status: RESOLVED FIXED
Product: gnome-power-manager
Classification: Deprecated
Component: gnome-power-manager
2.29.x
Other Linux
: Normal normal
: ---
Assigned To: Chris Coulson
GNOME Power Manager Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2010-02-12 03:35 UTC by Chris Coulson
Modified: 2010-03-17 11:19 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
0001-Avoid-a-race-in-detecting-the-idle-reset-alarm.patch (3.50 KB, patch)
2010-02-12 03:35 UTC, Chris Coulson
none Details | Review

Description Chris Coulson 2010-02-12 03:35:03 UTC
Created attachment 153600 [details] [review]
0001-Avoid-a-race-in-detecting-the-idle-reset-alarm.patch

A few people in Ubuntu have reported their display blanking whilst not really idle, and seeing the status icon appear in the notification area which warns about a broken X server (and points to your blog here: http://blogs.gnome.org/hughsie/2009/08/17/gnome-power-manager-and-blanking-removal-of-bodges/) when the display unblanks again.

I've also seen this a couple of times. Firstly, my display dims because I've been idle for a few seconds. I immediately move the mouse, but the display never returns to normal brightness. Eventually, the display blanks momentarily whilst I'm still working and the tooltip tells me that my session isn't idle, but the screen is idle.

This isn't easily reproducible, but when doing some debugging I found a possible race. Basically, what I think might happen is:

1) Idle timeout alarm expires and egg_idletime_event_filter_cb is called
2) User moves mouse, and IDLETIME counter gets reset
3) egg_idletime_set_reset_alarm is called and creates the reset alarm, but we already missed the reset event.

I thought that this might seem far-fetched, as the time between 1 and 3 should be so short that there's no chance of the user performing 2 right in the middle. However, this time can be indeterminate if the kernel preempts gpm here and another task gets some CPU time in-between detecting the initial alarm and creating the reset alarm

I managed to recreate this reliably by adding a "sleep (1)" in between detecting the idle timeout and creating the reset alarm, and moving the mouse within this 1 second period after the display dims.

I've attached a patch which removes this race, and fixes it for the test case above (where I inserted a sleep). The patch creates the reset alarm when creating an EggIdleTime instance, rather than creating it after the idle timeout expires. I've ensured that the instance will not emit a "reset" signal unless the idle timeout alarm has triggered since the reset alarm last expired (so this doesn't change the behaviour of EggIdleTime). As the change means that the reset alarm is not created in response to the idle timeout expiring, the reset timeout has to be set to zero (as opposed to being based on the time of the idle timeout event)
Comment 1 Richard Hughes 2010-02-12 14:35:11 UTC
I agree, good write up. I've committed your patch, many thanks.
Comment 2 Baptiste Mille-Mathias 2010-02-23 21:16:27 UTC
Reopening bug as the patch was reverted.
Comment 3 Jean-François Fortin Tam 2010-02-23 21:20:21 UTC
Uh, you didn't reopen it, you marked it VERIFIED FIXED (but /me is not touching it, don't want to step on toes).
Comment 4 Baptiste Mille-Mathias 2010-02-23 21:23:51 UTC
yeah I know
Comment 5 Baptiste Mille-Mathias 2010-02-23 21:26:05 UTC
and now I can set it NEW, pffewww
Comment 6 Alex Murray 2010-03-03 00:20:08 UTC
Why was this patch reverted out of interest? I can't see any reason given in the git commit for the revert?
Comment 7 Richard Hughes 2010-03-17 09:05:10 UTC
Chris, Looking through http://patches.ubuntu.com/g/gnome-power-manager/gnome-power-manager_2.29.91-0ubuntu6.patch it seems you've fixed the bug a better way. Is there any chance of you submitting this upstream? Ubuntu used to get pretty bad press for not forwarding fixes, and I really hope we're not going back to the bad old days. Thanks.
Comment 8 Chris Coulson 2010-03-17 11:19:57 UTC
I've pushed a fix as commit 0c171b96 now