WICG / interventions

A place for browsers and web developers to collaborate on user agent interventions.
Other
177 stars 28 forks source link

Existing Intervention to add--setTimeout/setInterval are aligned/clamped to 1 second in many browsers #5

Closed toddreifsteck closed 2 years ago

toddreifsteck commented 8 years ago

Safari, Chrome and Firefox all currently have some form of background tab timer coalescing that seems to align/clamp to 1 second. (Firefox/Chrome's behavior differ a bit and it may be useful to web Interop to align.)

skyostil commented 8 years ago

Chrome on Android additionally completely stops suspends timers in background tabs after 5 minutes: https://code.google.com/p/chromium/codesearch#chromium/src/components/scheduler/renderer/renderer_scheduler_impl.h&rcl=1455769844&l=217

ojanvafai commented 8 years ago

We clearly need to spec the 1 second thing and the full suspending that we do on android. So adding the needs spec label.

The other thing Chrome is considering is to start doing the full suspension on desktop, like we do on Android. We're considering doing this for cases where we would have killed the background tab due to memory constraints, i.e. suspend tasks in that tab and purge any transient memory (e.g. layout tree, etc).

skyostil commented 7 years ago

We're now also looking at doing a bit more adaptive throttling for background tabs in Chrome on top of this 1 Hz alignment. The reason is that a misbehaving background tab can still end up using a lot of CPU either by having lots of timers or a long running timer. The general idea is outlined here: https://docs.google.com/document/d/1vCUeGfr2xzZ67SFt2yZjNeaIcXGp2Td6KHN7bI02ySo/edit#

brheenan commented 7 years ago

This is shipped in Edge as well now (as of EdgeHTML14). The clamping to 1Hz in background tabs, not anything more intensive.

bryanmcquade commented 7 years ago

Additional context on the original change in Chrome: https://blog.chromium.org/2011/03/getting-smoother-animated-web-content.html

wanderview commented 7 years ago

Note, firefox throttles timers to a minimum 1 second delay in the background, but we don't align them. See:

https://bugzilla.mozilla.org/show_bug.cgi?id=1284368

johannhof commented 2 years ago

(As noted in https://github.com/WICG/interventions/pull/72, we intend to archive this repository and are thus triaging and resolving all open issues)

I filed https://github.com/whatwg/html/issues/7941 for further standardization and linked to this issue for context.