r/programming • • Jan 25 '17

Chrome 56 Will Aggressively Throttle Background Tabs

http://blog.strml.net/2017/01/chrome-56-now-aggressively-throttles.html
4.9k Upvotes

521 comments sorted by

784

u/bheklilr Jan 25 '17

How might this affect web pages like google music or spotify? I don't necessarily want my music to become choppy just because I tabbed out of it.

965

u/wfwhitney Jan 25 '17

As part of the spec, pages with active audio playback will not be throttled.

79

u/Saigot Jan 25 '17

Get ready for a lot of silent audio playback from shitty websites.

38

u/Sydonai Jan 25 '17

Jokes on the web, I've been using Lynx the whole time!

5

u/doenietzomoeilijk Jan 25 '17

Web marketeers hate him!

12

u/xeio87 Jan 25 '17

Chrome will at least warn you when a tab is using audio streams though.

→ More replies (3)

20

u/tehdave86 Jan 25 '17

What's to stop pages from playing audio that's inaudible to get around being throttled?

34

u/[deleted] Jan 25 '17

There is a visual indicator in a tab when it is playing audio.

31

u/Die4Ever Jan 25 '17

yea but that doesn't stop them lol

16

u/[deleted] Jan 25 '17

I wonder if muting the tab, under this spec, would then throttle the page?

→ More replies (6)
→ More replies (4)
→ More replies (3)
→ More replies (1)

1

u/zomgitsduke Jan 25 '17

I also suspect whitelists will be incorporated

1

u/jeblis Jan 25 '17

Now that almost every page has about playing video this won't do much.

1

u/danhakimi Jan 26 '17

What if I have a video buffering in the background?

1

u/stevenjd Jan 26 '17

pages with active audio playback will not be throttled

But the developer who created the page should be.

→ More replies (99)

4

u/[deleted] Jan 26 '17

See this is why I use the Spotify app. And I'm sure google play will be excempt from the rule.

1

u/norsethunders Jan 26 '17

I already don't like how they delay loading the Music page if the tab isn't active. It takes like 2-5 seconds to load so I usually immediately switch to a new tab, just to come back and see it start the loading process.

1

u/zetec Jan 26 '17

I don't know if this is related or not, but I'm on the beta channel and have been having a lot of WebGL crashes lately.

1

u/omniuni Jan 26 '17

It's based on timers. In other words, your music playback won't be affected, Chrome just won't waste CPU cycles to update the playback progress bar when you're not looking at it.

→ More replies (7)

75

u/STRML Jan 25 '17

To keep you all updated on the current status, this was just sent on the mailing list:

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.

If work needs to be done in the background, existing workarounds (such as Service Workers) are generally untenable at this time due to browser support. It is also unclear how/if Service Workers will be throttled to address the underlying issue.

If exceptions are made, it is likely that the community hardest hit by these changes (application authors & advertisers) will fashion workarounds. For example, one could set up a websocket server somewhere that simply sends messages every second, then schedule your work to run upon receipt of that message.

The current proposed throttling may be a no-go, unless a good user permission story comes to the fore.

I am still in favor of the idea behind the proposal, just not this implementation. Aggressive throttling is a large part of Safari's superior battery performance. The varied workloads across the web will be taken into account when this feature is finalized.

One additional good thing that may come of this: now that there is the capacity for measuring how over-budget a tab is, it would be possible for noisy idle tabs to be marked somewhere user-visible.

1.3k

u/Causeless Jan 25 '17

Great news for the user. Developer work should be compromised to make things better for the user, as far as I'm concerned.

I don't care for web JS crapware taking 50% of my CPU so they can run some animations in another tab.

283

u/indianapale Jan 25 '17

Need an add-on that disables JS on all but the current tab

278

u/antedaeguemon Jan 25 '17

"The great suspender" well... suspends the whole page. Worth looking into.

297

u/AckmanDESU Jan 25 '17 edited Jan 26 '17

Been using it forever. Only problem is that now I have 30+ tabs open permanently with things "I'll look at tomorrow"... That are 2+ months old.

Edit: yall recommending ways to put them in folders and shit don't understand that if I do that I'll never look at them in my life lol. Not like I look at them now, but it gives me the feeling of having shit I should do but don't do. Basically like my life, where I stay in my room 24/7 and quit studying, working and socializing but I know I should be doing something else.

148

u/Ambiwlans Jan 25 '17

I normally hover around 5 windows totaling ~120tabs. This month I've been very proud to make it down to 3 and 35 respectively.

230

u/Guysmiley777 Jan 25 '17

Someone hold him down while I restart his browser sessions and clear his history!

35

u/hugebillmurray Jan 25 '17

i didn't know this was a thing until i was at an acquiantance's house. granted, he's quirky, but i wasn't expecting him to have 700+ tabs of chrome quirky.

"why don't you close any of your tabs?"

"idk i might need them later"

i personally max out at one instance of each browser and 8 tabs or whenever the tabs start shrinking to accomodate more tabs. except for when i'm doing research...for science. then i'll go over that limit temporarily.

→ More replies (41)

26

u/[deleted] Jan 25 '17

Dead lord. Just reading that made uncomfortable.

→ More replies (1)
→ More replies (12)

15

u/NastyEbilPiwate Jan 25 '17

That are 2+ months old

Filthy casual.

5

u/[deleted] Jan 25 '17

30? I was at 250! Now I use pocket to save things I'll never look at.

→ More replies (1)

3

u/LordTwinkie Jan 25 '17

get OneTab it converts your tabs into a clickable list.

→ More replies (15)

24

u/[deleted] Jan 25 '17

yeah, I think the Great Suspender is a bit too aggressive for my needs, I would love a "modest suspender".

16

u/RaptorXP Jan 25 '17

Make suspenders great again.

3

u/ryosen Jan 26 '17

It has a lot of settings that you can use to tweak it.

4

u/BEEF_SUPREEEEEEME Jan 25 '17

Seriously one of the best addons for Chrome, saves SOOOO many resources.

2

u/revsky Jan 26 '17

I use Tab Snooze, it's amazing for making sure I don't forget to read things on future days.

→ More replies (4)

18

u/kernalphage Jan 25 '17

I forget if it's a Firefox addons or a feature, but it won't even bother loading up tabs you haven't clicked on this session. Which works great for me because I use tabs like soft bookmarks.

17

u/_teslaTrooper Jan 25 '17

That's a feature.

→ More replies (4)

17

u/chrisrazor Jan 25 '17

Or just pauses it.

35

u/bloody-albatross Jan 25 '17

Good JavaScript does that itself using the visibilitychange event. But in my experience this event is only fired for bringing a tab into the background/foreground, not for minimizing/restoring a browser window. And of course a lot of JavaScript code out there isn't good JavaScript.

50

u/GetTheLedPaintOut Jan 25 '17

Good JavaScript

Never heard of it.

27

u/Iohet Jan 25 '17

exists only in theory, like good communism

→ More replies (1)
→ More replies (2)
→ More replies (3)

2

u/lihaarp Jan 25 '17

Suspend background tab for Firefox. Does exactly this. For some unknown reason it got taken down by its author years ago and stopped working properly at around Firefox 49 or 50.

2

u/evaned Jan 25 '17

And of course, there are functionality downsides to this. Many sites have very reasonable and useful checks of things in the background. For example, consider Slack, Facebook, Gmail, or even Reddit + RES. In some of these cases, you'd want immediate notification through sound when there's a new message or something like that.

(Just to clarify: I'm not saying that the proposed linked solution has this problem; just that disabling JS entirely would.)

133

u/rmxz Jan 25 '17 edited Jan 25 '17

Great news for the user

Except for users that want background tabs to do processing.

In addition to the examples given in the article (Discord, Slack, BitMEX); this includes the common use case of opening links in new tabs for the sole purpose of letting whatever processing it needs finish before I switch to the tab to read it.

In my opinion, this should be a user-configurable setting.

1

u/Don_Andy Jan 26 '17

I didn't say in the article but maybe pinning tabs will prevent this from happening just as it currently prevents a background tab from getting discarded if you start running low on memory.

1

u/lnxaddct Jan 26 '17

Background tabs are given processing quotas. This won't impact background loading that requires a brief period of processing.

1

u/nil_von_9wo Jan 26 '17

Can I PLEASE have a right-click option to "Open in new background-tab and start processing"?

→ More replies (9)

17

u/bob000000005555 Jan 25 '17

On the other hand, I run a lot of background videos for music and such. So I hope this doesn't interfere with steady playback.

16

u/Rock48 Jan 25 '17

Tabs playing audio will work fine. I'm just annoyed about my socket.io connections that are gonna be totally fucked.

19

u/stephenflorian Jan 25 '17

Someone on the team addressed that concern here.

TL;DR Throttling is only a beta feature in 56 and will actually ship with 57 and after receiving feedback they will not throttle socket connections.

→ More replies (1)

4

u/FieryXJoe Jan 25 '17

They will hopefully add a method to manually add exceptions if there are already exceptions for tabs playing audio.

5

u/ryosen Jan 26 '17

They will hopefully add a method to disable it completely. I'm perfectly capable of making my own decisions as to what should be running and what shouldn't be.

→ More replies (1)

4

u/cd7k Jan 25 '17

Then play some audio :) Silent audio file... should compress pretty well too ;)

4

u/Rudy69 Jan 25 '17

I like that the writer of the article thinks it's something terrible while this whole time I think it might bring me back to Chrome

1

u/OldFartOf91 Jan 25 '17

I want the exact opposite

1

u/SoftCoreDude Jan 26 '17

Don't they always pause anyway?

When I work with p5.js, if I change the tab, when I come back the work is in the same place it was when I left

1

u/nthcxd Jan 26 '17

But how will hard working advertising executives feed their children??

1

u/[deleted] Jan 26 '17 edited Jan 26 '17

Developer shouldn't be forced to, they should be encouraged to. Perhaps give them a notification of when a tab goes into background. And then add a way for the user to know what tabs are using too much CPU.

nothing should be forced. that breaks the Web.

3

u/[deleted] Jan 26 '17

That would be wonderful if all web developers were both competent and not malicious.

Unfortunately, neither is true.

1

u/mfukar Jan 26 '17

What if the developer works to make things better for the user? Just asking idly..

1

