fix(recording): bound the video-writer frame wait as a hang safety net#123
Merged
Conversation
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.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe video frame writer loop now wakes at least every 100ms while waiting, while preserving its existing stop, encoding-failure, and frame-availability predicate. ChangesVideo writer synchronization
Estimated code review effort: 2 (Simple) | ~5 minutes Possibly related PRs
Suggested reviewers: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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()inwriteVideoFrameshas no timeout. If a notification were ever missed, the thread would block indefinitely, hangingvideoWriterThread.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
WriteSamplecall 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 towait_for(100ms)so it always re-checksstopRequested/encodeFailedperiodically, instead of relying solely on a notification reaching an already-waiting thread.Verification
Rebuilt
wgc-capture.exeon top of currentmain(includes #119) via CMake/Ninja:preferSoftwareEncoder: true): stops in ~89ms with a full[stop-timing]log and a valid non-zero MP4.Test plan
Related to #115 (already closed by #119) — no functional bug left open, this is a pure hardening commit.
Summary by CodeRabbit