Closed Bug 2067376 Opened 2 months ago Closed 2 months ago

sIdleMemoryCleanupWantsLaterScheduled is not cleared when the idle purge timer fires

Categories

(Core :: XPCOM, defect)

defect

Tracking

()

RESOLVED FIXED
157 Branch
Tracking Status
firefox157 --- fixed

People

(Reporter: jstutte, Assigned: jstutte)

References

Details

Attachments

(1 external file)

sIdleMemoryCleanupWantsLaterScheduled is set when ScheduleWantsLaterTimer arms the IdleMemoryCleanupWantsLaterCheck timer, and cleared only by CancelIdleMemoryCleanupTimerAndRunner. That timer is TYPE_ONE_SHOT_LOW_PRIORITY, so firing disarms it, but CheckIdleMemoryCleanupNeeded does not clear the flag when it runs as the timer callback. From the first expiry on, the flag claims a timer is armed when none is.

This is a reporting defect only. Both remaining reads guard an nsITimer::Cancel() that is redundant either way, since nsTimerImpl::InitCommon calls gThreadWrapper.RemoveTimer unconditionally. What it does cost:

  • the IdlePurgePeek "WantsLater" marker is gated on the flag, so a WantsLater -> timer -> WantsLater chain is reported once and every re-arm after that is silent;
  • the Done branch is gated on the same flag and claims to cancel a timer or runner when there is nothing left to cancel.

Suggested fix: clear the flag in CheckIdleMemoryCleanupNeeded when aTimer is non-null (it is null for the direct call from MayScheduleIdleMemoryCleanup), after the entry MOZ_ASSERT so that assertion keeps checking the observed state. The Done branch then has to let a timer callback through as well, or it stops reporting the end of an episode.

Noticed while profiling bug 2066416.

Severity: -- → S4

The flag is set when ScheduleWantsLaterTimer arms the WantsLater timer and
cleared only by CancelIdleMemoryCleanupTimerAndRunner. That timer is one shot,
so firing disarms it, but the callback does not clear the flag. From the first
expiry on it claims a timer is armed when none is.

Nothing misbehaves as a result: both remaining reads guard an nsITimer::Cancel()
that InitCommon would do anyway. What suffers is the reporting. The WantsLater
marker is gated on the flag, so a chain of WantsLater answers separated by timer
callbacks is reported once and every re-arm after that is silent, and the Done
branch claims to cancel a timer or runner when there is nothing left to cancel.

Clear the flag when the timer calls us back, after the entry assertion so that
still checks the state as observed. The Done branch has to let a timer callback
through as well or it would stop reporting the end of an episode, and both
marker texts need to stop describing only a first schedule or an actual
cancellation.

Assignee: nobody → jstutte
Status: NEW → ASSIGNED
Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 157 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: