Repository navigation
Conversation
Treat a live-but-muted MediaStreamTrack as unavailable, route mute and ended events through the existing generation-fenced restart path, and refuse to sample an initially muted stream. Failure-Class: new Verification: Rewind tests (20 passed); full Windows desktop suite (5070 passed, 18 skipped); Node/Web typecheck; focused ESLint and Prettier; failure-class tests (17 passed).
Git-on-my-level
left a comment
There was a problem hiding this comment.
Thanks for this clean fix. The muted-but-live track state is a real gap — MediaStreamTrack.muted can be true while readyState stays "live", and the old isLive() accepted that, persisting blank frames.
Your single-predicate approach (live && !muted) unified through one onTrackUnavailable handler is the right design. Two details stand out as well done:
- The post-
play()usability re-check closes a subtle race wheremutecould fire during the pendingplay()promise. - The
hasUsableVideoTrack()guard insideonTrackUnavailablecorrectly prevents duplicate recovery when another usable track still exists.
Both new behavioral tests (runtime mute + initially-muted stream) directly assert the no-save-before-recovery contract. The failure-class registration follows the established schema.
Approving — small, well-scoped, low-risk fix with solid test coverage.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
kodjima33
left a comment
There was a problem hiding this comment.
Desktop bug fix for #10737's recurrence: isLive() accepted live-but-muted tracks so Rewind kept saving blank frames. Single usable-track predicate plus mute/ended listeners, with regressions for both runtime-mute and initially-muted streams. Green CI.
## What changed and why Closes #8498. Closes #10488. Windows Rewind now reacts to foreground-window changes and follows that window across displays without keeping multiple capture streams alive. - The existing WinEvent hook requests an immediate sample on a foreground change. - Screen sources are cached as an ID-to-display map instead of caching only the primary source. - The foreground window's physical Win32 rectangle is converted to Electron DIP coordinates and matched to its display, with cursor and primary fallbacks. - The renderer replaces its single persistent 1 fps stream only when the target display changes, preserving the current quality tier and capture cadence. - Each save includes its capture source ID. The main process revalidates that source before ingestion and drops stale frames when focus moved displays during stream setup or JPEG encoding. - The stream replacement path retains the `ended`/`mute` recovery merged in #10829, including initial-muted rejection and generation-fenced late-event handling. Capture-disabled, lock/idle, excluded-app, sensitive-title, size, and duplicate-frame guards remain authoritative in the existing `ingestRewindFrame` path. ## Product invariants affected none ## How it was verified - Synced with current `origin/main` (`df314540b`) at head `c92147266`. - `npm run build` passed with the final code, including main/preload and renderer typechecks, bytecode verification, extension bundling, and the production renderer bundle. - A detached Windows integration used #10825 solely as the path-safe preflight runner; the committed 44-file composition passed all 70 selected checks in 188.34s. This PR's own diff remains 10 files. - Targeted ESLint and Prettier passed for the two conflict-resolved capture-host files. - `git diff --check` passed. - A native Windows Electron smoke probe previously exercised `SetWinEventHook -> foregroundCaptureTrigger -> BrowserWindow IPC`; two programmatic foreground-window changes produced `events=2`. - The current Windows host exposes one physical display, so a real dual-monitor switch was not hardware-tested here. Multi-display source selection, per-monitor DPI conversion, stream replacement, stale-source rejection, and muted/dead-track recovery are covered by tests. ## Tests - `vitest run src/main/rewind/sourceId.test.ts src/main/rewind/foregroundCaptureTrigger.test.ts src/renderer/src/components/rewind/RewindCaptureHost.test.tsx` passed: 3 files, 29 tests. - Coverage includes source-map caching and invalidation, foreground/cursor/primary display selection, physical-to-DIP conversion, source switching, late old-track events, stale-source rejection, burst coalescing, muted/dead-track recovery, and disabled/unmounted capture. - A full Windows Vitest run on the prior head reached one unrelated `Apps.errorToast.test.tsx` timeout under full-suite load; that untouched file passed 2/2 immediately on an isolated rerun. All Rewind tests remained green. ## Failure class (fixes) Failure-Class: none
What changed and why
Addresses #10737's recurrence after #10549.
#10549 made Rewind recover when a desktop-capture track reaches
readyState === "ended". A browser can also report that the source is unable to provide media by settingMediaStreamTrack.mutedwhile leavingreadyState === "live". The existingisLive()check accepted that state, so the hidden capture video could keep producing and saving blank frames without taking the recovery path.This change defines one usable-track predicate (
live && !muted), listens for bothmuteandended, and routes both states through the existing generation-fenced two-second restart. It also checks the initial track aftervideo.play()and avoids duplicate recovery if a lifecycle event fired whileplay()was pending.This deliberately does not add pixel-based black-frame heuristics, which would misclassify legitimate dark screens. It closes the remaining browser-declared unavailable-track state; a post-merge recurrence would need runtime health telemetry for a different source of blank pixels.
Product invariants affected
none
How it was verified
rewindSaveFramewas called once after themuteevent.RewindCaptureHost.test.tsx: 10/10 passed, including runtime mute and initially-muted stream recovery.mainstill contains Bug: manifest preflight compares MSYS and Win32 temp paths literally #10824.Tests
getUserMediaresolves an already-muted stream: no sample is scheduled before the replacement stream is usable.Failure class (fixes)
Failure-Class: new
Registers
FC-media-track-output-liveness: a long-lived capture loop must treat every browser-declared media-output unavailable state as non-capturable and recover before persisting another frame. #10549 is the historical evidence PR, andRewindCaptureHost.test.tsxis the canonical prevention artifact.New guards (only when adding a check or ratchet)
The behavioral regression lives with
RewindCaptureHostbecause that component is the sole owner of the Windows desktopMediaStreamTrack, sampling timer, and generation fence. There is no second media-track capture owner to justify a shared repository primitive; the single usable-track predicate is reused by event recovery, initial admission, and every sample.