Chrome / Javascript SetTimeout stuck after computer goes to sleep

1.7k views Asked by At

I will try to explain ours problem the simpliest possible way. We are facing a tricky bug with our web application + chrome.

We have a web page displaying curves, the refresh of the curve is triggered by a setTimeout. If the computer goes to sleep and then wake up it looks like the setTimeout is not restarting. We have to press our "real time" button to relaunch the setTimeout and then it restarts properly.

Is there a way to fix this issue and to make the refresh of the page active when waking up from sleep ?

Update: We have 6 Chrome instances that display different curves. All auto-refreshing. We leave it for the night. In the morning, waking the computer up from sleep mode and all windows are here, no freeze but no refresh anymore. We have to press our "real time" button on each screen to restart the refresh.

1

There are 1 answers

3
sabithpocker On

Check if the focus event of the whole window or document is triggered when computer comes back from sleep. If its triggered reset your timers from those handlers.

if (/*@cc_on!@*/false) { // check for Internet Explorer
    document.onfocusin = onFocus;
    document.onfocusout = onBlur;
} else {
    window.onfocus = onFocus;
    window.onblur = onBlur;
}