Closed Bug 842149 Opened 13 years ago Closed 13 years ago

nsIdleService polls too often if an idle listener removes itself

Categories

(Core :: Widget, defect)

defect
Not set
minor

Tracking

()

RESOLVED FIXED
mozilla22

People

(Reporter: Irving, Assigned: Irving)

Details

Attachments

(1 file)

On platforms that support polling for how long the system has been idle (OS/2, GTK, Windows, Qt, OS/X), when a handler that is currently in the idle state deregisters itself from the idle service, the idle service doesn't change its "mAnyObserverIdle" flag. This can lead to the idle service polling the OS for idle status every five seconds, to detect the idle -> user back transition, even though there is no handler waiting for that transition.
This takes the approach of counting the number of idle observers. The alternative approach would be to scan the observer list looking for remaining observers in idle mode, when one is removed.
Attachment #714957 - Flags: review?(justin.lebar+bug)
Gosh, we really need to rewrite this whole file.
> // Find the entry and remove it, if it was the last entry, we just let the > // existing timer run to completion (there might be a new registration in a > // little while. > IdleListenerComparator c; >- if (mArrayListeners.RemoveElement(listener, c)) { >+ nsTArray<IdleListener>::index_type element = mArrayListeners.IndexOf(listener, 0, c); Nit: This is an index, so please don't call it |element|. r=me, I guess. It would take me all day to verify that this patch actually works, but it's hard to imagine how this would make things any worse...
Attachment #714957 - Flags: review?(justin.lebar+bug) → review+
At the risk of stating the obvious, please keep an eye out for regressions after landing this; we don't have a great track record with modifying the idle service.
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla22
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: