New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 689436 link

Starred by 1 user

Issue metadata

Status: Duplicate
Merged: issue 166153
Owner: ----
Closed: Oct 3
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 2
Type: Bug



Sign in to add a comment

Android power save appears to rewrite timeouts values in setTimeout. Coming out of powersave doesn't restore them.

Reported by alank...@bel.fi, Feb 7 2017

Issue description

Steps to reproduce the problem:
1. Put Android device into powersaving mode from Settings > Battery

2. Create a web page that chains setTimeout calls, e.g.

  function timeoutBug() {
      console.log("Fired at " + new Date());
      setTimeout(timeoutBug, 60000);
  }
  timeoutBug();

3. Wait one minute with screen off. This allows timer to fire once, which creates a new timer during powersave. Turn screen back on. The setTimeout timer fires much later than 1 minute, despite the screen is on again.

What is the expected behavior?
JavaScript developers at large probably expect any setTimeout throttling to go away as soon as screen is turned on and the page is again in view, e.g. if the event is already delayed with respect to its proper timeout value, it should then be fired ASAP.

This matters for web framework called Ember, but possibly others. In Ember, there is a runloop called Backburner which does its work via setTimeout calls. If Ember application asks work to be scheduled during powersave, then Chrome adjusts its timeout value to some future time way past the actually requested timeout value. However, Backburner is not aware of this adjustment. Backburner attempts to avoid clearing and setting timeouts, so it is keeping an estimation of the time when the setTimeout call will fire next time, and if work is scheduled to occur after that estimated time, it simply puts it into a queue to be run next time when the setTimeout will fire.

Because Chrome delays the timeout firing much further than backburner expects, this means that work scheduled to occur in the next millisecond is already way past the time the setTimeout should have fired, so it just goes into the queue. No new setTimeouts are performed to deal with this situation. This interplay between backburner's expectations and Android Chrome's powersaving results in a temporarily stalled runloop in Ember applications.

What went wrong?
Saving power through throttling setTimeout is not a bad idea. But the implementation should stop powersaving as soon as user continues interacting with the device, and should check if any timeouts have elapsed and fire them immediately.

Did this work before? N/A 

Chrome version: 55.0.2883.91  Channel: stable
OS Version: any
Flash Version:

 
Cc: gab@chromium.org altimin@chromium.org alexclarke@chromium.org
Components: -Blink Blink>Scheduling
Interesting, does this reproduce *without* enabling power saving mode?

Comment 2 by alank...@bel.fi, Feb 7 2017

No, it is a requirement that the device has entered the OS-level power saving mode. Merely putting screen off won't do it.

In my case, the issue manifested only when the Android tablet had been unused for over 30 minutes, and was not connected to a charger.
Status: Available (was: Unconfirmed)
Project Member

Comment 4 by sheriffbot@chromium.org, Feb 13 2018

Labels: Hotlist-Recharge-Cold
Status: Untriaged (was: Available)
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue.

Sorry for the inconvenience if the bug really should have been left as Available. If you change it back, also remove the "Hotlist-Recharge-Cold" label.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Status: Available (was: Untriaged)
Mergedinto: 166153
Status: Duplicate (was: Available)
This is due to the monotonic clock on Linux and Android not advancing while the device is suspended. There's a longstanding bug for this.

Sign in to add a comment