Timers in child processes fire late after waking from sleep on Windows
Categories
(Core :: XPCOM, defect)
Tracking
()
People
(Reporter: jstutte, Assigned: jstutte)
References
(Blocks 1 open bug)
Details
Attachments
(7 external files)
On Windows, TimeStamp (QPC) counts system sleep, but the timer thread waits on a relative waitable timer, which since Windows 8 does not count down while the computer is asleep (SetWaitableTimerEx). After a wake, timers that became due during sleep are overdue, but the timer thread keeps waiting for the rest of its pre-sleep wait.
The parent process handles this: wake_notification makes TimerThread::DoAfterSleep recompute the wait. Child processes never get wake_notification, so their overdue timers fire only once the old wait runs out or something else re-arms the timer thread (a new timer, for instance). This comes from reading the code and has not been measured.
The same applies to macOS, Linux and Android once TimeStamp counts sleep there (bug 1204823), so this bug also prepares for that change.
The patches:
- forward
wake_notification(wake only, not sleep) from the parent to content, GPU, RDD and utility processes - handle it only in the parent's
nsIOService, which already forwards the resulting link change - stop ignoring wake notifications in the macOS timer thread (the pref becomes
timer.ignore_sleep_notificationsand only covers sleep) - treat
application-foregroundas a wake on Android, which has no wake notification
| Assignee | ||
Comment 1•11 days ago
|
||
Once TimeStamp counts sleep on macOS (bug 1204823), the timer thread, which
waits on a clock that does not, needs the wake notification to recompute its
wait. Only sleep notifications stay ignored on macOS, as they may come without
a matching wake notification. The pref is renamed to match its narrower
meaning.
| Assignee | ||
Comment 2•11 days ago
|
||
The following patches forward wake_notification to child processes. The
network change and captive portal recheck it triggers in nsIOService are
parent-only work, and the parent already forwards the link change to content
processes.
Updated•11 days ago
|
| Assignee | ||
Comment 3•11 days ago
|
||
Timers that became due during sleep only fire promptly after wake when the
timer thread gets wake_notification, which so far only the parent process
receives. On Windows, child process timers can already fire late after wake
today, as TimeStamp counts sleep but the timer thread's relative waitable timer
does not.
Content processes now also skip input event telemetry for events from before
the wake, as the parent already does.
| Assignee | ||
Comment 4•11 days ago
|
||
Its timer thread waits on a clock that does not advance during sleep, so like
content processes it needs the wake notification to fire timers that became
due while the system was asleep.
| Assignee | ||
Comment 5•11 days ago
|
||
Its timer thread waits on a clock that does not advance during sleep, so like
content processes it needs the wake notification to fire timers that became
due while the system was asleep.
| Assignee | ||
Comment 6•11 days ago
|
||
Their timer threads wait on a clock that does not advance during sleep, so
like content processes they need the wake notification to fire timers that
became due while the system was asleep.
| Assignee | ||
Comment 7•11 days ago
|
||
Android has no system wake notification, and the device usually sleeps while
Firefox is in the background. So the timer thread handles
application-foreground like wake_notification, and the parent forwards it to
the GPU, RDD and utility processes as a wake. Content processes already get
application-foreground.
This only matters once TimeStamp counts sleep on Android (bug 1204823).
Updated•10 days ago
|
Updated•10 days ago
|
Updated•10 days ago
|
Updated•10 days ago
|
Updated•10 days ago
|
Updated•10 days ago
|
Updated•10 days ago
|
Description
•