New issue
Advanced search Search tips

Issue 670102 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner:
Closed: Jul 13
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 2
Type: Bug



Sign in to add a comment

tabs keep running after 5 minutes with the screen off on mobile

Project Member Reported by ojan@chromium.org, Nov 30 2016

Issue description

We 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.
 
Hmm, which device are you using? Here's what I see on a Nexus 6P (Android N):

- Screen off at 15:31.
- Timer stops at 15:36.
- Screen on at 15:40.

By the way, what do you mean by "backgrounded after a few seconds"?
Screenshot_20161201-154029.png
284 KB View Download
Cc: skyos...@chromium.org
Owner: ojan@chromium.org
Assigning to Ojan for comments :)

Comment 3 by ojan@chromium.org, 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.

Comment 4 by ojan@chromium.org, Jan 13 2018

Cc: panicker@chromium.org altimin@chromium.org fmea...@chromium.org
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?
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.

Comment 6 by panicker@google.com, Jan 16 2018

Cc: ojan@chromium.org
Owner: fmea...@chromium.org
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?
Yes, I have been looking at similar issues and I was planning to own it.
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).
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.

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

Cc: -ojan@chromium.org
Status: WontFix (was: Assigned)
This issue seems to have been resolved.

Sign in to add a comment