fix(capture): honor cancellation during ScreenCaptureKit retry sleep#279
fix(capture): honor cancellation during ScreenCaptureKit retry sleep#279SebTardif wants to merge 2 commits into
Conversation
Transient SCK denial retries used try? await Task.sleep, which swallowed CancellationError and continued into a second capture attempt. Use throwing sleep plus checkCancellation so canceled capture stops promptly. Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
|
Codex review: needs real behavior proof before merge. Reviewed July 16, 2026, 4:05 PM ET / 20:05 UTC. Summary Reproducibility: no. live reproduction is provided, but the failure is source-reproducible with high confidence: Review metrics: 2 noteworthy metrics.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Retain the throwing-sleep approach, add deterministic tests that cancel both image and video denial retries during the delay and assert only one attempt occurs, then provide a redacted macOS runtime transcript or log showing prompt cancellation. Do we have a high-confidence way to reproduce the issue? No live reproduction is provided, but the failure is source-reproducible with high confidence: Is this the best way to solve the issue? Yes in direction: allowing the throwing sleep to propagate cancellation is the narrowest maintainable fix, but the PR should add focused regression coverage and real behavior proof before merge. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e2a46347138d. Label changesLabel changes:
Label justifications:
Evidence reviewedWhat I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
@clawsweeper re-review Added focused cancel-during-sleep coverage for both image ( |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Triage Wave 5 closeout: closing without merge, not requesting changes. Current Local maintainer proof against current-main behavior:
The mandatory live gate could not be cleared. The installed GUI host reported Screen Recording and Accessibility granted, but caller-local, GUI/on-demand, and fallback captures all timed out. A generated XCTest bundle containing the production permission checker was signed with the current OpenClaw Foundation Developer ID and run with an ungranted Screen Recording identity; its real Per the strict requirement, deterministic injected-error tests and standalone mirrored scripts are not being presented as live ScreenCaptureKit proof. No commit was pushed and there is no merge SHA. Thanks @SebTardif for the accurate root-cause report and the focused cancellation work. |
What Problem This Solves
Transient ScreenCaptureKit denial handling in
ScreenCaptureFallbackRunner(imagerunCaptureand genericrunpaths) sleeps withtry? await Task.sleepbefore retrying the capture.try?swallowsCancellationError, so a canceled CLI/MCP capture can still enter a second full capture attempt after the delay instead of stopping promptly.This is the same cancellation-swallow class as merged #270 / #271 / #230 / #267.
Evidence
Before (main)
After (this branch)
Live terminal transcript (after fix)
Pattern proof (
scripts/prove-screencapture-engine-cancel.swift) on macOS 26.5.2, cancel 50ms into the 350ms denial sleep:Production helper exercised (same host, branch
4e12fa53):Both image (
runCapture) and generic/video-style (run) paths assertattempts == 1when canceled mid-sleep.Real behavior proof
Behavior or issue addressed: Canceling during a ScreenCaptureKit transient-denial sleep must not run a second capture attempt (image and video-style runners).
Real environment tested: macOS 26.5.2 (Build 25F84), arm64, Peekaboo worktree at commit
4e12fa53(this PR), Swift toolchain 6.x.Exact steps or command run after this patch:
swiftc -parse-as-library -o /tmp/prove-sck-engine scripts/prove-screencapture-engine-cancel.swift /tmp/prove-sck-engine swift test --package-path Core/PeekabooCore --filter ScreenCaptureFallbackRunnerTestsEvidence after fix: Terminal transcript above: unfixed path runs 2 attempts after cancel; fixed path stops at 1 attempt with
cancelledin ~52ms. Focused production-helper runs onScreenCaptureFallbackRunneralso keep attempts at 1 for bothrunandrunCapture.Observed result after fix: Cancellation during the 350ms denial sleep aborts before the retry
attempt(api). Non-cancelled transient denial still retries once (existing green case).What was not tested: Live ScreenCaptureKit TCC denial from a real display capture under a canceled CLI task (needs TCC denial injection on a signed binary). Retry delay duration and cancel contract match production
ScreenCaptureKitTransientError(350ms).Summary
ScreenCaptureEngineSupport/ScreenCaptureFallbackRunner.runandrunCapture.Related: #271, #270, #267, #230