Skip to content

[Windows] [bug] 语音输入不显示录音胶囊 #470

Closed

Description

@Jefforry

现象

现象:

  1. 每次语音输入时,桌面不会显示任何UI提示,没有看到语音胶囊
  2. 使用环境:电脑 Windows 10,Openless 版本 1.3.2
    3.版本 Windows 10 专业版
    版本号 22H2
    安装日期 ‎2025/‎05/‎18
    操作系统内部版本 19045.5854
    体验 Windows Feature Experience Pack 1000.19061.1000.0

影响

这是一个基础 bug,在 Windows 上,我看不到语音胶囊,缺少必要的视觉交互指引.

建议接受标准

辛苦了,请查一下,这个必须修复的哟

TODO / 不确定项

No response

Activity

  1. added
    bug
    on May 18, 2026
  2. appergb commented on May 18, 2026

    @appergb
    Collaborator

    在开关设置中打开录音胶囊。

  3. Jefforry commented on May 18, 2026

    @Jefforry
    Author

    在开关设置中打开录音胶囊。

    我不至于犯这么低级的错误,是已经打开了也看不到胶囊才来反馈的

  4. added 2 commits that reference this issue on May 18, 2026
  5. appergb commented on May 18, 2026

    @appergb
    Collaborator

    @Jefforry 这一条还没真正修,但本次 Beta v1.3.4-3 加了诊断日志,能帮我们一起定位根因。

    目前的判断:维护者 @appergb 之前在评论里建议「在开关设置中打开录音胶囊」——这说明默认开关可能被关了。但你也确认是 1.3.2 最新版了,所以可能不是开关问题,而是 Win 上 SW_SHOWNOACTIVATE / HWND_TOPMOST 在某些环境下被 OS 拦了(比如管理员 / 全屏游戏 / 特定 DWM 配置)。

    新版加了两条 per-process 一次性 info log,能直接告诉我们走到了哪一步:

    • [capsule] first show this session: show_capsule=true visible=true state=recording —— 表示开关是开的,Win32 show 也调了。如果出现这条但你确实没看到胶囊,就是 OS 层 topmost 被拦。
    • [capsule] suppressed by user toggle: show_capsule=false visible=true state=recording —— 表示你的设置里开关是关的,请去设置里打开「录音胶囊」。
    • 都没出现 —— 录音状态机没走到 emit_capsule,是更上层问题。

    下载:https://github.com/Open-Less/openless/releases/tag/v1.3.4-3-beta-tauri
    Windows 用 OpenLess_1.3.4-3_x64-setup.exe 或 OpenLess_1.3.4-3_x64_en-US.msi。

    辛苦你帮忙做一下:

    1. 装上 1.3.4-3
    2. 触发一次语音输入(你平时复现胶囊不显示的那种场景)
    3. 退出 OpenLess
    4. 把 %APPDATA%\com.openless.app\logs\openless.log 里包含 [capsule] 的行贴回这个 issue

    拿到日志立即跟进根因。感谢配合 🙏

  6. added a commit that references this issue on May 18, 2026
  7. Cooper-X-Oak commented on May 18, 2026

    @Cooper-X-Oak
    Contributor

    This was generated by AI during triage.

    已纳入 Windows beta 高频反馈第一轮修复:#480。

    这条反馈会和 #476 一起归到胶囊/悬窗生命周期 P0:Windows 触发语音输入后必须能稳定显示录音胶囊。后续会优先确认是 hotkey/coordinator 已触发但 capsule window 没显示,还是窗口创建/置顶/可见性路径出了问题。

  8. byte92 commented on May 24, 2026

    @byte92

    @appergb mac端也遇到相同问题,胶囊不显示

  9. appergb commented on Jun 4, 2026

    @appergb
    Collaborator

    按理来说应该不会吧?我看一下日常的实际。你等我看看日常的实际,这个确实是个严重 bug,我正在修复。

  10. added a commit that references this issue on Jun 4, 2026
  11. added a commit that references this issue on Jun 4, 2026
  12. added a commit that references this issue on Jun 8, 2026
  13. added a commit that references this issue on Jun 8, 2026
  14. 5 remaining items

  15. appergb commented on Jun 14, 2026

    @appergb
    Collaborator

    @claude 整合所有代码,对全部代码进行分析,找出还有类似于这样被骂成屎山的代码——比如存在性能问题的代码。具体的性能问题例如:托盘麦克风监听 1.5 秒执行一次,所有音频设备永久运行,每天约 4 万次。像这种逆天的代码就不要再放进来了。审查一下还有哪些代码是这样的,以及是谁提交的,把提交者全部拉出来。

  16. claude commented on Jun 14, 2026

    @claude

    Claude finished @appergb's task in 4m 24s —— View job


    代码性能审查报告

    • 读取 CLAUDE.md(未找到,跳过)
    • 探索代码库结构
    • 搜索轮询/定时器模式(setInterval、setTimeout、永久监听)
    • 搜索音频设备监听相关代码
    • 搜索托盘/系统级永久运行代码
    • 搜索其他性能问题模式
    • Git blame/log 归因(⚠️ 当前分支只有一个 Cask 自动发布 commit,无法 blame 到个人)
    • 汇总报告

    说明:该分支只有一次自动发布 commit(14802f3),git blame 只能指向 bot,无法追溯到个人提交者。以下分析按代码中的注释线索、Issue 评论上下文推断责任方。


    🔴 严重问题(已存在或仍存在的逆天设计)


    1. 托盘麦克风设备轮询 — 已从 1.5s 改到 10s,但根本方案未做

    文件:src-tauri/src/lib.rs:921

    // 10s, not 1.5s. `list_input_devices()` is a relatively costly
    // CoreAudio/WASAPI enumeration and this ran every 1.5s forever —
    // the single biggest idle wakeup. The tray menu refreshes on hover
    // and the settings page reacts to `microphone:devices-changed`, so
    // ~10s detection latency is fine. (Proper fix: subscribe to an OS
    // device-change notification instead of polling.)
    std::thread::sleep(Duration::from_millis(10_000));
    • 原来:每 1.5s 枚举一次全部音频设备,24 小时 = 57,600 次 CoreAudio/WASAPI 调用,永不停歇
    • 现在:改到 10s,好一些,但 24h 仍 8,640 次无效轮询
    • 应该:改用 OS 原生设备变更通知(macOS: AudioObjectAddPropertyListener,Windows: IMMNotificationClient),设备不变就不唤醒
    • 代码自己的注释已经说了正确答案,但还没人去做

    2. 7 个结构完全相同的 Hotkey Supervisor 轮询线程

    文件:src-tauri/src/coordinator.rs,共 7 个,永久运行,每个睡 5s 醒一次

    函数 行号 说明
    hotkey_supervisor_loop L663 主录音快捷键
    qa_hotkey_supervisor_loop L677 QA 快捷键
    coding_agent_hotkey_supervisor_loop L687 Less Computer 快捷键
    combo_hotkey_supervisor_loop L722 组合键
    translation_hotkey_supervisor_loop L734 翻译快捷键
    action_hotkey_supervisor_loop(SwitchStyle) L746 切换风格快捷键
    action_hotkey_supervisor_loop(OpenApp) L758 打开 App 快捷键

    这 7 个函数的代码结构几乎一模一样(combo_hotkey_supervisor_loop vs translation_hotkey_supervisor_loop vs action_hotkey_supervisor_loop 可以直接 diff 对比),都是:

    loop {
        if inner.shutdown.load(...) { return; }
        // 检查 prefs,如果不需要就 sleep 5s 继续
        std::thread::sleep(Duration::from_secs(5));
        // 注册快捷键,失败就 sleep 3s
        std::thread::sleep(Duration::from_secs(3));
    }

    问题:

    • 快捷键一旦注册成功,线程继续每 5s 醒来检查 prefs → 读一把锁 → 发现没变 → 继续睡。7 个线程 × 每天 17,280 次无效唤醒 = 每天 120,960 次空转读锁
    • 7 份几乎相同的代码,600+ 行重复逻辑,coordinator.rs 已经膨胀到 7,025 行
    • 正确方案:注册成功后阻塞在 channel recv() 上(已有 bridge_loop 这么做了),supervisor 线程注册完就退出。prefs 变更通过 watch channel 推送给注册逻辑。

    🟡 中等问题(设置页 / 引导页的轮询)


    3. Onboarding 桌面引导每 1000ms 轮询权限

    文件:src/components/Onboarding.tsx:303

    const id = window.setInterval(refresh, 1000);  // 每秒调一次 checkAccessibilityPermission + checkMicrophonePermission

    refresh 同时调 checkAccessibilityPermission() + checkMicrophonePermission() 这两个 IPC,后者在 macOS 会短暂打开 CoreAudio 输入流。只要 Onboarding 页没完成,这就每秒烧两次 IPC。

    • 改法:改用 window:focus + 用户点击按钮后的单次刷新,完全不需要定时器

    4. Android Onboarding 每 3000ms 轮询麦克风权限

    文件:src/components/Onboarding.tsx:223

    const id = window.setInterval(refresh, 3000);  // Android 引导页每 3s 检查麦克风

    Android 的 checkAndroidMicrophoneAccess() 走 JNI,重量级。已有 focus 事件监听,定时器多余。

    5. PermissionsSection 热键状态每 1000ms 轮询

    文件:src/pages/settings/PermissionsSection.tsx:84

    const hotkeyId = platformCaps?.supportsDesktopHotkey === true
      ? window.setInterval(refreshHotkey, 1000)   // 每秒向 Rust 端查一次快捷键状态
      : undefined;

    设置页打开期间每秒调一次 getHotkeyStatus() IPC。热键安装状态是事件驱动的,完全可以由 Rust 端通过 emit 推送状态变更,不需要 frontend 轮询。

    6. LocalAsr 引擎状态每 5000ms 轮询

    文件:src/pages/LocalAsr.tsx:510

    engineStatusTimer.current = window.setInterval(() => {
        void refreshEngineStatus()
    }, 5000)  // 本地 ASR 页面打开时每 5s 轮询引擎状态

    引擎启动/停止是可以通过 Tauri emit 推送的事件,不需要轮询。


    🟠 代码结构问题(屎山成因)


    7. coordinator.rs 单文件 7,025 行

    所有 hotkey supervisor、coordinator 状态机、录音流程、胶囊逻辑、IPC 分发全部在一个文件里。这直接导致每次修 capsule bug 都要在一个近万行的文件里找代码。jiangmuran 叫它"屎山"完全是因为这个。

    8. Marketplace.tsx 双重 setTimeout 冗余刷新

    文件:src/pages/Marketplace.tsx:390

    window.setTimeout(() => { void refresh(); void refreshMyPacks(); }, 1500);
    window.setTimeout(() => { void refresh(); void refreshMyPacks(); }, 5000);

    上传完成后同一个 refresh 被触发两次(1.5s 和 5s),不清楚为什么不直接 await 上传完成后刷一次。

    9. LocalAsr.tsx 三连 setTimeout 强制滚动

    文件:src/pages/LocalAsr.tsx:203

    window.setTimeout(restoreScrollGuard, 0)
    window.setTimeout(restoreScrollGuard, 80)
    window.setTimeout(restoreScrollGuard, 200)

    同一个函数被射了三次延时,再加两个 requestAnimationFrame,是典型的"布局抖动修不好就多射几次定时器"的屎山写法。


    归因(基于 Issue 评论上下文)

    由于当前 checkout 只有一个 bot 提交,无法通过 git blame 归因。根据 Issue 评论:

    代码区域 推断提交方
    托盘麦克风从 1.5s 改 10s @appergb(注释风格一致,且是主要维护者)
    Mac capsule 不显示修复 @jiangmuran(本人在 #470 评论确认)
    coordinator.rs 大量重复 supervisor loop 历史积累,多人参与,@chris233 被 @appergb 点名为代码审核方
    Onboarding 1s 轮询、PermissionsSection 1s 轮询 无法确认,需看主仓库 git blame

    优先级建议

    优先级 问题 收益
    P0 托盘麦克风改用 OS 通知,彻底停轮询 消灭最大 idle 唤醒源
    P1 7 个 supervisor 线程注册成功后退出,靠 prefs watch channel 驱动 减少 12 万次/天空转
    P1 coordinator.rs 拆分文件 降低后续 bug 引入概率
    P2 Onboarding / PermissionsSection 改事件驱动,删定时器 消灭设置页 idle 轮询
    P2 LocalAsr / Marketplace 清理冗余 setTimeout 代码可读性
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1Windowsarea:uibug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions