[Jan 26, 7:25am]: Google has responded to this article and the plans for throttling:
----------------
"L'enfer est plein de bonnes volontés ou désirs"
Chrome 56 introduces a commendable optimization to throttle background tabs' timers. From the Intent to Implement, the gist is:
Unfortunately, our current implementation throttles WebSockets. Because of this we ARE NOT SHIPPING this intervention in M56.
The current plan is to disable time-budget background timer throttling for the pages with active connection (websocket, webrtc and server-sent events) and to ship in M57 (subject to further feedback). We will keep you updated with the progress.
----------------
"L'enfer est plein de bonnes volontés ou désirs"
Chrome 56 introduces a commendable optimization to throttle background tabs' timers. From the Intent to Implement, the gist is:
- 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 is generally a Good Thing. Browser vendors should be concerned about battery life, and this will do a lot to help. Unfortunately, this implementation is ignoring the new reality: the browser is no longer just a reading device; it is the world's largest application platform.
This will break apps on the web.
When idle, your application's timers may be delayed for minutes. Aside from terrible hacks like playing zero-volume sounds, you have no control over this. Avoiding expensive CPU work is not a panacea; that some applications must do significant work in the background, including syncing data, reading delta streams, and massaging said data to determine whether or not to alert the user.
Worse yet, the heuristic is based on local CPU time; faster clients may have no issue and face no throttling, but slower devices often will, causing cascading processing and notification delays.
Popular applications like Slack and Discord, as well as our own application (BitMEX, a Bitcoin trading site) will be hugely and adversely affected by this. What good is the user granting the Notification permission if we can't do the processing necessary to even fire the notifications?
Before you think this sounds alarmist, here's real data from a few days ago, where I ran a simple `setInterval` every second while our application ran and recorded the actual time elapsed. This shows timer delays on a site that does a medium amount of background processing:
Gone are the days when you could count on timers to fire semi-reliably.
This has dire ramifications for sites that keep WebSocket subscriptions open. In fact, we've already begun work with Primus to remove client-side heartbeat timers which will make it into a new semver-major soon. Emulation libraries like socket.io may have more trouble.
The recommendation from the Chrome team is to move this work to Service Workers. While it's great to have a way out, this recommendation involves significant compromises, development work, and compatibility fallbacks. And who's to say that Chrome won't have to start throttling noisy Service Workers in the future?
If you run an application that counts on background timers firing reliably, please leave a respectful comment explaining your use case in the Intent to Ship thread before this rolls to Stable. The team is listening and has already acknowledged their intent to make this throttling less aggressive. More data points would be very useful to them to ensure Chrome 56 does not break the web.
did you just do a setInterval with printing current time ? If so the 'budget' mechanism is not really working is it ? otherwise a simple lower priority / less cpu based on device capabilities etc would be acceptable to me
ReplyDeleteNo - this was a setInterval running at the same time as the regular work my existing production application does. So it's a good representation of what timers on a typical SPA might be throttled to.
DeleteRIP cookie-clicker and cookie-clicker-alikes. And that loligater game.
ReplyDeleteYou just killed my productivity for today
DeleteDamn Internet!
DeleteI am worry about apps like soundcloud or spotify (web versions) that will die and stop playing or making big pauses between songs.
ReplyDeleteWill make sense to show a pop up (requested manually by the app) to ask for "run on background" permission?
That shouldn't be a problem as apparently "tabs with audio are always considered foregrounded". Source: https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/-dmrNAFHd-4/discussion
DeleteAnd there's your workaround. Loop a 1 second null audio file for as long as you need to (please don't).
Deletehelp! How do I record silence? Do I need to update my microphone to capture silence?
DeleteI'd send you the answer, but I'm all out of paper...can you fax me a few blank sheets?
DeleteThe Chrome team has confirmed that this will not work; the mechanism for disabling throttling will be the same as the one that shows the speaker icon in the tab. That icon does not show with inaudible sound.
DeleteRickroll it is
DeleteWill make sense to show a pop up (requested manually by the app) to ask for "run on background" permission? +1
ReplyDeleteThis. Problem solved.
DeleteYes please, at least give us this option so users can give this permission and keep a tab running smoothly, we run a dedicated app that control certain things on our clients companies, they keep it in the background and run their PoS software on another tab, if the app is throttled they will notice and it's going to mess things up.
DeletePlease give us the choice as permission or a configuration option to disable throttling.
How will I mine bitcoin in the ads I serve???
ReplyDeleteyou have to target firefox users only.
DeleteI used to encounter this problem before Chrome 56, but it is not the browser fault, it might the code you wrote for timer would delay, there is some way to break through and get a correct time.
ReplyDeleteThat is a different issue; the behavior in Chrome 56 is brand-new.
DeleteAs a developer I hate the current slowdown already... And as a user I have no problem with having 81 Tabs open (current status)...
ReplyDeleteIf they would really care about performance they would ship an ad-blocker by default :D :D
Btw. I am really worried about the extensive use of serviceworkers. Not that I would not find them useful, but somehow I have a feeling that the tracking industry will find them even more useful.
have a look on "The great suspender" addong
DeleteSadly the well was poisoned by lazy developers who used by CPU and battery for non-essential tasks. It's just not sustainable for every tab to have free access to my computer's limited resources.
ReplyDeleteThis seems like a good idea, but I'm concerned it'll completely destroy my ability to cast a tab to a Chromecast while doing other work in a foreground tab. Should I be concerned?
ReplyDeleteNo. The system is aware of tabs that are playing audio or the source of mirroring, and this factors into the foreground vs. background state of the tab.
DeleteThey really ought to just include a JS function that disables this or something.
ReplyDeleteI have an app that allows a client tab to sync audio playback with a host video tab through socket.io. This'll kill that =/
ReplyDeletethe great suspender chrome extension (which supports whitelisting) is a better approach
ReplyDeleteMost of the timers on background tabs on my browser are only working to serve ad rotations. Google's approach may be over aggressive - I think I would have chosen to allow the user to opt-in to timers on a specific tab - but given the aggressive ad serving on some sites I can see why they would choose to do this.
ReplyDeleteExcept for the thousands of internal web apps that rely on chrome running smooth... chrome isn't only for reading websites anymore, there are a lot of companies that built their software for the web, I'm not against this but there should be a way to disable it from the options so it can be turned off in a corporate office.
DeleteEven in backgrounded tabs, messages from web workers and incoming messages on websockets are processed as they happen, so there is an opportunity to take some action on these events. For websockets, a ping-pong protocol driven by the server should work just fine.
ReplyDeleteWe've had issues with timer in backgrounded tab for a while now, and we've been using HackTimer to help restore reliability for our important timers: https://github.com/turuslan/HackTimer (there was a memory leak in HackTimer when we started using it, but we fixed it in our copy, and I assume it's been fixed upstream too by now).
As it turns out (at least in the current implementation), this is not true. See https://groups.google.com/a/chromium.org/d/msg/blink-dev/XRqy8mIOWps/Ctq56g4VBQAJ
DeleteThanks for the clarification Sam. In that case, the proposal is quite terrible for real-time apps that get backgrounded. Am glad they're revisiting this and delaying shipping.
DeleteThis comment has been removed by the author.
ReplyDeleteWhat if something like a QOS tag were established for the page author to declare their need for a higher priority? The browser would also need to display an icon on tabs that have requested higher priority so that users can close sites that are abusing the privilege.
ReplyDeleteI'm using https://github.com/deanoemcke/thegreatsuspender by long time and is perfect.
ReplyDeleteAre Service Workers the only way out ? What about regular or shared Workers ?
ReplyDeletealso, are Desktop browsers not running on batteries affected too? We have some polling to keep sessions alive on regular Desktop platforms, we need some predictable reliability (or whatever is close to that). Thanks for any sort of extra clarification.
DeleteIs it just Chrome, or also Chromium?
ReplyDeleteSlack or discord are using websockets. It's fucking 2017, stop using setTimeout/setInterval as part of realtime communication protocol.
ReplyDeleteAlso it will not break the internet. It will break only shitty pages with lots of non async code.
"Emulation libraries like socket.io may have more trouble."
DeleteThis comment has been removed by a blog administrator.
Delete"Popular applications like Slack and Discord, as well as our own application (BitMEX, a Bitcoin trading site) will be hugely and adversely affected by this."
DeleteSlack bootstrap-client.js 7 setTimeout
Slack rollup-client.js 8 setInterval , 121 setTimeout
Slack rollup-core_required_lib.js 3 setInterval , 46 setTimeout
Callbacks from websocket data are also throttled by this intervention.
DeleteI agree with the idea of allowing a user to opt-in per tab. After all, it is their battery life to consume as they see fit. Obviously, the UX for this would have to be thought through.
ReplyDeleteI'm guessing you mean Web Workers and not Service Workers.
ReplyDeleteNo, I meant Service Workers.
DeleteI already use The Great Suspender desktop Chrome extension to achieve much of this and it is really nice. https://github.com/deanoemcke/thegreatsuspender
ReplyDeleteAll due respect, Chrome project has been on a *very* strange path for the past couple of years. I don't follow their team but my guess is they've switched leads. Their market share going into decline is a direct consequence.
ReplyDeleteWell, there are always other browsers. Chrome is becoming a new IE6. We are close to launch an open source XMPP web client, and if it won't work in background in chrome, well, we'd openly point users to Firefox.
ReplyDeleteLooks like Google is not shipping M56.
ReplyDeletehttp://www.itpro.co.uk/web-browsers/28004/google-almost-broke-the-web-with-its-latest-chrome-update
Hi There, i have a pretty robust computer to allow me to keep 12 to 20 tabs open, many of which i am actively processing data in. over the last several months it seems that nothing is being done when I switch from one tab to another and return 30 seconds later. Is this related to the throttling. - I have a 32GB GB Mem, SSD Drives, and running a 5960 6 way CPU.
ReplyDeleteThanks in advance.
The first time I saw this website, I was immediately attracted to zoom. Moreover, all the information is in my opinion quite interesting and intriguing. I hope you also visit my website and pass judgment on my website. Thanks.
ReplyDeleteXMPP
Thanks for sharing your honest experience. When I first took a look at my head shots,
ReplyDeleteI wasn’t too thrilled with mine but you’ve given me a new perspective!
Love the way magnificently every word is composed with legitimate adjust.
ReplyDeleteflower wallpapers
These background check administrations would give you an exhaustive, finish, ground-breaking yet solid report about a man. They would convey you data like, yet are not restricted to telephone number narratives, resources and liabilities, family background, address accounts, marriage records and even criminal records!background check service
ReplyDeleteYes, the author of the following article is right! The problem exists and we need to make sure to elaborate this issue within the nearest time possible.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteIf your life has stopped giving you pleasure due to some unknown reasons than our Escorts Service is the right place it is still not too late to make it exciting. It is just your, who are such buddies, who can make you worth living if you spend a few moments with them. There is no such nudging in availing yourself of their companionship.
ReplyDeleteCall Girls in Dwarka
How to choose escorts in Aerocity, Delhi
Call Girls in Faridabad
Body Massage in Connaught Place
Body Massage in Aerocity
Massage Parlor in Aerocity
If you want to protect your computer from viruses but for which you are facing many problems then dial Toll Free Antivirus Support Number 1-888-985-6722 and get immediate help from technicians.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteGreat blog, you give Great Information us. Thanks for sharing this information!
ReplyDeleteAir Hostess xxn Service Jor bagh
5 Star Hotel xxn Service Jor bagh
hello, Kajal here, Great Blog, Thanks for sharing this information!
ReplyDeleteJodhpur xxn Girls service
Kochi xxn Housewife service
Staples Coupon Code $25 OFF $75 Get latest Staples Coupons and Promo codes which you have get $25 Off on your order over $75, with Staples Coupon code $25 off $75.
ReplyDelete