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

Đang mở
#1,184 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
macos, rust, tauri
Lĩnh vực
audio-video-rtc, desktop

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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 常驻,未验证。
Ngôn ngữ chính
Rust
Star
3.7k
Fork
349
Merge trung bình
2 ngày 14 giờ
Pull request đã merge (30 ngày)
97

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Open-Less/openless

Tất cả issue của Open-Less/openless

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.