Skip to content

Bug: Voice recording freezes app (UI hang + 100% CPU) when WASAPI capture device delivers no data #1097

Closed

Description

@VirPoe

Bug: Voice recording freezes the app (UI hang + 100% CPU) when input device delivers no WASAPI data

Environment

  • OpenClaw Tray WinUI: 0.6.12.0 (.NET 10.0.9)
  • OS: Windows 10 19045 (x64)
  • Input device: generic USB microphone ("K69 Audio Device", VID_31B2&PID_0011) using Microsoft's generic USB audio driver (wdma_usb.inf)

Symptom

Clicking the voice-recording (STT) button in the chat page:

  1. Audio pipeline started: 48000Hz 32bit 2ch → 16kHz mono, VAD=energy, STT=loaded is logged
  2. A single thread spins at ~100% CPU (observed 87s of CPU in one thread, state = Running)
  3. The UI becomes unresponsive (freezes) until the process is killed
  4. No audio is ever detected (VAD never triggers; "cannot detect audio")

Root cause analysis

The TTS/STT pipeline uses WASAPI capture (via NAudio). On this machine the capture device opens successfully (an audio session appears on the device) but never delivers any data through WASAPI:

  • WASAPI shared mode, formats 48k 16/24/32-bit float, mono/stereo: 0 packets / 0 bytes in 3s polls (verified with raw IAudioClient/IAudioCaptureClient polling, and NAudio WasapiCapture with both event and poll paths)
  • MME (waveInOpen) on the same device: normal signal (RMS -41 dBFS)
  • Device claims IsFormatSupported(Shared, 48k/2ch float) = true, but capture silently returns nothing

So this is a device/driver quirk (generic USB audio class driver, WASAPI data path broken, MME works). Many USB microphones behave this way under wdma_usb.inf.

The bug in the Tray app

The pipeline never detects the zero-data condition:

  • It starts the capture successfully (no error is logged)
  • The capture thread apparently busy-spins waiting for data (100% CPU on one thread) instead of blocking or timing out
  • The UI thread is starved → total freeze
  • No timeout, no error message, no fallback

Expected behavior:

  • If WASAPI capture produces no data within a timeout (e.g. 2-3s), the pipeline should stop, log a clear error (device opened but no data), and surface it in the UI instead of spinning forever
  • The capture loop should not busy-spin; it should block on the device event / use GetNextPacketSize polling with a timeout

Reproduction

  1. Use any USB microphone whose WASAPI path delivers no data (generic USB audio class devices with broken WASAPI; MME still works)
  2. Start Tray, click the record button
  3. Observe freeze + single-thread 100% CPU

Suggested fix

  • Add a data-timeout watchdog to the capture loop; on timeout, fail gracefully with a user-visible message
  • Ensure the capture thread blocks (event wait / Sleep with timeout) instead of spinning when GetNextPacketSize returns 0 repeatedly

Log excerpt

[INFO] Whisper model loaded: %APPDATA%\OpenClawTray\models\ggml-small.bin
[INFO] Audio pipeline started: 48000Hz 32bit 2ch → 16kHz mono, VAD=energy, STT=loaded
(no further audio logs; UI frozen; process must be killed)

Activity

  1. added
    P1
    impact:crash-loop
    impact:ux-friction
    no-stale
    issue-rating: 🦞 diamond lobster
    clawsweeper:source-repro
    clawsweeper:queueable-fix
    clawsweeper:fix-shape-clear
    on Aug 5, 2026
  2. clawsweeper commented on Aug 5, 2026

    @clawsweeper

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed August 7, 2026, 4:59 PM ET / 20:59 UTC.

    Summary
    Keep open. Current main still has no first-audio timeout when WASAPI starts successfully but produces no nonempty callbacks, leaving the chat request waiting until its broad 120-second timeout.

    Reproducibility: yes. for the missing recovery path: current source starts capture without a first-data deadline and chat waits 120 seconds. The particular driver-induced CPU spin still needs Windows runtime proof.

    Root-cause cluster
    Relationship: canonical
    Canonical: #1097
    Summary: This is the canonical report for the missing WASAPI no-data recovery path; the linked wake-phrase PR is adjacent feature work.

    Members:

    Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

    Next step
    No open PR owns this source-proven failure path, and one focused repair can add detection, teardown, a user-visible recovery path, and regression coverage.

    Review details

    Best possible solution:

    Add a short first-audio watchdog in the shared capture owner, tear down capture on expiry, and route a clear recoverable microphone diagnostic to chat while preserving ordinary silence after audio begins.

    Do we have a high-confidence way to reproduce the issue?

    Yes for the missing recovery path: current source starts capture without a first-data deadline and chat waits 120 seconds. The particular driver-induced CPU spin still needs Windows runtime proof.

    Is this the best way to solve the issue?

    Yes. A first-data deadline at the shared capture boundary is the narrowest maintainable repair and avoids device-specific settings or fallback policy.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • The driver-specific busy-spin cannot be exercised in this Linux read-only checkout, so the repair needs deterministic no-callback coverage and current-head Windows proof that the UI remains responsive.

    Codex review notes: model internal, reasoning high; reviewed against 89666df49eb9.

    Label changes

    Label justifications:

    • P1: A voice-recording action can hang the active Tray app and prevent a user from continuing chat until they terminate it.
    • impact:crash-loop: The report and current failure boundary concern an application hang with sustained CPU use in the capture path.
    • impact:ux-friction: The current voice flow provides no targeted in-product recovery when a microphone opens but yields no audio.
    Evidence reviewed

    Acceptance criteria:

    • ./build.ps1
    • dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore
    • dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore
    • Focused deterministic no-callback capture regression test
    • Current-head Windows Tray proof showing timeout, diagnostic, and responsive chat UI

    What I checked:

    Likely related people:

    • Karen: Introduced the Reactor chat surface that owns the current voice-request lifecycle. (role: chat-surface feature author; confidence: medium; commits: 9acafa606a4d; files: src/OpenClaw.Tray.WinUI/Chat/OpenClawReactorChatRoot.cs)
    • Caleb Eden: Most recent current-main commit touching the Reactor chat source, adjacent to the suppressed voice-request error path. (role: recent chat contributor; confidence: low; commits: 89666df49eb9; files: src/OpenClaw.Tray.WinUI/Chat/OpenClawReactorChatRoot.cs)
    • Dallin Romney: Latest accessible history entry for the AudioPipeline file; it is style-only, so behavioral ownership remains uncertain. (role: recent audio-pipeline contributor; confidence: low; commits: 01bacff715c0; files: src/OpenClaw.Tray.WinUI/Services/AudioPipeline.cs)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
  3. added
    status: 🚢 actively landing
    and removed
    status: 🚢 actively landing
    on Aug 7, 2026
  4. locked as resolved and limited conversation to collaborators on Aug 10, 2026
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

    P1clawsweeper:fix-shape-clearclawsweeper:queueable-fixclawsweeper:source-reproimpact:crash-loopimpact:ux-frictionissue-rating: 🦞 diamond lobsterno-stale

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions