Skip to content

fix: skip real AudioContext in Voice Mode onboarding preview under tests (build fix for vscode-engineering#3742) - #333858

Open
VS Code PR Bot (vscodebot-pr) wants to merge 3 commits into
microsoft:mainfrom
vscodebot-pr:fix-voice-onboarding-audiocontext-test-hang-aw-33552213184
Open

fix: skip real AudioContext in Voice Mode onboarding preview under tests (build fix for vscode-engineering#3742)#333858
VS Code PR Bot (vscodebot-pr) wants to merge 3 commits into
microsoft:mainfrom
vscodebot-pr:fix-voice-onboarding-audiocontext-test-hang-aw-33552213184

Conversation

@vscodebot-pr

Copy link
Copy Markdown
Contributor

Build failure

The Run unit tests (Electron) task on the macOS insider stage hung and hit the task timeout right after the Voice Mode onboarding suite. The runner emitted a burst of [WARNING:services/audio/sync_reader.cc] SyncReader::Read timed out, audio glitch count=... messages, then produced no further output for ~14 minutes until it was killed, so .build/logs was never written and the downstream publish/verify steps cascaded.

Root cause

VoiceSamplePlayer.ensureAudio() in src/vs/workbench/contrib/agentsVoice/browser/voiceModeOnboarding.ts always constructs a real AudioContext and connects the analyser to context.destination:

const context = new targetWindow.AudioContext();
const analyser = context.createAnalyser();
context.createMediaElementSource(audio).connect(analyser);
analyser.connect(context.destination);

The onboarding tests inject a deterministic audio element via the audioFactory option, but nothing suppresses the real AudioContext. Connecting the analyser to context.destination opens the host's real audio output device. In headless Electron that device keeps polling for audio with no live producer, which is exactly what the repeated SyncReader::Read timed out glitch warnings report. Combined with the sample-playback tests (clicking the playing voice..., previews the native voice..., swaps the chips...) that each trigger a preview, the open output stream stalls the runner and the whole test task times out.

The AudioContext graph is best-effort waveform decoration only; the sample plays regardless. It was safe in interactive use but unsafe in headless CI, and there was no way for a test to opt out.

How the fix works

When a caller supplies its own audioFactory (only tests do), ensureAudio() now returns the injected element immediately and skips building the AudioContext/analyser graph. No real audio output device is opened, so the SyncReader polling loop never starts and the runner no longer stalls. Production code paths, which never pass audioFactory, are completely unchanged and still get the waveform analyser. The guard reuses the existing audioFactory field, adds no new types or imports, and preserves all existing logging.

Rollback evaluation

  • Recommendation: Do not roll back.
  • Public culprit commit/PR: not confirmed. The pre-existing AudioContext/destination graph was introduced earlier (in the initial Voice Mode onboarding change) and is the mechanism of the hang; the change that immediately preceded the failing build reworked the voice test setup and surfaced the stall, but source inspection does not establish it as the code-level cause.
  • Rationale: the fix-forward is a bounded, test-only guard with no production behavior change, so it is lower risk than reverting any recent voice work and does not require owner confirmation of revert safety.
  • Owners to consult: @meganrogge

Validation

Static source inspection only. The repository dependencies were not installed in this environment (node_modules absent), so npm run typecheck-client and the Electron unit test task could not be run here. The change is a single early-return guard using an existing field with no new imports or types. Reviewers should run the agentsVoice browser tests (voiceModeOnboarding.test.ts) in Electron to confirm the suite no longer hangs and emits no SyncReader::Read timed out warnings.

Risk

Low. The behavioral change is limited to callers that pass an audioFactory override, which is only the tests. Interactive Voice Mode onboarding still constructs the analyser graph and renders the live waveform exactly as before.

Recommended reviewer

Recommended owner: @meganrogge

Fixes microsoft/vscode-engineering#3742

Generated by build-fix · opus48 · 209 AIC · ⌖ 19 AIC · ⊞ 11.7K ·

The onboarding voice-sample preview always built a real AudioContext and
connected the analyser to context.destination, opening the host audio
output device even when a test-supplied audio element was injected. In
headless Electron test runs this device kept spinning with no producer,
emitting endless `SyncReader::Read timed out` audio-glitch warnings and
hanging the unit test task until timeout. Skip the best-effort analyser
graph when an audioFactory override is provided; the sample still plays.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The functional change is narrowly test-scoped; only a minor comment-style issue remains.

Pull request overview

Prevents Voice Mode onboarding tests from opening a real audio output device.

Changes:

  • Skips AudioContext creation when tests inject an audio element.
  • Preserves production waveform analysis.
File summaries
File Description
voiceModeOnboarding.ts Bypasses the analyser graph for injected audio elements.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/vs/workbench/contrib/agentsVoice/browser/voiceModeOnboarding.ts Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@meganrogge
Megan Rogge (meganrogge) marked this pull request as ready for review September 1, 2026 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

vscode-build VS Code build process issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants