Bug 1721667 - Move idle timeouts to active on freeze. r=peterv

To avoid handling Timeouts without a valid mWhen when TimeoutManager
is notified that a load is complete, but where the inner window is
potentially frozen we preemptively move then in Freeze.

Differential Revision: https://phabricator.services.mozilla.com/D193450
This commit is contained in:
Andreas Farre 2023-11-14 15:58:17 +00:00
parent 7e60ac48dc
commit 5388421dd7

View file

@ -1125,6 +1125,20 @@ void TimeoutManager::Resume() {
void TimeoutManager::Freeze() {
MOZ_LOG(gTimeoutLog, LogLevel::Debug, ("Freeze(TimeoutManager=%p)\n", this));
// When freezing, preemptively move timeouts from the idle timeout queue to
// the normal queue. This way they get scheduled automatically when we thaw.
// We don't need to cancel the idle executor here, since that is done in
// Suspend.
size_t num = 0;
while (RefPtr<Timeout> timeout = mIdleTimeouts.GetLast()) {
num++;
timeout->remove();
mTimeouts.InsertFront(timeout);
}
MOZ_LOG(gTimeoutLog, LogLevel::Debug,
("%p: Moved %zu (frozen) timeouts from Idle to active", this, num));
TimeStamp now = TimeStamp::Now();
ForEachUnorderedTimeout([&](Timeout* aTimeout) {
// Save the current remaining time for this timeout. We will