According to Google, this would reduce the CPU usage coming from Chrome's background tabs, indirectly improving the browser's performance and the device's battery life.
This new mechanism is explained in a two-page document and discussed further on the Google Chrome discussions group.
Unfortunately, many web developers have abused this feature and overloaded pages with timers that often trigger and run seemingly non-stop.
According to Google, this has led to some situations where one Chrome background tab was consuming up to 20% of the device's memory.
Background tabs will work on a "time budget"
The way they plan to do this is by using a "time budget" for each tab, which can exhaust if the background tab triggers too many timers. The proposed throttling mechanism, as described by Google engineer Alexander Timin, is as follows:
- Each WebView has a budget (in seconds) for running timers in background.
- A timer task is only allowed to run when the budget is non-negative.
- After a timer has executed, its run time is subtracted from the budget.
- The budget regenerates with time (at rate of 0.01 seconds per second).
Legitimate concern that this measure might break apps
Developers have voiced concern that this mechanism might ruin real-time applications such as Slack, Discord, and others, who rely on timers to power many of their features, such as notifications and operations that alter the tab's favicon to signal new content.
Anticipating criticism, Google engineers said they've tested the new throttling system on Gmail and saw no loss of functionality.
The browser vendor also said that pages that play audio would be exempted from the timer throttling mechanism, a decision they made to avoid breaking the service of YouTube, Soundcloud, Spotify, and other music streaming services, which users intentionally leave running in the browser's background.
Google plans to ship this feature for all six Blink platforms: Windows, Mac, Linux, Chrome OS, Android, and Android WebView.