Skip to content

fix(sender): distinguish idle capture from a stalled pipeline - #195

Merged
swellweb merged 1 commit into
swellweb:maint-3.5from
Betafer:codex/fix-capture-idle-health-v3.5-20260912
Sep 14, 2026
Merged

swellweb merged 1 commit into
swellweb:maint-3.5from
Betafer:codex/fix-capture-idle-health-v3.5-20260912

Conversation

@Betafer

@Betafer Betafer commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Why

Thanks again for the project. While using an iMac as a monitor for a Mac mini, we found that an event-driven capture can legitimately stop producing frames on a static desktop. Treating every eight-second gap as a capture failure causes unnecessary restarts.

This is a focused follow-up, rebased on maint-3.5 (fb45b5f), separate from pairing, login items, codecs, and rendering changes.

Change

  • Track real ScreenCaptureKit / CGDisplayStream status using a small, lock-protected monotonic capture-health model.
  • Accept long idle only after a usable first frame; preserve timeout detection for startup and genuine active stalls.
  • Do not restart blank/suspended capture in a wake loop.
  • Recheck health after the watchdog delay, and use pipeline identity plus generation to prevent delayed recovery from restarting a stopped or replacement session.
  • Ignore an obsolete capture delegate's error after its pipeline has been replaced.

The existing watchdog interval and timeout remain unchanged. No extra per-frame main-actor dispatch is added.

Validation

  • 17 executable XCTest cases against the production model: first-frame timeout, active stall, long/repeated idle, resume, blank/suspended/stopped/unknown states, fresh-pipeline isolation, recovery rechecks, both API mappings, and actual CMSampleBuffer attachment parsing.
  • Reproducible without starting Sender or requesting capture/input permissions: ruby TargetBridge-Sender/scripts/test_capture_health.rb (macOS with full Xcode/XCTest selected). All 17 tests passed locally. The Mini's Command Line Tools alone lack XCTest, so the additional run there could not execute the suite; this is not counted as a pass.
  • The rebased Sender and test target pass xcodebuild build-for-testing on Apple Silicon.
  • Prior installed integration test: Mini M4 to iMac 24 M4; two sessions, a static capture remained idle beyond the eight-second threshold (about 13.6 seconds measured without a new frame), resumed frames without a watchdog restart, and stopped explicitly.

The model tests do not replace a physical sleep/wake matrix on Intel hardware. No new physical sleep or interactive GUI test is claimed for this PR.

Scope / integration

Independent of #194, though both touch the capture entry guard in TBDisplaySenderService.swift; retain both the usable-frame guard here and the pre-encode reservation there if Git requires a small context resolution. No generated build metadata is included.

@swellweb
swellweb merged commit 402ef8e into swellweb:maint-3.5 Sep 14, 2026
4 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.

2 participants