简体   繁体   English

计算机进入睡眠状态后Chrome / Javascript SetTimeout卡住了

[英]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. 我们的Web应用程序+ chrome面临着一个棘手的问题。

We have a web page displaying curves, the refresh of the curve is triggered by a setTimeout. 我们有一个显示曲线的网页,曲线的刷新由setTimeout触发。 If the computer goes to sleep and then wake up it looks like the setTimeout is not restarting. 如果计算机进入休眠状态然后唤醒,则看起来setTimeout没有重新启动。 We have to press our "real time" button to relaunch the setTimeout and then it restarts properly. 我们必须按下“实时”按钮重新启动setTimeout,然后才能正常重启。

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. 更新:我们有6个Chrome实例显示不同的曲线。 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. 检查计算机从睡眠状态恢复时是否触发整个windowdocumentfocus事件。 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;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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