u/mickoes Jan 26 '17

Now these crapware will incorporate sound elements to bypass the throttling. I hope they include a custom filter or a few options with this new feature!

1

u/FrzTmto Jan 30 '17

A Tab not visible should get 0 % processor time to update an animation...

→ More replies (2)

162

u/[deleted] Jan 25 '17 edited Jan 26 '17

will this affect my Cookie Clicker progress?

36

u/vlees Jan 25 '17

No idea how the most recent version works, but the original one (3 years ago?) would have, yes

22

u/[deleted] Jan 25 '17

How much of that have you played?

97

u/xeio87 Jan 25 '17

The correct answer is always "too much".

27

u/louiswins Jan 25 '17

The correct answer is always "not enough".

FTFY

→ More replies (1)

12

u/[deleted] Jan 26 '17

God damnit. Looks like I'm going back to playing that again

266

u/redalastor Jan 25 '17

That's great news as far as I'm concerned.

Rendering should be done only on requestAnimationFrame which isn't fired when your page is not active anyway and 0.1 second every second is quite enough for all those notifications and other processing tasks. And even if I get a notification 5 seconds late, who cares? The tab's in the background.

I'm looking forward to the battery savings.

212

u/[deleted] Jan 25 '17

Facebook developers be like "OMG OMG WHAT WILL WE DO, THE WORLD IS BURNING" - Right now.

73

u/redalastor Jan 25 '17

They've been known to adapt. Maybe React will now do its rendering only on requestAnimationFrame like Elm is doing. It avoids redrawing more often than the browser can display which boosts performance.

28

u/[deleted] Jan 25 '17

You should check out React Fiber then. It sounds like it does exactly that and more ;)

(More = being able to prioritize some renders over others, splitting rendering into chunks to not block animation if a single render would exceed the frame budget and being able to eliminate pending work if changes from a higher priority event have made it obsolete.)

7

u/redalastor Jan 25 '17

Oh, looks like React is slated to become React Fiber. Great news.

11

u/[deleted] Jan 25 '17

Yeah, it's just the codename of the project to optimize the rendering pipeline and it's expected to be released as part of React 16. No ETA yet though :)

→ More replies (1)

11

u/DaFox Jan 25 '17

React pages in chrome on my ultra low power device is just silly, it ends up corrupting the page temporarily sometimes and everything starts moving around

6

u/PaintItPurple Jan 25 '17

React's defaults have never been particularly performance-conscious, but it's not that hard to adapt it. For example, Om (a ClojureScript interface to React) has used requestAnimationFrame for years.

2

u/muffsponge Jan 25 '17

There are ways to make a react/redux app update only on animation frames. I use it in my apps. Especially useful if you do multiple dispatches in a single frame.

4

u/nipplesurvey Jan 25 '17

do you have any links to learn more about how to do this? not finding anything productive googling, but perhaps i'm googling the wrong thing....

→ More replies (1)

3

u/[deleted] Jan 25 '17

Good.

30

u/bulldada Jan 25 '17

I've recently been building an application with the WebMIDI APIs and this requires some pretty solid timing, setInterval is too imprecise and causes a lot of noticable drift. requestAnimationFrame is a much better solution for timing your MIDI events, but the background tab throttling is quite frustrating as it completely messes up the timing as soon as you change window/tab, it's not even predictably throttled. There doesn't seem to be any way in chrome to disable this behaviour with a flag or otherwise, although Electron/NWjs I think may have a command line option for it.

The solution is probably a better timing/event API that doesn't get throttled rather than using requestAnimationFrame for non-graphical purposes.

I do appreciate that this change is probably for the overall good, but it does have a significant negative effect for some niche applications and it's a shame there's no way to manually disable it. Running it in it's own top level window and making sure to never accidentally minimise it is the only real workaround for now.

9

u/Fidodo Jan 25 '17

Web workers are not throttled, probably because they run in a separate thread, so try that. Also, I'm misreading you and you're not using set interval for time tracking right?

→ More replies (2)

25

u/obsa Jan 25 '17

Running it in it's own top level window and making sure to never accidentally minimise it is the only real workaround for now.

I don't see any reason why that's not a perfect solution.

Why, as a user, would I want there to be an API to side-step this protection mechanism? Background tab = background tab. Don't bother me.

24

u/bulldada Jan 25 '17

Perhaps I was unclear, I wasn't suggesting an API to disable it. An option in chrome, even if hidden in chrome://flags would be appreciated though. Alternatively asking permissions to run in background as it does with many other APIs, fullscreen, web audio input, etc. The WebMIDI API already requires the user grant it permissions, I wouldn't mind seeing some unthrottled timing event behind that.

4

u/obsa Jan 25 '17

I would agree that a permission-based API would be appropriate to allow legacy behavior. This way, the user could opt on a case-by-case basis what the page is allowed to do in the background.

Yeah, all these granular permissions are not a seamless experience for low-tech users, but low-tech users also complain when nothing works well and they don't understand why.

3

u/useablelobster Jan 25 '17

Why doesn't javascript have a (even slightly) reliable time api? If it hasn't happened now then it won't happen for years at this point. Hopefully WebAssembly will have something?

→ More replies (1)

15

u/frankster Jan 25 '17

