Skip to content

fix: prevent double-finalize race condition in restartRecording on Windos#293

Merged
siddharthvaddem merged 1 commit intosiddharthvaddem:mainfrom
abres33:fix/restart-recording-windows
Apr 3, 2026
Merged

fix: prevent double-finalize race condition in restartRecording on Windos#293
siddharthvaddem merged 1 commit intosiddharthvaddem:mainfrom
abres33:fix/restart-recording-windows

Conversation

@abres33
Copy link
Copy Markdown
Contributor

@abres33 abres33 commented Apr 3, 2026

Description

Fixes a bug where clicking the Restart button in the recording HUD would stop the recording and open the video editor instead of discarding the current recording and starting a fresh one.

Motivation

On Windows, a race condition caused finalizeRecording to be called twice for the same recording session. The second call had no discard protection and would save the footage and open the editor - exactly as if the Stop button had been pressed. This made the Restart button non-functional on Windows.

Type of Change

Bug Fix

Related Issue(s)

Fixes #292

Testing

  1. Launch OpenScreen on Windows
  2. Select a source and start a screen recording
  3. While recording is active, click the Restart button (circular arrow) in the HUD toolbar
  4. Verify: the recording restarts - HUD stays visible and a new recording begins
  5. Verify: the video editor does NOT open
  6. Verify: clicking Stop still works normally and opens the editor as expected

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.

Summary by CodeRabbit

Bug Fixes

  • Fixed an issue with screen recording restart functionality where stopping and restarting recordings could cause unexpected behavior during the restart sequence.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 3, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f273e66d-8085-49cb-b812-47412b706ba4

📥 Commits

Reviewing files that changed from the base of the PR and between 2f36160 and 846cf71.

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

📝 Walkthrough

Walkthrough

A single-line fix in the useScreenRecorder hook that prevents automatic video editor finalization during the restart sequence. The fix sets allowAutoFinalize.current = false after flagging the current recording for discard, stopping the unintended editor opening.

Changes

Cohort / File(s) Summary
Recording Restart Logic
src/hooks/useScreenRecorder.ts
Added flag to prevent auto-finalization during restart: sets allowAutoFinalize.current = false after marking recording for discard, preventing the MediaRecorder "stop" event from triggering unwanted editor finalization.

Possibly related PRs

  • PR #216: Both PRs modify restart logic in src/hooks/useScreenRecorder.ts — the earlier PR established the discard flag mechanism, and this PR completes the fix by preventing auto-finalization from overriding the discard behavior.

Poem

🎬 A rabbit's restart now spins true,
No editor pops when recording's through,
One flag set, the chaos is gone—
The HUD keeps rolling, we carry on! 🐰


🎯 1 (Trivial) | ⏱️ ~2 minutes

🚥 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed Title contains a typo 'Windos' instead of 'Windows' and accurately describes the main bug fix being implemented.
Description check ✅ Passed Description includes all required sections: motivation, type of change, related issues, testing steps, and completed checklist items.
Linked Issues check ✅ Passed The code change directly addresses issue #292 by setting allowAutoFinalize flag to prevent double-finalize, matching the requirement to set a discard flag before stopping.
Out of Scope Changes check ✅ Passed The single-line change is narrowly focused on fixing the Windows restart race condition with no unrelated modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@siddharthvaddem siddharthvaddem merged commit b101820 into siddharthvaddem:main Apr 3, 2026
5 checks passed
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]: Restart Recording button stops recording and opens editor instead of restarting

2 participants