fix(capture): honor cancellation during ScreenCaptureKit retry sleeps#286
fix(capture): honor cancellation during ScreenCaptureKit retry sleeps#286SebTardif wants to merge 1 commit into
Conversation
|
Triage Wave 5 closeout: closing without merge, not requesting changes. Thanks @SebTardif for following the #279 closeout and combining the full cancellation family. Head The result is still blocked by the same mandatory live boundary documented on #279 and #280. This PR explicitly says a real signed ScreenCaptureKit/TCC denial under a canceled caller was not tested. The injected The re-entry condition is precise: provide new authenticated, properly signed live ScreenCaptureKit/TCC evidence from an independently healthy macOS host showing a real transient denial, cancellation during retry backoff, and no second capture/probe while the non-canceled control still retries once; alternatively, an owner must explicitly waive that live gate. Until then, the standing contributor-policy outcome is close rather than change-request. No commit is being merged and there is no merge SHA. Closing appreciatively with the implementation and deterministic proof preserved in this PR. |
What Problem This Solves
After a transient ScreenCaptureKit denial (
SCStreamError -3801), three retry paths sleep withtry? await Task.sleepbefore a second attempt:ScreenCaptureFallbackRunner.run(generic/video-style capture)ScreenCaptureFallbackRunner.runCapture(image capture)ScreenRecordingPermissionChecker.hasPermission(SCShareableContent permission probe)try?swallowsCancellationError, so a canceled CLI/MCP capture or permission check can still burn a full second ScreenCaptureKit attempt after the ~350ms delay instead of stopping promptly.This is the same cancellation-swallow class as merged #270 / #271 / #230 / #267. Closed #279 and #280 each covered a subset; maintainer triage asked for one combined fix covering all three sites (see #279 closeout).
Evidence
Before (main)
After (this branch)
Red / green on production helpers
Red without production fix (cancel mid 350ms sleep):
Green with fix:
Non-canceled transient denial still retries once (control case green).
Live terminal pattern proof (after fix)
Also:
pnpm run build:clipassed on this branch.Real behavior proof
Behavior or issue addressed: Canceling during a ScreenCaptureKit transient-denial retry sleep must not run a second capture attempt (
run/runCapture) or a second shareable-content permission probe.Real environment tested: macOS (arm64), Peekaboo worktree on branch
fix/screencapture-retry-honor-cancelat tip of this PR, Swift 6.x toolchain.Exact steps or command run after this patch:
Evidence after fix: Terminal transcripts above: unfixed paths run 2 attempts/probes after cancel; fixed paths stop at 1. Production helpers with injected transient
-3801errors match those counts for engine and permission.Observed result after fix: Cancellation during the ~350ms denial sleep aborts before the retry
attempt(api)/ secondSCShareableContentprobe. Non-canceled transient denial still retries once.What was not tested: Live ScreenCaptureKit TCC denial from a real display capture under a canceled CLI task on a signed binary (requires TCC denial injection). Delay length matches production
ScreenCaptureKitTransientError(350ms). Same live-gate limitation noted in fix(capture): honor cancellation during ScreenCaptureKit retry sleep #279 closeout.Summary
CHANGELOG.mdentry under Unreleased.Related
6b2554a6(fix(capture): stabilize concurrent live area capture, 2026-05-07)