Its pretty easy to imagine, from what /u/bulldada has said, why you might want a background midi tab to have reliable timing.

If I'm listening to music on soundcloud, I don't usually have that tab in the foreground - likewise if I am listening to music played back via the webmidi api, i may not want the tab to be in the foreground.

3

u/evaned Jan 25 '17

I don't see any reason why that's not a perfect solution.

There are lots of reasons.

First, we've got tabs for a reason -- they're useful. Why would I want to open a bunch of new windows just to work around something?

Second, it's too susceptible to silly mistakes like minimizing or opening a new tab on top.

Third, suppose there's a link in a website "app" that I want to have background privileges. Now, I can open that link in a new tab and open it. With this change, I couldn't; I'd need to open it in a new window, or copy and paste the URL into another.

IMO, that's a "solution" that may well be worse than the problem....

→ More replies (3)

18

u/SystemicPlural Jan 25 '17

ehh.

Firstly its every 0.01 second, not 0.1.

Secondly, this throttles all timers, not just requestAnimationFrame.

Thirdly, notifications wont be 5 seconds late, but over a minute late - and that's assuming the notification is fired in just one cycle.

It will break a lot of sites that do background processing.

8

u/adrianmonk Jan 25 '17 edited Jan 26 '17

Thirdly, notifications wont be 5 seconds late, but over a minute late - and that's assuming the notification is fired in just one cycle.

I see zero justification to conclude that it's "over a minute". The announcement says that the quota will be replenished at a rate of 0.01 seconds per second, which does not equate to saying that you will have to wait a full 100 seconds before you get any additional quota.

They could give 0.01 seconds of quota every 1 second. Or they could give 0.05 seconds of quota every 5 seconds. Or they could use a scheme where quota is granted "continuously" (instead of periodically), so that if your quota is negative, your thread is put in a non-runnable (blocked) state, a projection is made on when your quota will accrue back up to zero, and an OS-level timer is set to put your thread back into a runnable state then. (The formula for when to wake up your thread is simply now + 100 * -quota, I think.)

Point being, if your available quota hits -42 milliseconds, your thread might only be delayed by 4.2 seconds. Of course, then your quota is only up to 0, but if you only need 10 milliseconds to handle the event, then you should able to accrue that in another 1 second. It's entirely possible you will be able to ride the line pretty closely if you do find yourself in this situation. Of course, if your handler burns 10 seconds of CPU time every time it runs, then things are going to go badly.

7

u/Fidodo Jan 25 '17 edited Jan 25 '17

But it accumulates. Also, you should be offloading whatever heavy work you can to web workers which are parallelized. Most background uses tend to sleep then be active in bursts. I think if you reword it to you add 100ms to your budget every 10s, it makes more sense.

10

u/redalastor Jan 25 '17 edited Jan 25 '17

It will not impact RequestAnimationFrame which never fires when backgrounded.

And why would you require intensive background processing?

42

u/[deleted] Jan 25 '17

How else are you going to mine crypto currency on your users' machines?

→ More replies (18)

1

u/lechatsportif Jan 25 '17

raf already stops during inactive tabs iirc. the real culprit is settimeout which will be the source of data access etc.

2

u/Fidodo Jan 25 '17 edited Jan 25 '17

0.1 would be more than enough, but the article said 0.01 not 0.1. But since it accumulates and you presumably have an initial buffer, it's probably not too bad.

1

u/ACoderGirl Jan 26 '17 edited Jan 26 '17

Huh. First I've learned about requestAnimationFrame. That's cool and very nifty. Of course, sometimes it's not really gonna work. After all, that's only good for animations or something that you'd want to pause if you're not focused. Lots of times there's processing that you'd want going on, too. I always assumed any visual changes wouldn't be shown if the tab wasn't active, anyway (but you might need those DOM, etc, changes to be made so that the application acts smoothly).

For example, suppose you made a cookie clicker clone (remember that game?). You obviously would want the game to process in the background, keeping track of the number of clicks and all (that is, the game state must run). Yet, you don't care about the animations. However, it's natural to code those in the same loop.

Regarding notifications, being real time is quite useful for chat applications and such. Also, 5 seconds is one thing, but the link from the OP clearly shows an example of a 1 second interval becoming 136 seconds. That's a WHOLE different thing!

EDIT: And yes, I know about web workers, but it's unreasonable to expect existing applications to be updated. There's always legacy applications and we'd generally want them to still work unless absolutely necessary. That said, I think the idea is a good one. But it should prompt when a tab uses too many resources and ask if you'd want to permit it to be unthrottled (whitelisting the domain).

2

u/redalastor Jan 26 '17 edited Jan 26 '17

Huh. First I've learned about requestAnimationFrame. That's cool and very nifty. Of course, sometimes it's not really gonna work. After all, that's only good for animations or something that you'd want to pause if you're not focused. Lots of times there's processing that you'd want going on, too. I always assumed any visual changes wouldn't be shown if the tab wasn't active, anyway (but you might need those DOM, etc, changes to be made so that the application acts smoothly).

You've missed the latest developments in web development. I don't blame you, it moves fast.

