Skip to content

fix(sdk-recorder): retain microphone audio when sharing tab sound - #2727

Merged
richiemcilroy merged 3 commits into
CapSoftware:mainfrom
AksharP5:fix/sdk-tab-microphone-audio
Oct 20, 2026
Merged

richiemcilroy merged 3 commits into
CapSoftware:mainfrom
AksharP5:fix/sdk-tab-microphone-audio

Conversation

@AksharP5

@AksharP5 AksharP5 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

SDK users sharing tab audio could lose microphone narration even though recording and upload succeeded. This mixes the captured audio sources into one MediaRecorder track and releases the mixer with the capture streams. Each input gets an equal share of the output range, and audio startup rejects after ten seconds if the browser leaves it pending. Single-source recordings keep their direct track path and original level.

Closes #2726

Before and after

Same SDK flow and Chrome 154/Linux environment, with a moving canvas and two synthetic tones, each at input amplitude 0.2. The SDK records for three seconds, stops, and runs its multipart client against local request stubs. These measurements come from decoded recordings.

Decoded signal Main 94a99fc1b This patch
Tab audio, 440 Hz amplitude 0.199892 0.098673
Microphone, 1000 Hz amplitude 0.000030, source absent 0.099018, source retained
Audio tracks supplied to MediaRecorder 2 1 mixed track
SDK result complete, narration lost complete, both sources retained

The two-source mix deliberately uses gain 0.5 to leave headroom for both inputs. Independent FFmpeg decoding of the saved VP9/Opus WebM files confirms that both sources survive. The microphone tone is 76.36 dB below the tab tone before, and within 0.04 dB of it after.

Validation

  • bun run --cwd packages/sdk-recorder test: seven tests pass, covering the shared recording track, mixing headroom, zero/single-source capture, startup timeout, and cleanup after encoder or audio startup failure. Uses the existing Bun runtime without adding dependencies.
  • Real Chromium SDK recordings pass with both sources, microphone only, tab audio only, video without audio, and pause/resume. Half-second windows retain both tones across pause/resume. Encoder-failure and destroy() checks release the source tracks and close the mixer.
  • With two loud input tones at amplitude 0.9, decoded samples with absolute amplitude at least 0.99 fall from 31.95% on the initial PR head to 0% after adding headroom. The decoded peak falls from 1.067 to 0.904.
  • Injecting a never-resolving audio resume() leaves the initial PR head capturing at 10.5 seconds. The updated code rejects at 10.0 seconds, stops all captured tracks, closes the mixer, and clears its deadline.
  • Scoped Biome 2.2.0, git diff --check, strict TypeScript checking of the capture module, and a browser bundle build pass.
  • The SDK entry-point TypeScript check reports the identical pre-existing TS2345 error in the event-listener unsubscribe code at src/index.ts:87 on main and this patch. No unrelated type changes are included. Full workspace checks were not run locally.

Capture inputs and upload requests were stubbed for the browser test. Physical microphones, the native tab picker, Firefox, Safari and cloud services remain unverified. The dashboard recorder and its separate mixer are unchanged.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; both previous findings are fixed.

Summary

The SDK now combines tab sound and microphone audio into one recording track.

  • Tab and microphone audio record together on one track.
  • The SDK type export list puts RecorderEventMap first.

Reviews (2) · Last reviewed commit: "fix(sdk-recorder): bound audio startup a..." · Reviewed by Greptile

@vercel
vercel Bot temporarily deployed to Preview – cap-status October 20, 2026 02:09 Inactive
@vercel

vercel Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
cap-status Skipped Skipped Oct 20, 2026 7:42pm UTC

Comment thread packages/sdk-recorder/src/core/stream-manager.ts Outdated
Comment thread packages/sdk-recorder/src/core/stream-manager.ts Outdated
@AksharP5
AksharP5 force-pushed the fix/sdk-tab-microphone-audio branch from 998b7b3 to fa64a45 Compare October 20, 2026 02:23
@vercel
vercel Bot temporarily deployed to Preview – cap-status October 20, 2026 02:23 Inactive
@AksharP5

Copy link
Copy Markdown
Contributor Author

@greptileai please re-review fa64a45.

Both findings have fixes and regression coverage. Audio startup now has a ten-second deadline with capture cleanup, and the mix reserves headroom for each input. The PR description includes fresh browser encoding, loud-input and stalled-startup checks. All seven package tests pass.

@vercel
vercel Bot temporarily deployed to Preview – cap-status October 20, 2026 19:42 Inactive
@richiemcilroy
richiemcilroy merged commit 6235d4e into CapSoftware:main Oct 20, 2026
28 of 29 checks passed

This branch was previously deployed

1 inactive deployment
Preview – cap-status — c8418c1f Deployed Oct 20, 2026 by vercel[bot]
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.

Recording SDK drops microphone audio when tab audio is enabled

2 participants