Skip to content

fix(recording): bound the video-writer frame wait as a hang safety net#123

Merged
EtienneLescot merged 1 commit into
mainfrom
fix/wgc-video-writer-wait-timeout
Jul 19, 2026
Merged

fix(recording): bound the video-writer frame wait as a hang safety net#123
EtienneLescot merged 1 commit into
mainfrom
fix/wgc-video-writer-wait-timeout

Conversation

@EtienneLescot

@EtienneLescot EtienneLescot commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

Small follow-up to #119 (Fixes #115). CodeRabbit flagged this on the now-superseded #121: the video-writer thread's per-frame cv.wait() in writeVideoFrames has no timeout. If a notification were ever missed, the thread would block indefinitely, hanging videoWriterThread.join() and the whole stop sequence — the exact failure mode #115/#119 already fixed for the common case.

#119 already fixed the actual root cause (the blocking WriteSample call no longer runs under the shared mutex, so the main thread's stop-wait is never starved). This is a defense-in-depth hardening on top: switch the video-writer's own wait to wait_for(100ms) so it always re-checks stopRequested/encodeFailed periodically, instead of relying solely on a notification reaching an already-waiting thread.

Verification

Rebuilt wgc-capture.exe on top of current main (includes #119) via CMake/Ninja:

Test plan

Related to #115 (already closed by #119) — no functional bug left open, this is a pure hardening commit.

Summary by CodeRabbit

  • Bug Fixes
    • Improved video frame processing responsiveness by periodically checking for new frames and stop requests.
    • Helps prevent capture operations from remaining idle when an expected wake-up signal is missed.

Follow-up to #119 (Fixes #115). CodeRabbit flagged, on the now-superseded
#121, that the video-writer thread's per-frame cv.wait() has no timeout: if a
notification were ever missed, the thread would block indefinitely, hanging
videoWriterThread.join() and the whole stop sequence — exactly the failure
mode this release is eliminating. #119 already fixed the actual root cause
(the blocking WriteSample call no longer runs under this mutex, so the main
thread's stop-wait is never starved), but the wait itself was still
unbounded. Switch it to wait_for(100ms) so the loop always re-checks
stopRequested/encodeFailed even in that circumstance, instead of relying
solely on a notification reaching an already-waiting thread.

Verified: rebuilt wgc-capture.exe on top of current main (includes #119),
re-ran the #115 repro (screen-only, all extras disabled) and the
full-featured regression (system audio + cursor) - both stop in under 110ms
with a full [stop-timing] log and a valid MP4.
@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 69ff792b-30d8-49dc-aa95-2c809e93967a

📥 Commits

Reviewing files that changed from the base of the PR and between 574b685 and 34282ba.

📒 Files selected for processing (1)
  • electron/native/wgc-capture/src/main.cpp

📝 Walkthrough

Walkthrough

The video frame writer loop now wakes at least every 100ms while waiting, while preserving its existing stop, encoding-failure, and frame-availability predicate.

Changes

Video writer synchronization

Layer / File(s) Summary
Timed video writer wait
electron/native/wgc-capture/src/main.cpp
Replaces the unbounded condition-variable wait with a 100ms wait_for using the existing predicate.

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

Possibly related PRs

Suggested reviewers: my-denia

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/wgc-video-writer-wait-timeout

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
EtienneLescot merged commit 3f51d68 into main Jul 19, 2026
9 of 10 checks passed
@EtienneLescot
EtienneLescot deleted the fix/wgc-video-writer-wait-timeout branch July 19, 2026 09:28
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]: Windows native recorder never stops after stdin stop command (v1.7.0-rc.2)

1 participant