Skip to content

perf(windows): skip the webcam frame copy when its sequence has not changed - #941

Merged
EtienneLescot merged 1 commit into
mainfrom
claude/recording-webcam-copy-skip
Sep 30, 2026
Merged

EtienneLescot merged 1 commit into
mainfrom
claude/recording-webcam-copy-skip

Conversation

@EtienneLescot

@EtienneLescot EtienneLescot commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

The video writer no longer copies the webcam frame when it already holds it. With a 30 fps camera and a 60 fps screen, that removes about 30 full-frame copies a second from the thread that paces the screen.

Fixes #934
Part of #920

Change

  • copyLatestFrame takes the caller's last seen sequence and returns false without copying when it has not changed.
  • Both backends (Media Foundation and DirectShow) route through one inline rule, snapshotWebcamFrame, next to WebcamFrameSnapshot.
  • main.cpp: only the two copyLatestFrame calls in the webcam blocks change. The sequence comparison moved into the call.

Measured

  • New webcam_snapshot_test, wired into CMake and build-windows-wgc-helper.mjs: an unchanged sequence returns false and copies nothing.
  • It fails on the old rule: with the sequence check removed, 2 assertions fail (unchanged sequence reports nothing new, unchanged sequence copies nothing).
  • node scripts/build-windows-wgc-helper.mjs: every target builds, all four native test executables pass.

Pending (maintainer, real take)

  • storeMs / readSampleMs in INFO: Webcam capture loop ended, and the helper's CPU, before and after.
  • Not changed: a frame rejected as not yet visible (camera warm-up) is still copied on each tick until a visible one arrives, as before.

🤖 Generated with Claude Code

…hanged

copyLatestFrame now takes the caller's last seen sequence and returns false without copying when nothing new arrived. Both capture backends share the rule through snapshotWebcamFrame, covered by webcam_snapshot_test.
@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 1 minute.

Check out review usage here.

View limit details

Limit details: You’ve used all 8 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: e5e643d7-b961-4c93-b907-077dc2ec3c6a

📥 Commits

Reviewing files that changed from the base of the PR and between 345e225 and 975fb58.

📒 Files selected for processing (8)
  • electron/native/wgc-capture/CMakeLists.txt
  • electron/native/wgc-capture/src/dshow_webcam_capture.cpp
  • electron/native/wgc-capture/src/dshow_webcam_capture.h
  • electron/native/wgc-capture/src/main.cpp
  • electron/native/wgc-capture/src/webcam_capture.cpp
  • electron/native/wgc-capture/src/webcam_capture.h
  • electron/native/wgc-capture/src/webcam_snapshot_test.cpp
  • scripts/build-windows-wgc-helper.mjs
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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.

@EtienneLescot

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@EtienneLescot

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@EtienneLescot
EtienneLescot merged commit 1f5d9d8 into main Sep 30, 2026
18 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.

Recording (Windows): don't copy the webcam frame when it has not changed

1 participant