[macos] 空闲时常驻音频输出会话,阻止系统空闲睡眠导致整夜耗电

未关闭
#1,184 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
macos, rust, tauri

调研方向

Start by reproducing the issue with OpenLess idle on battery, then trace audio output setup and teardown in the frontend and native app; the report does not identify specific files or tests. Check whether an audio context or output session remains active after startup and after short sounds. Done means idle and post-sound audio assertions are released within seconds, sleep works, and dictation shortcuts and sounds still work.

由索引模型根据 Issue 内容生成。

描述

bug
现象

现象

  • 环境:MacBook Pro(M3 Max),macOS 26(Darwin 25.6.0),电池供电。OpenLess 1.3.18。
  • 触发条件:OpenLess 一启动就会出现,无需使用听写;之后在后台运行(未录音、未播放声音),用户按电源键锁屏/关闭显示器后离开,不合盖。
  • 当前表现:OpenLess 的 WebKit GPU 进程(com.apple.WebKit.GPU.xpc)在 coreaudiod 中持续持有音频输出上下文,coreaudiod 据此创建 PreventUserIdleSystemSleep assertion,即使没有任何声音播放也不释放。系统因此无法进入空闲睡眠,整夜保持唤醒直到电量耗尽。退出 OpenLess 后该进程消失,assertion 同时释放。
  • 证据:

验证时只运行 OpenLess(已退出其他可能占用音频的应用),pmset -g assertions,PID 24081 为 OpenLess 的 WebKit GPU 进程:

pid 421(coreaudiod): [0x00035d8c00018824] 00:01:26 PreventUserIdleSystemSleep named: "com.apple.audio.30-7A-D2-73-9A-51:output.context.preventuseridlesleep"
    Created for PID: 24081.
    Resources: audio-out 30-7A-D2-73-9A-51:output

蓝牙耳机断开后,会切换到内置扬声器继续持有(当时 OpenLess 的 WebKit GPU 进程为 PID 2492):

pid 421(coreaudiod): PreventUserIdleSystemSleep named: "com.apple.audio.BuiltInSpeakerDevice.context.preventuseridlesleep"
    Created for PID: 2492.
    Resources: audio-out BuiltInSpeakerDevice

pmset -g log(2026-10-12 晚):19:47 按电源键关闭显示器后,上述 assertion 在每 15 分钟的 Summary 中持续存在,期间没有任何 Sleep 记录,直到次日 07:44 电量降到 1% 进入 Low Power Sleep:

2026-10-12 19:47:53 +0900 Notification  Display is turned off
2026-10-13 03:02:53 +0900 Assertions    PID 421(coreaudiod) Summary PreventUserIdleSystemSleep "com.apple.audio.BuiltInSpeakerDevice.context.preventuseridlesleep" 07:13:17
2026-10-13 07:44:35 +0900 Sleep         Entering Sleep state due to 'Low Power Sleep':TCPKeepAlive=inactive Using Batt (Charge:1%)

ps -p 2492 -o comm= → .../com.apple.WebKit.GPU.xpc/...;退出 OpenLess 后 pmset -g assertions 中不再有该 assertion。

影响

影响

  • macOS 笔记本用户在电池供电下锁屏离开(不合盖)时,系统无法自动睡眠。实测 M3 Max 约 12 小时从 79% 耗尽到 1%。
  • 用户难以定位:活动监视器和 pmset 中显示的是 coreaudiod / WebKit GPU 进程,而不是 OpenLess。
  • 合盖或手动「睡眠」可以规避,但依赖用户习惯;作为常驻后台的听写工具,影响面较大。
建议接受标准

建议接受标准

  • OpenLess 空闲(未录音、未播放提示音)时,pmset -g assertions 中不存在由 OpenLess(含其 WebKit GPU 进程)创建的 PreventUserIdleSystemSleep 音频 assertion。
  • 播放提示音等短音频后,音频输出上下文在数秒内释放。
  • 锁屏并关闭显示器后,系统能按 pmset 的 sleep 设置正常进入空闲睡眠(pmset -g log 中可见 Sleep 记录)。
  • 快捷键唤起听写、提示音等现有功能不受影响。
TODO / 不确定项
  • 尚未确认是哪里一直开着音频输出:WebView 里的 AudioContext 或 <audio> 没有 suspend/close,还是原生侧。推测是前端的 AudioContext 常驻,未验证。
主要语言
Rust
星标
3.7k
派生
349
平均合并
2 天 14 小时
30 天内合并 PR
97

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Open-Less/openless 的其他 Issue

查看 Open-Less/openless 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。