Idle service waits for 5000 seconds before checking for user activity when all observers are idle

RESOLVED FIXED in mozilla15



5 years ago
5 years ago


(Reporter: Irving, Assigned: Irving)


Mac OS X
Bug Flags:
in-testsuite -

Firefox Tracking Flags

(Not tracked)



(1 attachment, 1 obsolete attachment)

When the idle service has notified all observers that they system is idle, it sets a timer to wait for a fixed time before it re-checks for user activity and sends out a "back" notification as needed.

Also, add NSPR logging so that users in debug builds can set NSPR_LOG_MODULES=idleService:<level> to get tracing information from the idle service.
Created attachment 614106 [details] [diff] [review]
Fix idle service check interval to be 5 seconds, add PR_LOG tracing

Fix calculation of next user activity poll, when all observers are idle - the previous code was multiplying MIN_IDLE_POLL_INTERVAL_MSEC * PR_USEC_PER_SEC (interval in milliseconds * microseconds per _second_).

Also initialized the "last user activity time" to PR_NOW() at startup to get rid of some anomalous calculations during the first few calls, and removed some special cases that handled the value when it was initialized to 0

Should update documentation to describe how to enable the NSPR logging.
Attachment #614106 - Flags: review?(netzen)
Comment on attachment 614106 [details] [diff] [review]
Fix idle service check interval to be 5 seconds, add PR_LOG tracing

Review of attachment 614106 [details] [diff] [review]:

Sorry for the delay, it looks great. Thanks for the patch.
I'm not a widget peer, but I was previously delegated a patch for the same code so I'll go with it.

nit: Please fix all of the PR_LOG( to be line length 80.
I don't need to re-see it after the line length fixes and member->static global fix, you can just carry forward the r+.

::: widget/xpwidgets/nsIdleService.h
@@ +228,5 @@
> +  /**
> +   * Log service handle
> +   */
> +  PRLogModuleInfo *mLog;

nit: Please move this to the .cpp and make it a static global instead as per the other logging code in /widget.  Also you can surround it with #ifdef PR_LOGGING.  I know it is a service so there is only 1 but might as well stay consistent with the other code.
Attachment #614106 - Flags: review?(netzen) → review+
Created attachment 618807 [details] [diff] [review]
Fix idle service check interval to be 5 seconds, add PR_LOG tracing, v2 with nits picked

Fix :bbondy's commends, (see
Attachment #614106 - Attachment is obsolete: true
Attachment #618807 - Flags: review+
Keywords: checkin-needed
Flags: in-testsuite-
Keywords: checkin-needed
Target Milestone: --- → mozilla15
Last Resolved: 5 years ago
Resolution: --- → FIXED
Was this a regression? When updating Instantbird from Mozilla 11 to Mozilla 12 we stopped receiving "back" notifications when the user is no longer idle. Given the bug description here, it looks like this could be the fix I was looking for.
Seems like something from bug 720493, but the target milestone there is Mozilla 13, and I believe some of our nightly testers reproduced it on Mozilla 12 builds, so I'm not sure.
You need to log in before you can comment on or make changes to this bug.