3 ms·
> We investigated how background tabs use system resources and found that JavaScript Timers represent >40% of the work in background tabs. ... Beginning in M87,
by Cactus2018 6y ago
> We investigated how background tabs use system resources and found that JavaScript Timers represent >40% of the work in background tabs. ... Beginning in M87, we’re throttling JavaScript timer wake-ups in background tabs to once per minute. This reduces CPU usage by up to 5x, and extends battery life up to 1.25 hours in our internal testing. We’ve done this without sacrificing the background features that users care about, like playing music and getting notifications.
- brundolf 6y ago...what in the world are all of those background timers doing? Polling for things like element visibility or something? I rarely have use for timers, especially now that CSS animations are available everywhere
- rasz 6y agothings like this: var tid = setInterval(function() { var bef = new Date().getTime(); debugger ;var af = new Date().getTime(); if (af - bef > 100) { clearInterval(tid); window.location.href = "/"; } }, 100);
- chhamilton 6y ago(Chromium dev here) Yes, lots of sites are written with tight setInterval/setTimeout loops, checking for modifications to the DOM, visibility, doing animations, etc. In most cases there are modern web APIs that do these things for you that don't require polling (rAF, MutationObserver, IntersectionObserver, etc). Throttling is mostly about reducing the impact of these sites. We are not trying to penalize well-written sites, and if you have valid use cases that you feel are being unfairly penalized we're more than happy to accept feedback!
- brundolf 6y agoThanks for the added context! That makes sense. I've debugged one or two hastily-assembled marketing sites in my time and I've seen some atrocious practices along these lines. At one time you could charitably write it off as maximizing browser support, but much of it can't really be explained that way anymore. It's a shame that sites like these drag down the web experience as a whole.