tabs keep running after 5 minutes with the screen off on mobile |
||||||
Issue descriptionWe pause script in background tabs after 5 minutes, but not in the foreground tab if just the screen is off. We pause eventually, but not at 5 minutes. I used this test case: http://jsbin.com/duvigohudi/edit?html,output <!DOCTYPE html> <div id="out"></div> <script> function f() { out.innerHTML += "Woo I'm a timer -- " + new Date() + '<br>'; } setInterval(f, 1000); </script> What I saw on my device was a page that started at 14:38:30, was backgrounded after a few seconds and didn't pause until 15:10:54. So it took ~20 minutes.
,
Dec 8 2016
Assigning to Ojan for comments :)
,
Mar 19 2017
Here's a slightly better test case: http://jsbin.com/guxaminume/1/edit?html,console <script> window.addEventListener('visibilitychange', function(e) { console.log(document.visibilityState); if (document.visibilityState != 'hidden') { setTimeout(function() { clearInterval(logger); }, 20000) } }); var logger = setInterval(function() { console.log(Date.now() / 1000); }, 5000); </script> I'm not really sure what's happening. Sometimes I get 5 minutes and other times it seems to never stop. I'm trying to figure out what the pattern is.
,
Jan 13 2018
FWIW, I'm still able to reproduce this. There's a lot of variance, but I just saw one run of 6 minutes before it was paused and one run where it's 14 minutes. Is noone else able to reproduce this?
,
Jan 15 2018
That's really weird. Have you had DevTools connected by any chance? Not sure if it would be affecting this, but at some point I discovered they permanently disable screen dimming until Chrome is restarted.
,
Jan 16 2018
Fadi could you try out this test case along with current suspension logic on mobile? Is this related to the renderer not knowing the correct background state?
,
Jan 16 2018
Yes, I have been looking at similar issues and I was planning to own it.
,
Jan 24 2018
My preliminary investigation, when the screen is turned off, the hidden and backgrounded signals are triggered in the RendererScheduler code in chromium, but they did not trigger in a single process webview. I have tested that on a device with M and with O android. There is a chance that my recent fixes solved the issue as they dealt with a very similar problem. (I will revert them and retry the tests).
,
Jan 24 2018
I reran the jsbin tests listed above with a shortened sleep time (5 seconds instead of 5 minutes), and the timers seems to stop as expected. ojan: Can you retest it on latest canary and let me know if the problem still persists, if so, I am curious about your exact setup.
,
May 8 2018
,
Jul 13
This issue seems to have been resolved. |
||||||
►
Sign in to add a comment |
||||||
Comment 1 by skyos...@chromium.org
, Dec 1 2016284 KB
284 KB View Download