You're probably aware that the DOM is slow. Really slow. Create a plain old div in the javascript console and check how many properties it has. Last time I checked we were at 120. And those properties have properties too. Yuck! And we can't axe that without breaking backward compatibility.

So people came with the idea that that instead of always going to the DOM we could use a virtual dom. Now your page is just an array of tags where the names are strings, the attributes are objects, and the children are arrays which contain more tags, more attributes, more children, and so on. That's very, very fast compared to the actual DOM.

Of course the library you use eventually has to render that virtual DOM to the actual DOM. So where did you gain speed you may ask? In the changes when you give a new virtual DOM to render, the library or framework you use computes the difference between the two structures and figures out the minimal DOM change required to move from one to the other. It will move your old tags around and change their content instead of creating new ones, that's way faster.

But now we're thinking, fine each individual update is much faster but do we need to render every update? And it turns out we don't have to. Your virtual DOM contains absolutely everything about how your app looks but if the user isn't looking at it you can keep modifying it as much as you want (it's fast!) and let the library render it when the user is looking.

And even when the user is looking some frames will be skipped. The browser won't redraw more than 60 times per second so if you changed your virtual DOM 70 times there will be 10 intermediate states that wouldn't have been drawn anyway that will be skipped.

The virtual DOM was popularised by Facebook and is now the underlying mechanism of most JS frameworks. Connecting it to RequestAnimationFrame hasn't happened yet in most of them though.

1

u/vlees Jan 25 '17

Some sites do rely on as soon as possible notification systems (eg the system the blog post writer writes about: a Bitcoin trading site. The price of that can highly fluctuate within any second).

6

u/redalastor Jan 25 '17

Then notify right this second and don't blow your CPU budget on useless stuff.

You don't need to mine bitcoins on the browsers of your users.

→ More replies (5)

2

u/amunak Jan 25 '17

Well god forbid someone making money from something would be forced to use a dedicated desktop app (which would likely be best for performance, reliability and usability anyway).

→ More replies (1)

171

u/alexandreracine Jan 25 '17

lol, from the article : " This will break the web."

Again? How much time we can break this thing?

26

u/[deleted] Jan 25 '17 edited Jan 25 '17

I also enjoyed at the top of the article:

"L'enfer est plein de bonnes volontés ou désirs"

Which translates to: The road to hell is paved with good intentions.

Edit: not sure why this was downvoted, sorry whoever I bothered with this tidbit

3

u/villedepommes Jan 25 '17

Upvoted you. Surprisingly, the French version is rather different from the English one. I found the English version to be more poetic and the French one -- more concise. It's usually the other way around :-)

→ More replies (3)

3

u/fecal_brunch Jan 25 '17

FYI I think you meant "how many times can we break this thing".

3

u/[deleted] Jan 26 '17

If it was going to break the web to throttle these things, wouldn't it break the web to run a website on an weaker machine?

1

u/[deleted] Jan 25 '17

If this breaks the web, we all switch to Firefox for a few weeks and fix the web. Then Google will fix Chrome, we switch back to Chrome and everything will be back to normal.

1

u/CyclonusRIP Jan 26 '17

Shit's already broken. Seems like 1 out of every 4 sites I visit completely locks up my browser due to some shit code.

0

u/[deleted] Jan 25 '17

[deleted]

61

u/Fidodo Jan 25 '17

Each tab is single threaded. Chrome team wants devs to move their workload to other threads that don't share the heavy Dom and render workloads. This is a good thing.

7

u/metocean_programmer Jan 25 '17

Is there a way to multithread, or is Chrome sandboxed in a way that limits each tab to a single thread?

35

u/Fidodo Jan 25 '17

JavaScript is single threaded. Changing that requires fundamental language changes. I'm not sure of the state of future language changes in that regard. Multi threading is only through workers. It's a JS limitation more than a chrome one. The main limitation of workers is that the data transferred needs to be serialized.

7

u/Klathmon Jan 25 '17

There are zero-copy transfers already available in most browsers for web workers for typed-array constructs.

And there are working proposals about true shared memory, however I personally try my best to avoid shared memory wherever possible, as it's almost always a bugridden shitfest.

→ More replies (2)
→ More replies (4)

12

u/STRML Jan 25 '17

Service Workers aren't available in all browsers. And what's to stop a noisy Service Worker from causing the same issue?

→ More replies (4)

0

u/[deleted] Jan 25 '17

[deleted]

3

u/UnrealIncident Jan 25 '17

Firefox already has it implemented, Edge is in development and Safari has it in their planned features.

88

u/Me00011001 Jan 25 '17

Now if it would just throttle ram usage of background tabs.

32

u/Ruud-v-A Jan 25 '17

There is a proposal for purge + suspend. Discussion about the details is still ongoing.

→ More replies (1)

1

u/fixed-point Jan 25 '17

I don't think we should be throttling their RAM usage, but I do think we're right to throttle how much CPU time they get, or even suspending them entirely where we can.

It shouldn't matter if your memory usage comes close to, equals or exceeds the amount of RAM in your machine: if the background tabs are not doing any work, then we should be letting the OS page it out.

→ More replies (25)

44

u/JZcgQR2N Jan 25 '17

Is anyone else surprised this wasn't done already?

22

u/Fidodo Jan 25 '17

