You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何强制Chromium浏览器在后台执行setInterval/setTimeout?

解决Chrome/Edge后台标签页中setTimeout/setInterval被严重节流的问题

问题描述

即使标签页未休眠,setTimeout/setInterval代码在Chrome/Edge后台标签页中最终会被严重节流,执行间隔逐渐变长直至基本停止。原本设定每秒执行一次的任务,日志显示间隔从几秒逐渐拉长到数分钟:

Took 1.6927670464932056 time to execute at Tue Mar 07 2023 15:03:26 GMT-0700 (Mountain Standard Time)
main-loop.service.ts:191 Took 1.6322318190016232 time to execute at Tue Mar 07 2023 15:03:29 GMT-0700 (Mountain Standard Time)
main-loop.service.ts:191 Took 1.6322318190016232 time to execute at Tue Mar 07 2023 15:03:29 GMT-0700 (Mountain Standard Time)
main-loop.service.ts:191 Took 1.5268028376189324 time to execute at Tue Mar 07 2023 15:03:31 GMT-0700 (Mountain Standard Time)
main-loop.service.ts:191 Took 1.5268028376189324 time to execute at Tue Mar 07 2023 15:03:31 GMT-0700 (Mountain Standard Time)
main-loop.service.ts:191 Took 1.4788079994765282 time to execute at Tue Mar 07 2023 15:03:34 GMT-0700 (Mountain Standard Time)
main-loop.service.ts:191 Took 1.4788079994765282 time to execute at Tue Mar 07 2023 15:03:34 GMT-0700 (Mountain Standard Time)
main-loop.service.ts:191 Took 1.4304450467780012 time to execute at Tue Mar 07 2023 15:03:36 GMT-0700 (Mountain Standard Time)
main-loop.service.ts:191 Took 1.4304450467780012 time to execute at Tue Mar 07 2023 15:03:36 GMT-0700 (Mountain Standard Time)
main-loop.service.ts:191 Took 1.4040571259142123 time to execute at Tue Mar 07 2023 15:03:46 GMT-0700 (Mountain Standard Time)
main-loop.service.ts:191 Took 1.4040571259142123 time to execute at Tue Mar 07 2023 15:03:46 GMT-0700 (Mountain Standard Time)
main-loop.service.ts:191 Took 1.428811537802659 time to execute at Tue Mar 07 2023 15:07:16 GMT-0700 (Mountain Standard Time)
main-loop.service.ts:191 Took 1.428811537802659 time to execute at Tue Mar 07 2023 15:07:16 GMT-0700 (Mountain Standard Time)
main-loop.service.ts:191 Took 1.4115845539280958 time to execute at Tue Mar 07 2023 15:10:16 GMT-0700 (Mountain Standard Time)
main-loop.service.ts:191 Took 1.4115845539280958 time to execute at Tue Mar 07 2023 15:10:16 GMT-0700 (Mountain Standard Time)

该场景是一款需要后台运行的游戏,可接受约15秒的执行间隔(此间隔在Firefox中正常),但无法接受Chrome/Edge的3分钟节流间隔。

有效解决方法

添加非零音量的背景音乐,用户可手动静音标签页,此时后台任务仍能正常执行,不会被浏览器节流。

内容的提问来源于stack exchange,提问作者Dyllon Gagnier

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.29 10:05:30