fix(overview): timeout hung ScreenCaptureKit calls

Merged
QE
3d ago
+347-12

Summary

  • Wrap ScreenCaptureKit calls with 5-second timeout to prevent indefinite hangs that block the capture limiter
  • Release limiter slot immediately on timeout so subsequent overview sessions can proceed instead of waiting for restart
  • Apply timeout to: SCShareableContent fetch, desktop background captures, and window preview captures
  • Add withOverviewCaptureTimeout() helper using Task.sleep-based deadline with first-completion semantics
  • Add unit test verifying timeout behavior and limiter recovery
  • Add agent skill documentation for Defi feature verification (overview, navigation, workspaces, service lifecycle)

Testing

  • New test hungNativeCaptureFailsAtDeadlineInsteadOfHoldingTheSlot verifies timeout fires and limiter releases
  • Local: python3 script/verify.py local (swift build and non-desktop tests)
  • Desktop E2E: existing testOverviewShowsBothMonitorsBeforeLoadingPreviews exercises the capture flow
  • Manual: defi toggle-overview && sleep 3 && defi status should show overviewReceivedPreviews > 0

[!NOTE]

Timeout hung ScreenCaptureKit calls in overview capture paths

  • Adds withOverviewCaptureTimeout in OverviewPreviewCapture.swift, a main-actor wrapper that races a capture operation against a 5-second deadline and throws OverviewCaptureTimeoutError. The hung native call is not cancelled; the wrapper just stops waiting on it.
  • Wraps shareable-content discovery, desktop screenshots, and window screenshots in captureOverviewImages, and shareable-content discovery plus sample-buffer capture in OverviewSurfaceCapture.prepare. Timeout errors follow the existing error paths and release the capture limiter slot.
  • Bounds desktop background capture retries to 5 per overview session generation in OverviewController.swift; after exhaustion, window previews still schedule, and a new generation resets the count.
  • Adds tests in OverviewPreviewTests.swift covering the deadline failure and limiter release to queued captures.
  • Behavioral Change: overview captures now fail after 5 seconds instead of blocking indefinitely; the underlying ScreenCaptureKit call keeps running after the timeout, and desktop backgrounds are skipped after 5 failed retries in a session.

Macroscope summarized 44c31e1.