It was, background tab timer intervals were throttled to a second between fires. This is a new implementation that gives you more flexibility, but adds a budget.

7

u/MikoSqz Jan 25 '17

I'm shocked that it's ever not been a thing. Surely you'd implement that immediately next thing after implementing tabs in the first place.

9

u/amritoit Jan 25 '17

Much needed , I will expect memory optimization from Chrome in future, it takes lot of memories even with one tab for few applications like gmail inbox.

4

u/[deleted] Jan 26 '17

I hate when chrome tries to take my memories. So painful

→ More replies (1)

6

u/DonLaFontainesGhost Jan 26 '17

Can it please aggressively throttle videos that play automatically upon loading? I'm getting tired of having to wait for some godforsaken CDN to finish loading a video frame so I can pause it because I want to read the story, not hear it.

→ More replies (1)

11

u/Fidodo Jan 25 '17 edited Jan 25 '17

Background tab timers were always throttled, this is just a new strategy to do it. The best workaround IMO is to use web workers to do all the processing to lighten the workload of the main process. I believe web workers are purposefully non throttled because they are parallelizable, although I'm not sure of that. Ideally this will give you more flexibility to do light weight background processing with more flexible timers, since previously you were limited to a 1 second minimum throttle time no matter what. However the compute time per second sounds really low, but with the initial budget buffer and accumulation of budget, it might not be as bad as it sounds.

1

u/Coffeinated Jan 25 '17

Whatever a stupid webpage is doing in the background, if it can't be done in 100 ms every 10 seconds I probably don't really want it anyway. That should be more than enough to poll some information from whatever and I seriously don't know what else a webpage should do.

3

u/Fidodo Jan 25 '17

Most likely yes. Also, since that budget accumulates, it provides more flexibility that way as well.

1

u/kevin____ Jan 26 '17

While I agree with you, 100ms is excessive. There are other use cases for long-polling that aren't advert based and might take longer than that to respond.

14

u/AyrA_ch Jan 25 '17

If possible, you should not depend on a "stable" fire rate for timers, but instead compensate for delays (like this example I made a while ago)

10

u/useablelobster Jan 25 '17

Or, cry inside because Javascript still doesn't have a way to accurately measure the time between two instants in two thousand and seventeen.

I'm by no means a Javascript hater but that lack is pretty painful from time to time.

11

u/[deleted] Jan 25 '17

This fuzzing of time is a security feature. Firefox too goes to great lengths to prevent JS from having a very accurate time source.

9

u/ConcernedInScythe Jan 26 '17

Further reading on this?

5

u/goldcakes Jan 26 '17

Timing based side channel attacks.

5

u/erlingur Jan 25 '17

What about performance.now()?

2

u/AyrA_ch Jan 25 '17

Or, cry inside because Javascript still doesn't have a way to accurately measure the time between two instants in two thousand and seventeen.

console.time(). You can have up to 10'000 timers running at the same time. If you want to measure more than just execution time, then use console.profile(). profile is not in a standard but chrome, FF and IE support it.

4

u/PaintItPurple Jan 25 '17

Looking at the linked design document, it actually contemplates the problem the OP is worried about. The design doc notes that a random burst of activity could leave the page without CPU budget for minutes at a time, and suggests there should be a configurable maximum amount of time that pages can be blocked for.

This still wouldn't solve everybody's problems — for example, the other commenter who has a web-based MIDI application — but it does look like it will help with the "updates delayed for ridiculous amounts of time" problem.

6

u/kmeisthax Jan 26 '17

The only thing I'll agree with is that tabs with Notification access probably should be considered active tabs, in the same way that tabs with running audio are.

Aside from that, fuck background processing with a rusty iron. The web is not an application platform, and even if it was, applications shouldn't be background processing without a good reason. I don't need my phone dying because some idiot at Facebook needs to constantly monitor some random thing so they can show some context-sensitive reminder on their app. Good application platforms ramp that shit down to let your active task do what it needs to do.

6

u/Doctor_McKay Jan 26 '17

The web is not an application platform

But it is now.

6

u/stevenjd Jan 26 '17

The web is not an application platform

+1

Have an upvote.

3

u/[deleted] Jan 25 '17

What will this mean for people who enjoy incrementals / idle games and the like.

4

u/rezoner Jan 25 '17

Firefox? :)

3

u/[deleted] Jan 25 '17

this will be nice for when i go down the porn rabbit hole.

2

u/phoenix616 Jan 25 '17

I'm running one of the latest Chromium dev builds (should be 58 or something) and I never noticed any issues with this. Granted I suspend inactive background tabs via extension anyways but didn't notice anything strange with the sites whitelisted from the suspension..

2

u/crimzonphox Jan 26 '17

I think 57 will have it not 56. They are beta testing it in 56

2

u/ultramarioihaz Jan 26 '17

It's called the Great Suspender! Great extension.

2

u/zuchit Jan 26 '17

no wonder chrome has been crashing for me when i have youtube video playing on other tabs

2

u/mw44118 Jan 26 '17

I just discovered how chrome keeps session cookies alive even after closing the browser. This made it impossible as far as I know to log out users after they close the app.

So we set up a setInterval timer in background to verify that our site was still running.

And that seems to not work reliably either because background tabs don't always run javascript.

What am I supposed to do?

2

u/[deleted] Jan 26 '17

Can I get a fucking finally with my amen? Chromes resource usage (and most browser resource usage in general really) is insane. Chrome feels like it's trying to slowly suck my RAMs soul out, and yet it's still the best performing browser. Is rendering a modern web page and keeping it in memory really so hard a task that this can't be made a lot lighter?

5

u/meiso Jan 25 '17

How about a motherfucking option for a minimum tab width?

3

u/rapidsight Jan 25 '17

Yay! Chrome is starting to catch up with Safari!

3

u/bl4blub Jan 26 '17

just make sure youtube runs ^^

8

u/k-zed Jan 25 '17

Good, but not enough.

The web should be an information sharing and dissemination platform (focusing on content instead of presentation, as originally imagined), not a half-assed application platform. It'll never be better than it is now - it's only going to get bigger, slower and more complex this way.

We should make a clean break and reclaim the previous reality of simple, public, clearly defined protocols with numerous third-party implementations instead of a mess of proprietary spaghetti.

We should have NNTP instead of web forums again.

"Social media" should be services with public, documented APIs instead of web sites, and so on. (Like Twitter would be, if they didn't intentionally smother third-party clients with ridiculous limits.)

6

u/The_Mad_Chatter Jan 26 '17

The web should be an information sharing and dissemination platform (focusing on content instead of presentation, as originally imagined), not a half-assed application platform.

Why not both?

IMO the solution to this and a lot of other issues is just a way for webapps to properly identify themselves as webapps, and let browsers handle that in better ways. E.g this throttling business would just be a permission you grant when you first visit a site.

As bad as webapps can be, its SO much better than it used to be. Remember Java applets? And ActiveX? At least now webapps tend to be not just cross-OS but often cross-devicetype as well.

5

u/teadefrost Jan 25 '17

I've thought the same for quite a while now. I guess people don't like hearing the truth.

9

u/ViKomprenas Jan 25 '17

Why?

10

u/BigotedCaveman Jan 25 '17

Because the "web application" craze has resulted in the by far shittiest application platform ever created.

5

u/[deleted] Jan 26 '17

There are many really good web applications. Google has like five of them. I prefer Google sheets to numbers and google docs to pages and I just started using google music.

→ More replies (1)
→ More replies (9)

1

u/roffLOL Jan 26 '17

the web is moving there, intentionally or no. i abuse a whole bunch of *undocumented ajax endpoints as personal api:s.

*ehrm, i mean, they sort of reveal themselves after some clicking.

1

u/[deleted] Jan 26 '17

There are already lots of simple, public, clearly defined protocols with numerous third-party implementations out there. IRC, XMPP, RSS, bittorent, ftp, and countless others that still exist. The problem with those is they can't change rapidly. Facebook updates itself constantly, IRC never changes. So that's why these open protocols can't compete with plain old interactive websites.

1

u/[deleted] Jan 26 '17

But then how those service will monetize anything :) Previous reality didn't make that much money due to accessibility issues. And quality/profability of thrid party solutions.

Now, same applications but made as webapps (slack) are huge successes due to accessibility and ease of content sharing/viewing.

Question is, how there are so many shitty native applications (looking at you Skype/Lync) ?

6

u/shaan7 Jan 25 '17

the browser is no longer just a reading device; it is the world's largest application platform.

Thats the problem that needs to be fixed. Let the browser remain a reading device and write applications like they're supposed to be - not by hacking and patching a document markup to create applications.

6

u/Xxyr Jan 25 '17

Web applications are often a lot easier to manage than traditional applications in any number of ways.

For example my users don't have tp care what device they are on and what they have installed beyond "a web browser" nor do they have to deal with constant updates as new features are released and bugs fixed. They just suddenly have the new version on refresh.

There are so many advantages I cant understand wanting to go back to developing desktop apps as your primary platform for everything.

1

u/steamruler Jan 26 '17

However, I agree that work needs to be done to make the browser function better as a web application platform, while also capable of being a reasonably efficient reading device for everything that isn't a web application.

Let web applications say they are that, and let the user consent to the heavier load that it brings.

→ More replies (1)

2

u/rapidsight Jan 25 '17

Totally agree, 100%, you deserve a thousand upvotes. Ignore the down votes, because you are right.

2

u/rekrap1 Jan 25 '17

This is awesome

2

u/pkulak Jan 25 '17

Meh. It's not like Google doesn't have apps itself that run extensively in the background. I have two tabs open right now for Inbox and Music.

1

u/gigitrix Jan 25 '17

Sounds like the sort of thing where they should ramp it up to the aggressive threshold rather than start there today. Otherwise, it's great news for the user.

1

u/[deleted] Jan 25 '17

It's entirely possible they doing that, and the aggressive threshold goal is much higher.

1

u/gigitrix Jan 25 '17

Well my point being that that experimental data suggests a lot of immediate breakage. They should start lower down if it's as bad as it seems there, much like they phase in more security over time like deprecating weaker SSL cert configurations.

1

u/Jestar342 Jan 25 '17

What will this mean for libs like SignalR? My system uses signalr to let my users communicate over the web. I can't use a new signalr connection per-tab, we have to use one connection per terminal, and reconnecting every time the user switches is just no good.

