New issue
Advanced search Search tips

Issue 735256 link

Starred by 1 user

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: 2017-06-29
OS: ----
Pri: 3
Type: Feature



Sign in to add a comment

consider throttling infinite repeating tasks in background tabs, e.g. for tab title/favicon changes

Project Member Reported by ojan@chromium.org, Jun 20 2017

Issue description

A number of sites infinitely toggle the tab title in background tabs (e.g. to notify of a chat). This is a nice feature, but doing it infinitely means burning a lot of the user's battery. We should look into throttling or curbing this in some way.
 

Comment 1 by ojan@chromium.org, Jun 21 2017

Made a test case: http://plexode.com/eval3/#s=aekVQXANLVQMbA2FKAR4BERw9T2ABVVBISE1GNUpVpAkKAVycAQFwD3aXAUoMDAEGExYBEwEgAT0DUE9GwgEbwQNVWFDCm09enJxURlUqT1VGU1dCTQmgoqSmqEYNARIR6goDDcNLS5IDEQNeAA==

var i = 0;
function toggleTitle() {
  document.title = i++ % 2 ? "one" : "two";
}
setInterval(toggleTitle, 1000)

Turns out Safari doesn't support changing the title at all. I assume they allow it to change from JS up until some point in the page load.

Comment 2 by ojan@chromium.org, Jun 21 2017

Hmmm...there's something more going on here in Safari. Google Hangouts is able to dynamically change the tab title.

Comment 3 by ojan@chromium.org, Jun 21 2017

I can't tell what Safari is doing. Sometimes my plexode link works and sometimes it doesn't. Sometimes Hangouts works and sometimes it doesn't. I made a modified version so I could background the tab first before tab title changed and it seems to also sometimes work.

http://plexode.com/eval3/#s=aekVQXANLVQMbA2FKAR4BERw9T2ABVVBISE1GNUpVpAkKAVycAQFwD3aXAUoMDAEGExYBEwEgAT0DUE9GwgEbwQNVWFDCm09enJxURlWmTkZQVlUJqpcfrK4B1VUqT1VGU1dCTQmgoqSmqEYNARIR+QqcXvYWfIRBQcAYNYZLJaSAYRAZeAA=

Comment 4 by ojan@chromium.org, Jun 21 2017

Cc: skyos...@chromium.org altimin@chromium.org
Labels: -OS-Chrome
This test case shows kind of what they're doing. When a tab is background they have some sort of super-linear backoff on setting tab title. I think that's actually just them increasingly throttling the background tab. We should probably figure out what they're doing.

http://plexode.com/eval3/#s=aekVQXANLVQMbA2FKAR4BERw9T2ABVVBISE1GNUpVpAkKAVycAQFwD3aXAUoMDJtPXpycVEZVpk5GUFZVCaqXH6yuAb5VKk9VRlNXQk0JoKKkpqhGDQESEeIKnF7fFuIRChwDDQNQS0uSAxEDXgA=

Comment 5 by ojan@chromium.org, Jun 21 2017

Can't say I understand what the logic is, but it looks like they grow up until a max clamp of 1 minute in background tabs.

I'm looking at the code as best I can tell and I'm not seeing this logic: https://trac.webkit.org/browser/webkit/trunk/Source/WebCore/page/DOMTimer.cpp. Interestingly it looks like the clamp setInterval on a per-timer basis and they clamp setTimeout completely differently based off nesting level.

http://plexode.com/eval3/#s=aekVQXANJVQMbAx1RU0YBSkUePQNNUEhIRlOdHx0QlkYfAw0DS5GTYUoBHgERHD1PYU1CVFU1Sk6YtSVCVUYPT1BYCQq4T2ABVaBITUbAVdbNAVy5AQFwD3a0mQwMz99hT0ZYwMLkxcfJy83o4A9uCQifoaMIBQPNABBi1To9XKdgaZhSdDYBhIMAIJdbtYKYBwBXi+dxGZzejK9X8WckUjjPL0IJ5UI0iYRQKxVBLbDwfbkflZVFRPY5TK5CJoJaahazYawNAISCNKBS5L1HpNLDisAZQJZLSQDCIDLwAA==

That page had this output:

1: 2004
2: 1405
3: 2000
4: 2511
5: 4481
6: 12601
7: 8366
8: 21469
9: 1909
10: 46944
11: 54846
12: 59998
13: 60604
14: 59391

Comment 6 by ojan@chromium.org, Jun 21 2017

Yeah, I give up finding the code for this.

Comment 7 by ojan@chromium.org, Jun 21 2017

Cc: ojan@chromium.org
Owner: ----
Summary: consider throttling infinite repeating tasks in background tabs, e.g. for tab title/favicon changes (was: consider throttling tab title and favicon changes)
Today we have time-based background throttling. I wonder if we should also have count-based throttling, e.g. 10 tasks per 10 minutes or something like that?

Thoughts/ideas welcome.

Comment 8 Deleted

Comment 9 by ojan@chromium.org, Jun 23 2017

NextAction: 2017-06-29

Comment 10 by ojan@chromium.org, Jun 23 2017

Status: Available (was: Assigned)
Labels: -Type-Bug Type-Feature
I wonder how widespread this problem is. Ojan, do you happen to have some examples or some data?

Comment 13 by ojan@chromium.org, Jun 26 2017

No data. The only examples I know of are google products with chat: hangouts, gmail, inbox. I know there are others out there, but this is just the anecdata I run into with my own browsing.
The NextAction date has arrived: 2017-06-29

Comment 15 by ojan@chromium.org, May 8 2018

Cc: -ojan@chromium.org

Sign in to add a comment