[Feature Request] Revive the service worker on chrome.idle state change to fix unresponsive popup and partial theming after system sleep
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- typescript
- 领域
- frontend
调研方向
首先检查后台 service worker 入口点和 ui/popup/index.html,然后检查扩展清单如何声明权限,以及当前如何使用 chrome.alarms。验证 macOS 休眠后 Chrome 中的行为:popup 应该能够渲染,并且页面应接收到完整的 Dynamic mode theme,而不只是 fallback background。
由索引模型根据 Issue 内容生成。
描述
Prerequisites
- I searched for any existing report about this feature request to avoid opening a duplicate.
Is this feature request related to a problem?
Yes
Feature Request Description
Problem
Occasionally — most often after macOS wakes from sleep — Dark Reader's MV3 background service worker gets stuck in an unresponsive state. When this happens, two symptoms always appear together:
- Clicking the toolbar icon does nothing: the popup never renders (stuck before or at "Loading, please wait"). Since the options page is the same page (
ui/popup/index.html), settings become completely inaccessible. - Pages loaded during this state are only partially themed: the fallback dark background is applied, but the full Dynamic mode theme never arrives, leaving a half-dark page.
Toggling the extension off/on in chrome://extensions immediately fixes both symptoms, which points to the background service worker as the single shared failure point (both the popup and the content scripts depend on it for state/theme data).
This looks related to a known Chromium platform issue where an extension service worker becomes inactive and no longer wakes on incoming events (chromium-extensions thread). One reported trigger mechanism is that time spent in system sleep appears to be counted into the service worker's idle timer, which matches the "after wake from sleep" pattern I observe.
Proposed solution
Add the idle permission and register a chrome.idle.onStateChanged listener in the background service worker. chrome.idle.onStateChanged is a documented wake signal that Chrome delivers on OS resume / screen unlock, so it wakes the suspended worker directly:
chrome.idle.onStateChanged.addListener((newState) => {
if (newState === 'active') {
// lightweight state refresh / no-op extension API call
// to revive the worker and re-sync state
}
});
Dark Reader already uses chrome.alarms, but alarm ticks can be skipped across a deep sleep, so an idle-state hook is a more reliable revival trigger for this specific scenario. Prior art: another extension fixed the same post-sleep dead-worker problem this way (OpenCLI PR #1737).
Screenshots
No response
Additional Context
Environment:
- Dark Reader 4.9.129 (from Chrome Web Store)
- Chrome 151.0.7922.138 (stable), macOS
- Engine: Dynamic mode; "Detect dark theme" disabled; default theme values; settings storage healthy (verified locally)
Related reports:
- Discussion #13769 describes the same symptom (icon click does not open the popup while other extensions work fine, recovers by itself after a while)
- The 4.9.128 changelog entry "Fixed not working popup for some users" improved things, but the post-sleep case still occurs on 4.9.129
If a new install-time permission warning is a concern, idle could be requested as an optional permission and enabled from settings.
- 主要语言
- TypeScript
- 星标
- 22.6k
- 派生
- 2.8k
- 平均合并
- 1 天 17 小时
- 30 天内合并 PR
- 82
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
darkreader/darkreader 的其他 Issue
-
Broken Website
难度 2/5 1-3 小时 新手友好度 64/100
darkreader/darkreader#16259 ·
维护者通常 2 天内回复
-
Broken Website
难度 2/5 1-3 小时 新手友好度 72/100
darkreader/darkreader#16126 · 1 条评论 ·
维护者通常 2 天内回复
-
Pay to use?未关闭
难度 1/5 1 小时以内 新手友好度 66/100
darkreader/darkreader#16108 · 7 条评论 ·
维护者通常 2 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 70/100
darkreader/darkreader#16100 · 1 条评论 · 1 个 reaction ·
维护者通常 2 天内回复
-
Broken Website
难度 2/5 1-3 小时 新手友好度 72/100
darkreader/darkreader#15999 · 5 条评论 ·
维护者通常 2 天内回复
查看 darkreader/darkreader 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 67/100
knaw-huc/textannoviz#742 ·
-
难度 2/5 1-3 小时 新手友好度 88/100
cloudflare/realtimekit-ui#219 ·
维护者通常 1 天内回复
-
ui
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
tui: Mermaid renderer displays <b>/<strong> tags literally and ignores \n line breaks可能已有人在做 @argszero 今天认领。 未关闭area/tui platform/wsl status/repro-simulated type/bug version/v2
难度 2/5 1-3 小时 新手友好度 82/100
anomalyco/opencode#66773 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
mermaid-js/mermaid-v13#1370 ·
维护者通常 1 天内回复