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

Aperta
#1,184 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
macos, rust, tauri

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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 常驻,未验证。
Lingua principale
Rust
Stelle
3.7k
Fork
349
Merge medio
2g 21h
PR unite (30g)
100

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Open-Less/openless

Tutte le issue di Open-Less/openless

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.