Skip to content

Fix: mic audio killed after cancelling a native-capture recording (#699) - #1003

Open
SomSamantray wants to merge 1 commit into
webadderallorg:mainfrom
SomSamantray:fix/mic-audio-killed-on-cancel-699
Open

SomSamantray wants to merge 1 commit into
webadderallorg:mainfrom
SomSamantray:fix/mic-audio-killed-on-cancel-699

Conversation

@SomSamantray

@SomSamantray SomSamantray commented Sep 20, 2026

Copy link
Copy Markdown

Description

Cancelling a native-capture recording (clicking the "X"/cancel button) never stopped the mic fallback recorder's getUserMedia stream. The stale mic track stayed open, so the next recording opened a second, concurrent mic stream and produced silent/dead audio until the user manually reselected the microphone device.

cancelRecording's native-capture branch now stops the mic fallback recorder alongside discarding the native capture (via Promise.allSettled), mirroring the cleanup stopRecording already performs in both its warm-start and normal branches.

Motivation

Fixes a reproducible audio bug reported in #699: recording, cancelling, then immediately recording again leaves the user with no microphone audio.

Type of Change

  • New Feature
  • Bug Fix
  • Refactor / Code Cleanup
  • Documentation Update
  • Other (please specify)

Related Issue(s)

Fixes #699

Screenshots / Video

Not applicable — this is an internal media-cleanup fix with no UI change.

Testing Guide

  1. npm test — full suite passes (1194 tests), including a new test: stops the mic fallback recorder when cancelling native recording in src/hooks/useScreenRecorder.test.ts.
  2. npx tsc --noEmit and npx biome lint — clean on the changed files.
  3. Manual repro (native capture path, e.g. macOS/Windows full-screen or window recording with mic enabled): start a recording, click cancel/"X", immediately start a new recording, confirm the mic level is live rather than dead/silent.

Checklist

  • I have performed a self-review of my code.
  • I have added any necessary screenshots or videos.
  • I have linked related issue(s) and updated the changelog if applicable.

Scope

Change is intentionally narrow: only the native-capture branch of cancelRecording in src/hooks/useScreenRecorder.ts is touched. The webcam and plain-mediaRecorder cancel branches already clean up their own media correctly and are left untouched to minimize the diff and regression risk.

Disclosure

This change was drafted with AI assistance (Claude Code) and reviewed, tested, and verified by me before submission.

Summary by CodeRabbit

  • Bug Fixes
    • Canceling a native screen recording now also stops the microphone fallback recorder.
    • Recording cancellation waits for both recording sources to finish stopping, helping prevent lingering audio capture.

Cancelling a native-capture recording (clicking the "X"/cancel button)
never stopped the mic fallback recorder's getUserMedia stream. The
stale mic track stayed open, so starting the next recording opened a
second concurrent mic stream and produced silent/dead audio until the
user manually reselected the microphone.

cancelRecording's native-capture branch now stops the mic fallback
recorder alongside discarding the native capture, mirroring the
cleanup stopRecording already performs.

Fixes webadderallorg#699

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: webadderallorg/Recordly/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: a6e05ea4-449d-4fce-abb2-77843d84d23b

📥 Commits

Reviewing files that changed from the base of the PR and between 4992686 and aafa440.

📒 Files selected for processing (2)
  • src/hooks/useScreenRecorder.test.ts
  • src/hooks/useScreenRecorder.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

Native recording cancellation now stops the microphone fallback recorder alongside native capture disposal. Tests verify that native cancellation invokes the fallback stop callback.

Changes

Native recording cancellation cleanup

Layer / File(s) Summary
Coordinate cancellation cleanup
src/hooks/useScreenRecorder.ts
cancelRecording now awaits native capture disposal and microphone fallback cleanup with Promise.allSettled. The callback dependency array includes stopMicFallbackRecorder.
Validate fallback cleanup
src/hooks/useScreenRecorder.test.ts
Tests provide the optional fallback stop callback and verify that native cancellation invokes it while preserving native cancellation behavior.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: webadderall

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the microphone-audio bug and the native-capture cancellation scenario. It is concise and directly related to the main change.
Description check ✅ Passed The description includes all required template sections, explains the defect and motivation, identifies the bug-fix type, links issue #699, documents testing, and completes the checklist.
Linked Issues check ✅ Passed Issue #699 requires microphone cleanup after cancelling a native-capture recording. In useScreenRecorder.ts, the native cancelRecording path now runs stopMicFallbackRecorder() with `discardActiv…
Out of Scope Changes check ✅ Passed The changed files contain only the native-cancellation microphone cleanup and its automated test. These changes directly support issue #699. No unrelated change is shown in the reviewed diff.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

[BUG] - audio gets killed when you press x

1 participant