Skip to content

fix: keep macOS webcam recordings continuous with VP8 - #1297

Open
tonisives wants to merge 1 commit into
getopenscreen:mainfrom
tonisives:fix/macos-webcam-recording
Open

tonisives wants to merge 1 commit into
getopenscreen:mainfrom
tonisives:fix/macos-webcam-recording

Conversation

@tonisives

@tonisives tonisives commented Oct 17, 2026 •

Copy link
Copy Markdown

Summary

On macOS, MediaRecorder's H.264 webcam encoder can stop producing frames while the camera stream stays live. A local reproduction with a Logitech C922 produced only 13 frames over 56 seconds; VP8 produced 3,828 frames over 128 seconds with a maximum frame gap of 68 ms. A second installed-build take produced 1,932 frames over 64 seconds, maximum gap 66 ms.

Prefer VP8 for macOS webcam recording, independently of the native H.264 screen recorder. Keep the existing H.264 preference on Windows/Linux and negotiate supported fallbacks. Check the codec's VideoToolbox configurations before selecting hardware presentation: VP8 CPU frames need the existing NV12/CVPixelBuffer conversion to appear in the Metal compositor. Preserve unknown-sized WebM Cluster bytes when patching duration, including recordings under 2 MB.

The machine-specific build/install scripts used for local testing are excluded. Autofocus and camera constraints are unchanged. The held-screen preview clock fixes already on main address a separate editor-only freeze.

Related issue

No issue linked; reproduced locally on macOS.

Type of change

  • Bug fix

Release impact

  • Patch

Desktop impact

  • macOS

Screenshots / video

Private camera recordings were checked locally and are not attached. The testing checklist records the measured continuity and the partial desktop smoke-test scope.

Testing

  • Node 22: full unit suite, 351 files; 4,909 passed, 2 skipped.
  • Focused webcam recorder options, webcam capture target and WebM duration tests: 25 passed.
  • Both app and test TypeScript checks pass.
  • Biome check of the five changed TypeScript files passes.
  • Native codec regression test passes: VP8 uses CPU presentation; H.264 advertises VideoToolbox.
  • Release compositor addon builds on Apple Silicon with the vendored LGPL FFmpeg SDK.
  • Capture-to-editor and MP4 camera presentation tested on the v2.0.0 local build carrying this patch. The port to current main has unit/type/build checks; a new desktop capture smoke test on that exact main build and physical Windows/Linux capture were not run.

Summary by CodeRabbit

  • Bug Fixes
    • Improved webcam recording compatibility across macOS, Windows, and Linux by selecting an available video format for each platform.
    • Webcam recording bitrate now reflects the camera’s delivered dimensions.
    • Fixed duration updates for WebM recordings of all sizes while preserving their video data.
    • Unsupported hardware-decoding formats on macOS now use the CPU presentation path, supporting preview and export.

@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 89d559b7-b24f-4ed3-8667-b18a9e509107
📥 Commits

Reviewing files that changed from the base of the PR and between 763cfed and 7ce05cc.

📒 Files selected for processing: 7
  • crates/compositor/src/pipeline_macos.rs
  • electron/recording/webm-duration.test.ts
  • electron/recording/webm-duration.ts
  • src/hooks/useScreenRecorder.ts
  • src/hooks/webcamRecorderOptions.test.ts
  • src/hooks/webcamRecorderOptions.ts
  • technical-documentation/testing/manual-e2e-checklist.md

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

📝 Walkthrough

The changes update platform-specific webcam codec selection, route all on-disk WebM duration patches through a header-only splice path, and gate macOS VideoToolbox setup on codec support. Tests cover codec selection, WebM byte preservation, and decoder support.

Changes: Camera recording and playback

Layer / File(s) Summary
Webcam codec selection
src/hooks/webcamRecorderOptions.ts, src/hooks/useScreenRecorder.ts, src/hooks/webcamRecorderOptions.test.ts
The new helper selects codecs in platform-specific order, omits mimeType when no candidate is supported, and sets the bitrate from delivered camera dimensions. The screen recorder uses this helper. Tests cover codec preferences, fallback, and bitrate.
On-disk WebM duration patching
electron/recording/webm-duration.ts, electron/recording/webm-duration.test.ts
Files of all sizes now use the header-only splice path. Tests check patching a file under 2 MB and preservation of Cluster bytes after duration patching.
macOS decoder setup
crates/compositor/src/pipeline_macos.rs, technical-documentation/testing/manual-e2e-checklist.md
VideoToolbox setup is attempted only when the codec supports the device type and pixel format. Tests check VP8 and H.264 support. The manual test log records macOS capture results and remaining test gaps.

Priority: ⬆️ High

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 7ce05

The camera-recording changes are ready to merge after normal checks; no concrete blocking issue remains identified.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 6 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly states the primary bug fix: keeping macOS webcam recordings continuous by using VP8.
Description check Passed The description follows the repository template and covers the summary, issue status, change type, release impact, platform impact, testing, and known test limitations.
Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 6 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

This branch has not been deployed

No deployments
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.

1 participant