Skip to content

fix(audio): 提示音结束后释放 Web Audio 输出 - #1427

Open
Theigrams wants to merge 1 commit into
Open-Less:betafrom
Theigrams:personal/fix-audio-cue-idle
Open

Theigrams wants to merge 1 commit into
Open-Less:betafrom
Theigrams:personal/fix-audio-cue-idle

Conversation

@Theigrams

Copy link
Copy Markdown

摘要

关联 #1184。基于当前 beta 继续 #1248 中 Rpeng666 提出的按需创建、播完释放方案。

macOS 上,胶囊窗口挂载时会预热录音提示音。即使关闭提示音,空闲的 WebKit GPU 进程仍可能持有扬声器输出,并在播放其他声音时伴随大量 CoreAudio I/O 过载和爆音。

修复 / 新增 / 改进

  • 移除启动预热,只在录音提示音或设置页预览播放时创建 AudioContext。播放结束或录音停止后释放输出,关闭提示音或卸载监听器时取消待播放请求。
  • 处理在原生 WKWebView 中观察到的竞态。若 close() 完成后,迟到的 resume() 又让旧上下文报告 running,再次关闭旧上下文。回归测试覆盖该状态序列及连续触发时的资源清理。

兼容

  • 生产代码范围仅限 AudioCue.tsx 和 audioCue.ts。沿用当前胶囊窗口的事件订阅和设置页预览入口。
  • 保留提示音的音色、快速录音的延迟反馈及现有设置格式。无需迁移配置或新增依赖。

测试计划

  • 通过 audio-cue-runtime.test.mjs、audio-cue-window-contract.test.mjs、capsule-ready-replay.test.mjs 和 audioCue.test.ts。
  • 在 Apple Silicon macOS 27.2 上构建并运行两个完整 Tauri App,同以 aff704b1 为基线。两次均关闭录音提示音且保持 OpenLess 未录音,通过同一内置扬声器用 afplay 播放同一个 30 秒本地 WAV。记录 Unified Log 和 CoreAudio 活跃输出客户端。
播放观察窗口 未修复 beta(30.9 秒) 修复版(32.9 秒)
CoreAudio 过载相关日志 11,171 0
WebKit 跳过音频周期 871 0
WebKit GPU 处于音频输出状态的采样 14/14 0/15

外部音频停止后的约 5 秒内,未修复版继续占用输出并跳过 94 次音频周期,修复版为 0。本次实机对照以音频输出状态和系统日志为依据,覆盖上述播放复现窗口。

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-10T14:16:06.034419Z
We couldn’t complete this review. Comment @codex review to try again.
078202c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant