Repository navigation
fix(desktop): reopen Rewind capture when the display stream dies (#10504) - #10549
Merged
Merged
Conversation
) Windows Rewind opens one persistent getUserMedia desktop stream and samples it on a timer. Nothing observed the track's lifecycle, so when the capture source went away (display sleep, GPU/driver reset, resolution or session change) the host kept drawing a dead <video> — the timeline filled with blank frames and capture never came back for the rest of the session. Watch the video track's 'ended' event: skip sampling while no track is live, and reopen the stream after a short delay. Our own teardown calls track.stop(), which does not fire 'ended', so this cannot self-trigger. Failure-Class: none Verified: pnpm vitest RewindCaptureHost.test.tsx 2/2 pass; with the fix reverted the same test fails exactly on the reported symptom (a frame is still saved from the dead video, stream never reopens). pnpm run typecheck and pnpm run lint clean (0 errors).
The recovery added in the previous commit tears the stream down and reopens it, but a grab already in flight (a frame save is an IPC round-trip) still ran its own reschedule afterwards. That both orphaned the restart timer's reference and left the old loop alive, so every recovery that happened mid-save added another sampling loop — doubling capture work each time. Stamp each scheduling chain with a generation that stop() bumps, so a grab from a torn-down stream neither saves its frame nor reschedules itself. Failure-Class: none Verified: pnpm vitest RewindCaptureHost.test.tsx 3/3 pass, including a new case that kills the track while a save is pending and asserts exactly one frame per interval after recovery; that case fails (2 frames per interval) with this commit reverted.
kodjima33
force-pushed
the
watchdog/issue-10504-rewind-capture-recovery
branch
from
July 25, 2026 11:08
2d6e664 to
083e267
Compare
This was referenced Jul 26, 2026
This was referenced Jul 29, 2026
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.
Bug
#10504 — on Windows, after Omi Desktop has been running for a few hours the Rewind timeline fills with dark/blank screenshots while the app still reports capture as active.
Root cause
RewindCaptureHostopens one persistentgetUserMediadesktop stream into a hidden<video>and samples it on a self-pacing timer. Nothing observed the track's lifecycle. When the OS tears the capture source down mid-session (display sleep, GPU/driver reset, resolution or session change) the track ends, but:grabAndSchedulekept drawing the now-dead<video>(itsvideoWidth/videoHeightstay non-zero) and saving those frames — the blank frames in the timeline, exactly the issue's own hypothesis "the timeline is receiving blank frames while the app still thinks capture is active";Fix
Commit 1 — recover from a dead capture track:
live— no more blank frames from a dead stream.endedevent and reopen the stream after a 2s delay. Our own teardown usestrack.stop(), which per spec does not fireended, so this cannot self-trigger or loop on unmount/settings changes.Commit 2 — keep exactly one sampling loop across a restart:
finallystill rescheduled itself after the teardown, orphaning the restart timer's handle and leaving the old loop alive — every mid-save recovery added another parallel sampling loop, doubling capture work each time.stop()bumps, so a grab from a torn-down stream neither saves its frame nor reschedules itself.Plus a changelog fragment for the user-visible behavior. Scope: ~30 changed lines in one component plus regression tests.
Tested
pnpm vitest run src/renderer/src/components/rewind/RewindCaptureHost.test.tsx→ 3/3 pass. The tests drive the real component against a fake desktop stream: baseline frame saved → track dies → no frames while the stream is down →getUserMediacalled again and saving resumes; a mid-save death yields exactly one frame per interval after recovery; and no reopen after unmount.pnpm vitest run src/renderer/src/components/rewind/→ 13/13 pass.pnpm run typecheck→ clean;pnpm run lint→ 0 errors (pre-existing prettier warnings only, including one on an untouched line of this file that is already present onmain).make preflight→ 10/10 checks pass on this diff.Not claimed: this was not reproduced on a real multi-hour Windows session. It fixes a confirmed mechanism for #10504 (blank frames plus no recovery once the capture track dies), not a bisected repro.
🤖 automated by hourly watchdog — tested, then merged in the same run
Failure-Class: none