Chrome To Introduce Timer To Throttle Background Pages (ghacks.net)
Google plans to roll out a change in Chrome Stable soon that will have the browser throttle timers in background tabs to improve battery life and browsing performance. From a report: The motivation behind the chance is that some pages consume a lot of CPU when they are in the background. Google mentions JavaScript advertisements and analytics scripts explicitly but it is not limited to that. The core idea is to limit the processing power that background tabs get in Chrome once the feature lands. (1) Each WebView has a budget (in seconds) for running timers in background. (2) A timer task is only allowed to run when the budget is non-negative. (3) After a timer has executed, its run time is subtracted from the budget. (4) The budget regenerates with time (at rate of 0.01 seconds per second). (5) The only pages that appear to be exempt from the throttling are those that play audio.
I guess we'll be seeing a lot more pages that play audio soon.
There are two types of processing jobs: One is a fixed amount of work, the other is as much work as can be done. You only save battery power by throttling the latter. The fixed amount of work type of job is usually more efficiently executed at full speed. So this may backfire. And who believes this isn't Google throttling competitors' analytics scripts while not throttling their own?
Silent audio won't necessarily work, as browsers are already detecting whether a video's audio is silent. In Firefox 51, this video that has intermittent audio causes the speaker icon in the tab to blink on and off whenever the game plays a sound effect.
Page rank, etc. might influence timer thresholds.
Almost all tab use is, unfortunately, a lazy substitute for bookmarking, of pages that don't need to update when not viewed.
Key words: "Almost all". I can think of a couple exceptions that aren't "a lazy substitute for bookmarking":
Great, now ever page with an advertisement on it will play some audio in order to get around the timers.
Can they stop those css pop up screens? You know the kind that darken your background and ask for your email address when browsing many sites? You are forced to try and look for the nearly invisible X to close them. Tons of mainstream sites do this and its annoying as hell.
Only the State obtains its revenue by coercion. - Murray Rothbard
The problem is documents that run "as much work as can be done"-type tasks that don't benefit the user, such as sending a client-side real-time-bidding ad auction out to forty different ad networks. So perhaps the goal is to discourage documents from running "as much work as can be done"-type tasks at all without the user's consent.
Safari purges tabs in the background all the time saving enormous amounts of processing, yet it reloads them far too frequently as well wasting even more.
The only pages that appear to be exempt from the throttling are those that play audio.
So pages that steal computing cycles will start playing inaudible sounds while they work. This will stop all the scripts except for those that really should be stopped, and annoy pet dogs around the world too.
First, they block flash by default (yeah, Flash sucks - But 90% of online games still use it, and I want them to work); Unity virtually never works in Chrome; and now Google wants to cripple the small number of games that follow their own damned guidelines by using pure JS/HTML5?
I wouldn't care quite so much if Mozilla didn't appear dead set on committing suicide, but at this rate, I'll be running Edge by the end of the year!
To block sponsor and mailing list pop-overs, just press Ctrl+W (Command-W on macOS).
does that mean I can keep 500 tabs open, instead of 50?
I believe the "tab purging" only happens on iOS, not on MacOS. However, as the OP notes, Safari has had the timer throttling on background tabs for years.
"The slave who knows his master's will and does not get ready...will be be beaten with many blows."Luke 12:47-48
Genuinely curious, when do you think it's useful to run games in background tabs? And I thought they just added "click-to-flash", rather than preventing you from viewing flash content entirely, which seems totally reasonable. That's a decision that saves memory/energy with the option of still using flash, and anything that gets the abomination known as flash off the web sooner is a good thing.
"The slave who knows his master's will and does not get ready...will be be beaten with many blows."Luke 12:47-48
According to the article (yes, I RTFA), here's the criteria:
-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).
This suggests a few ways around this.
- Play a 0.1 second silent audio sample on page load, throwing the page into "non-throttle mode". ::90 second extended cut::
- If "playing audio" itself only keeps the page's budget from decaying for a short time, play a 0.1 second silent audio sample before every timer call.
- Change your timer code to record its own runtime and set the next refresh to (runtime(ms) * 10). Ie. if your tracker call took 310ms to execute, set the refresh to 3100ms, or 31 seconds. If nothing else this would force ad trackers to write some efficient code for once.
- "HEY WEB SURFER WE'D JUST LIKE TO TAKE THIS OPPORTUNITY TO PLAY YOU OUR AMAZING JINGLE AND YOU WON'T BELIEVE WHAT HAPPENS NEXT!"
I'm not exactly sure how to mitigate that. Silent audio detection? (solved by playing a 40khz tone that you won't hear but will drive your pets bonkers) Option to turn it off? (disables your music streaming app after a while) That option with whitelists? (manual intervention == annoying your customers)
I'll be honest, we're throwing science against the wall to see what sticks. -Cave Johnson
The only pages that appear to be exempt from the throttling are those that play audio.
So every page is now going to play a silent audio track in a loop in order to work around this limitation?
This is a common trick in iOS applications to prevent the system from backgrounding you when off-screen. It won't take long to migrate to the web . . .
So now we need adblockers that detect pages that detect adblockers.
Some already do. But this may violate anti-circumvention law, be it a country's WIPO Copyright Treaty implementation (such as the Digital Millennium Copyright Act) or laws defining trespass upon a networked computer (such as the Computer Fraud and Abuse Act).
But if website operators try to assert the DMCA or CFAA against ad blocker developers, the latter will probably end up building plausible deniability into their products. Instead of blocking ads per se, they'll block third-party tracking (such as Disconnect), block content-types, and pause page loads that exceed 1 MB. This CPU throttling appears to have a similar intent.
to have a mainstream browser just be a browser?
I'm going to sound like an old man but there was a time when all Chrome was aiming for was to be fast and lean. And it was able to be that. Something changed and now Google wants to use it for more than that. Which is when these sorts of things always go to shit. We saw it with IE, which was always shit but it got even more shit to everyone's surprise. Firefox keeps going through cycles of shittiness. Ug.
The browser is re-inventing preemptive scheduling algorithms.
Which isn't necessarily a bad thing. Not all web applications would work better as native applications, especially because most users don't want every web app to become (say) Mac-exclusive.
when do you think it's useful to run games in background tabs
Two obvious situations come to mind. First, "Idle" games, where you basically just let it run in the background and check in on it once an hour. And second - Let's say I want to look something up (maybe a Wiki for the game itself) in another tab; online games typically do not react gracefully to losing their network connection, and I would be shocked if being throttled for more than 100-250ms per second wouldn't have almost the same effect.
anything that gets the abomination known as flash off the web sooner is a good thing.
If you don't want to run Flash - Then don't. My computer? Not yours to decide what runs on it.
That is what Greasemonkey/Tampermonkey are for, as an addition to uBlock Origin. They help somewhat, but some sites still skitter around them. Definitely an arms race going on.
Nope... they will just sell audio ad space to all comers.
when do you think it's useful to run games in background tabs?
When they're streamlined simulations of an RTS's tech tree. Click the cookie a few times and I'll explain.
It is always wrong (ok, 99.9% of the time wrong) to have more than one context/page/plug-in instance in the browser play audio at a time, whether the context is backgrounded or not.
From a user perspective, the result of multiple concurrent audio streams is garbled, unintelligible, dissonant sound.
So if you can save power by preventing that, do so.
Related case in point: When a browser re-starts after a crash, it often seems to start auto-playing a bunch of separate youtube videos (which had been paused or at-end-of-video) on backgrounded pages. Again, this is ALWAYS the wrong thing for the browser to do.
Where are we going and why are we in a handbasket?
Egads, what took so long? This should have been done YEARS ago.
But tabs I am not looking at, (by default) should use ZERO CPU. I get that I might launch several tabs quickly and want to allow them to load. So, allow some time for them to load, but then cut it to zero.
Give me the OPTION to change this behavior. Give me the OPTION to play music in background (either globally, or on a specific tab). And for gosh sake, SHOW ME how much CPU each tab is using (optionally). Then I will know to avoid the sites that are using my browser to bitcoin-mine.
Apple had to clamp down on iOS apps that were abusing the "background audio" flag. Too many apps just played silent audio. Now, playing silent audio will get the app bounced from the store.
Unfortunately, the web has no benevolent dictator vetting sites. OF COURSE "background audio" will be abused!
The idea is to limit the processing power that background tabs get.
Got it. Simple, succinct, perfect.
(1) Each WebView has a budget (in seconds) for running timers in background. (2) A timer task is only allowed to run when the budget is non-negative. (3) After a timer has executed, its run time is subtracted from the budget. (4) The budget regenerates with time (at rate of 0.01 seconds per second).
Of what interest is it to anybody that the pseudo-code for this is the above, vs some other slightly different variant of how to restrict allocated processing time? Users aren't going to care. And if developers try to somehow design around this level of detail, they'll break if the algorithm ever changes.
When I tell a friend I'll show up for dinner, I don't then explain that I'm going to do so by walking one foot at a time until I get to the dinner place, at which point I'll commence chewing and swallowing.
- First they ignore you, then they laugh at you, then ???, then profit.
The only pages that appear to be exempt from the throttling are those that play audio.
Dadgummnit! Those noisy ads that auto-play while I'm pre-loading news articles are the ones I want suppressed.
When I spawn a tab to pre-load a (quiet) article, I want it to load ASAP, not throttled.
"We reject as false the choice between our safety and our ideals." --The American President (20.1.2009)
If they are concerned about battery like, i don't figure they are talking about mobile devices, the browsers for which all already pause javascript execution as soon as the tab is backgrounded.
Tying this to audio only is a bad UI design. Otherwise we are going to be seeing a lot more audio applications.
This should not be arbitrarily set by Google. Instead, it should come up as a permissions pop-up like the location permissions...
For example, it could say... This application wishes to update in the background more frequently than the recommended levels. This may affect battery life. Do you approve" [Yes] [No]
I have several tabs open all day long in the background for time tracking.
They use setInterval for autosaving. As this is semi-important, I wouldn't want this tab to be throttled.
Will there be an easy to use UI for disabling this throttle on a per tab basis? Perhaps in the context menu?
Okay, but what does luck have to do with it?
#DeleteFacebook
This is common sense. If the page is not visible, then it should NOT do anything. If it's still hogging the cpu when I can't see it then that is lazy ass programming by a wannabe coder. The timer solution idea has been used in many applications and systems in the past, though not exactly the same way. It's hardly a new groundbreaking concept, it's quite like dynamic priorities in unix systems. Better to use have the headline read "Chrome throttles cpu usage of background tabs, but still is unable to completely stop them for fear of angering the advertising overlords."
No web page should do anything when you're not looking at it. Full stop. Pun intended.
For all intensive purposes, "whom" is no longer a word. That begs the question, "who cares"?
This is common sense. If the page is not visible, then it should NOT do anything. If it's still hogging the cpu when I can't see it then that is lazy ass programming by a wannabe coder. The timer solution idea has been used in many applications and systems in the past, though not exactly the same way. It's hardly a new groundbreaking concept, it's quite like dynamic priorities in unix systems. Better to use have the headline read "Chrome throttles cpu usage of background tabs, but still is unable to completely stop them for fear of angering the advertising overlords."
LOL!
Weren't timers originally disabled for pages in the background? Whose stupid idea was it to enable them? I'd like to see background pages completely disabled - downloads are handled by a separate mechanism anyway, so if you start a download and then go to another page, who cares?
"Transparent" is a shit show that trades on every stereotype going. A man in drag is NOT a transsexual.
1. Skip "CPU Budget" stuff
Just have a throttle of 10 or 100 or 1000 script actions per second, set well below browser lockup speed. To hell with reviews your browser is 0.028% slower than IE or Edge or Opera, running balls out locked up.
ATTN REVIEWERS OF BROWSERS: When you review for script speed, not caring about lockup, you are full of fail. This is all your fault.
2. I don't care what standard allows popups -- get rid of them.
3. I don't care what standard allows message boxes -- get rid of them.
4. I don't care what standard allows music or video autoplay -- have an all off button at the tab level. Let people set it permanently "for just this site."
5. Investigate why editing is slow and stuttered on Slashdot text entry for a message like this with Chrome on a S6. Whose crappy, chatty script implementation is calculating PI to a million digits between each letter?
(-1: Post disagrees with my already-settled worldview) is not a valid mod option.
>"Google plans to roll out a change in Chrome Stable soon that will have the browser throttle timers in background tabs to improve battery life and browsing performance."
It also kills remote access and thin clients. I have been screaming about this for years. And it shouldn't just be for background tabs, it should be for foreground ones too... if you are idle or the window doesn't have focus, there should be a way to throttle the hell out of the thing! Timers, animation, mouse polling, useless refreshing, so many things are conspiring to suck systems dry. Please, Mozilla, Firefox needs this too, ASAP!
At work we use thin clients and a single site we must use just revamped their site and now is consuming about 1000% more CPU than it used to... and it does it all day long, continuously. Yes, it is bad programming, but it is not like we end-users have much of any control over it. We need options to control this on the CLIENT SIDE. I ask users now to PLEASE close that tab/site when not using it, but many have to use it all day long or just don't care.... it ultimately affects us all.
Slashdot is a U.S.-based site, and the U.S. is not the only party to the WIPO Copyright Treaty.
It is always wrong (ok, 99.9% of the time wrong) to have more than one context/page/plug-in instance in the browser play audio at a time
Are you sure about that? I count on my mail tab to ding when I get mail, my voice tab to ring when a call is incoming
If you get more than an average of 3.6 seconds of notification sounds per hour, then "99.9% of the time" they're not being played.