1

u/[deleted] Jan 25 '17

Fuck this will break 2 of my sites. They already suffer other chrome-related issues though. Its my own bad design though honestly.

1

u/KyleRochi Jan 25 '17

Hopefully this resolves "google chrome helper"

1

u/[deleted] Jan 25 '17

As a user who currently uses firefox with 1gb of RAM I hope they also add this to firefox.

1

u/Gr1pp717 Jan 25 '17

How might this affect incremental/idle games that I leave running in the background?

1

u/mintysoul Jan 25 '17

Well, maybe I can come back from Opera because Chrome was unusable when I had 40+ tabs open.

1

u/Kougeru Jan 26 '17

Firefox already had option to unload background tabs. Group Tabs (removed but living through extensions) are unrivaled still though.

1

u/bumblebritches57 Jan 26 '17

When will it aggressively throttle the energy use on OS X?

1

u/c0shea Jan 26 '17

The recommendation from the Chrome team is to move this work to Service Workers.

Overall, I agree with this move. However, for those of us like myself who are forced to support IE11, that's a no-go. Believe me, I would love to live in a world where I only had to worry about making our company apps work in Chrome, but that's sadly far from the truth. In the meantime, I can see many being stuck with an even more fragmented code base to support even more diverse implementations in browsers. Great.

1

u/CurtainDog Jan 26 '17

So conflicted, the linked article argues against the action suggested in the title. How to resolve all these feels....

Oh well, downvote.

1

u/goodbyerpi Jan 26 '17

How will I load my 27 porn tabs at once then????

1

u/rydan Jan 26 '17

Will they aggressively throttle background non-tabs? My Chrome has always been full of memory and CPU leaks even days after all but one tab is closed. The only way to fix it is to close out everything completely.

1

u/thedracle Jan 26 '17

I hope NWJS and Electron find some way to patch or disable this.

1

u/TBSdota Jan 26 '17

Didn't chrome do this when it first launched?

1

u/[deleted] Jan 26 '17

I already use The Great Suspender (tab hoarder here), so it won't matter to me. It doesn't throttle, it puts unvisited tabs down after few minutes. I whitelist important stuff I want running in the background with it. The same (user whitelisting) will probably be available in this functionality when it reaches stable. Canary users will likely be able to disable it anyway.

1

u/siranglesmith Jan 26 '17

It's being released behind a flag in chrome 56, full release in chrome 57.

1

u/neilhighley Jan 26 '17

Terrible Idea. Its not for the browser to determine what tabs are useful or not.

-2

u/deus_lemmus Jan 25 '17

Screw you chrome, I load 30+ tabs simultaneously and want them to finish

37

u/lolomfgkthxbai Jan 25 '17

Finish what? Rendering a video you can't see or drawing text you can't read?

→ More replies (14)

6

u/[deleted] Jan 25 '17 edited Jul 11 '17

deleted 0.2649 What is ^^^this?

1

u/oridb Jan 25 '17

Can we have this for the current tab too please?

1

u/flukus Jan 25 '17

Yes, it's called noscript.

1

u/s0uly Jan 25 '17

Still no tree-style tabs. No thanks.

Separate windows for tabs doesn't count if tabs still exists and cannot be removed...

1

u/youngbrendo Jan 25 '17

EILI5: I get the gist of what's going on but there are a lot of terms and concepts being mentioned here that I'm not familiar with. Can someone provide a "for dummies" explanation of the implications of this and why some people would or would not want the throttling to happen?

3

u/ascii Jan 25 '17

Websites that want to use your CPU when you're not looking at the site will soon be aggressively throttled in Chrome. Safari has been doing this on iOS for a while. It will significantly reduce battery drain from unwanted, poorly coded ads as well as poorly coded or malicious websites. A large number of people will see significant improvements in battery life. Yay.

Except there are a lot of completely valid reasons for doing background processing:

  • Web players like YouTube or the Spotify web player still want to produce sound even when you're looking at another tab.

  • A chat app like Slack might want to receive updates when somebody says something so that whenever you switch to the slack tab, the latest comments are already there.

  • A web app like Dropbox where you upload big chunks of data might want to keep uploading your stuff even when you're not looking.

There are workarounds for some of these issues, and some of them might be an acceptable tradeoff in order to get better battery time, but if this change rolls out, a fair number of websites will break in Chrome.

1

u/youngbrendo Jan 26 '17

That helps a lot. Thanks!

1

u/jaman4dbz Jan 25 '17

As a web developer...

...that has a billion tabs open. Thank you!

1

u/panorambo Jan 27 '17

"I use setInterval to do shit, this will break the Web!"

Yeah, well, if the web-page you have written is not in users focus, then it should not be freely allowed to do those keep-alives or whatever else you deem is necessary for your application. It's not your browser, it's users' browser.

Users should decide which background tabs are alive and which should be dead, nothing more than thawed and re-frozen bookmarks.

There is no need to cry your eyes out, it will not break the Web. Just imagine that the user have closed your page, instead of having it open in a background tab. Utilize onFocus handlers to re-connect and do all the things that you think should not be your concern, whenever they activate the tab again.