简体   繁体   中英

Chrome / Javascript SetTimeout stuck after computer goes to sleep

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.

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;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM