Measure execution time by adding telemetry probes for tracking
foreground, tracking background, non-tracking foreground and
non-tracking background timeouts.
Measure execution time by adding telemetry probes for tracking
foreground, tracking background, non-tracking foreground and
non-tracking background timeouts.
Clear the throttle tracking timer in ClearAllTimeouts. Also clear it
in Suspend, and if mThrottleTrackingTimeouts isn't set restart the
timer if the document hasn't loaded.
In websites such as Facebook Live, timeout chains are used to drive the
playback of a video or something similar in JavaScript. Throttling the
minimum timeout values a tab playing a video from such websites in the
background could make the timeout based scheduling of video playback to
not work correctly, and cause audio buffer under-runs that are audible.
In order to address this, other major browsers don't throttle timeouts
in tabs that are playing audio. This brings us to parity to other
browsers (even though we already do this for websites that use Web Audio
since we've had similar bug reports using the Web Audio API.)
The current audio agent setup that drives the tab audio notification
icons is currently tracking whether a Window is playing audio. We use
this setup to decide whether to throttle timeouts when a window goes
into background.
Without this, we would only try to clamp the timeout for background
windows and nested timeouts. We should also do this for all timeouts
that are classified as tracking.
For simplicity, this test is being added to test_classifier.html which
already has all of the infrastructure necessary for setting up a test
domain as a tracking domain.
This pref allows easier testing and debugging of this feature
by forcing timeouts to end up in the tracking bucket in either
the alternating or random fashion.
This will allow us to schedule these timers differently in the future.
This patch only performs the refactoring, and is not intended to change
any behavior. Specifically, this patch doesn't change the order in
which timeouts are fired -- they should still all be fired according to
the mWhen field.
The implementation works by splitting timeout storage per window into
two Timeouts objects, mNormalTimeouts and mTrackingTimeouts. The ForEach
helper methods are extended to deal with both of these objects, and as a
result, most of the algorithms operating on the list of timeouts work
correctly without any modification, with the notable exception of
RunTimeout.
In RunTimeout(), the order in which Timeout objects are processed does
matter, so for that case we use the OrderedTimeoutIterator class to
iterate over both linked lists simultaneously in the mWhen order. Also,
inserting the dummy timeout when running the timeouts is only necessary
for the linked list where the last expired timeout is coming from, so we
only inject the dummy timer into the corresponding list, therefore we
remember which list we picked the last expired timeout from when
looking for it.
With this patch, all of the methods which loop over the timeouts
are refactored in preparation for splitting the list of timeouts
into a tracking and a normal list.
These generic loops need to run in the same way for both normal and
tracking timeouts. This refactoring allows us to only change the
TimeoutManager ForEach helpers to loop over both linked lists when
splitting the timeouts into two separate lists without needing to
modify each call site separately.