Repository navigation
Record selected macOS windows natively with ScreenCaptureKit - #17012
vkodithala wants to merge 4 commits into
Conversation
Keep window identity isolated across occlusion and movement, encode a fixed canvas, and finalize partial captures when the target becomes unavailable. Preserve the existing screen recorder and shared smart trim. Co-authored-by: vkodithala <varoon@warp.dev>
Co-authored-by: vkodithala <varoon@warp.dev>
Co-authored-by: vkodithala <varoon@warp.dev>
|
This PR was generated with Warp, requested by @vkodithala. Comment |
Remove CoreImage from the BGRA handoff so capture buffers cannot be retained by deferred image rendering. Native covered-content freshness still requires macOS verification. Co-authored-by: vkodithala <varoon@warp.dev>
|
Freshness still blocks |
First principles: what works, what stopped updating, and the smaller optionI have not demonstrated a regression in the shipped recorder. The failure is in this proposed new selected-window video path when another window covers the target. The earlier demo does show useful things working: window isolation, movement/resize, and playable output. Calling it generally frozen—or presenting it as complete passing proof—was imprecise. What ‘freeze’ meansThe movie keeps playing, but the target's picture stops changing. Think of a recorded stopwatch: the playback scrubber advances while the stopwatch holds an old number, then jumps forward after uncovering. It is not a black frame or a player crash. There are several different evidence files, with different timelines. The earlier GUI demonstration is not the same file as the raw or trimmed output; timestamps must not be transferred between them. A later precisely timed diagnostic, using Terminal printing a counter once per second, held counter 2727 from movie time 1.847s to 59.333s, then jumped to 2784. That diagnostic used OS-default ScreenCaptureKit settings and Apple's own The built-in Three separate jobs
Background input and individual screenshots do not automatically provide a continuous video stream. Adding recording does not require rebuilding input. Linux todayRust resolves the X11 window and dimensions, checks visibility at startup, raises the target if necessary, then launches ffmpeg Importantly, Linux requires a foreground-visible target at startup; it is not an established background/covered-window video guarantee. The visibility check is not continuous. Treating occlusion-proof Mac video as already-achieved Linux parity overstated the baseline. Sources: window selection and ffmpeg, visibility and raise, stop/finalization. Existing Mac background computer usePictures: we already invoke Apple's Input: we send Quartz events to the owning process with What the new
|
Inspectable evidence and availability correctionIn the original 60.940s RAW video, prior samples show clock 71.0 across 31–36s and 80.6 across 41–46s. These are RAW-movie offsets, not timestamps in the shared GUI demonstration; its exact seek offset was not established. A separate, later 38.430s diagnostic at the same3807 head gives the clearer comparison: at capture offset 29.082s, the recorded frame reads56.1, while the contemporaneous independent target image reads64.9—about8.8s stale. Earlier in that run, at19.270s, the values were55.0 versus55.1, so this is not a permanent clock offset. That diagnostic's original RAW movie. At current310c, a separate confirmed-cover diagnostic at15.091s likewise shows recorded37.5 versus independent46.5. These two artifacts are screenshots of the images displayed in Preview. Correction to the explanation above: the later OS-default57.49s diagnostic movie was never published and its scratch directory is no longer present in the resumed runner. Its measurements survive in the investigation record, but the movie is not currently available to inspect. The published comparisons above are the recoverable evidence. None establishes a regression from the previously shipped recorder. |
Linux comparison: stop/save is the difference; resize parity was overstatedBoth signals stop both processes. The difference is whether stopping leaves a usable movie. Stop, finalization, and upload are separateOn Linux, The Mac utility tests showed something different: SIGINT and SIGTERM stopped
Sources: Linux recorder and finalization, exit watcher and preparation/upload, FFmpeg signal handling. The FFmpeg reference is upstream source, not a claim that this run tested a particular deployed binary. Resize: Linux does not promise full-content fitting eitherI held this Mac draft to a stronger standard than the existing Linux implementation. Linux resolves the initial dimensions once and passes a fixed Mac Full-content aspect-preserving resize was an approach I proposed and carried into the draft—not existing Linux parity or a separate requirement independently demanded by the requester. Accepting Linux-like resize limitations is a reasonable v1 scope choice and should not, by itself, force a more elaborate backend. What remains to chooseThe simple utility remains a plausible timed-only v1 if that workflow is acceptable: choose a duration, let the timer finish, then prepare/upload; document resize limitations. Early-stop/save is the important remaining difference. For example, a Stop at 4 seconds cannot currently return its saved movie promptly; with a preselected 10-minute timer, availability could wait until that timer expires. Killing early produced no requested movie. This does not prove that no better Mac mechanism exists. It establishes the tested invocation's behavior on macOS 26.6.2 with SIGINT/SIGTERM. The raw diagnostic publication failed at the artifact cap, as documented in the PR; the available baseline screenshot is not visual proof of signal/cropping failures. No code has changed. The decision remains open: accept timed-only behavior, authorize the proposed bounded screenshot-to-ffmpeg feasibility check, or pause. This comparison does not itself accept limitations or authorize another backend. |


Description
Record one explicitly selected macOS window with ScreenCaptureKit instead of silently recording the main display. A display crop cannot retain occluded window content. The native stream pins the window ID and owner, keeps a fixed H.264 canvas, and finalizes a partial recording when the target disappears. Screen recording stays on the existing ffmpeg path; Linux/Windows capture and overlays are unchanged. Shared smart trimming and thumbnail/upload handling remain in place.
The bridge loads ScreenCaptureKit dynamically on macOS 12.3+, preserving the older whole-screen path. Aspect-preservation and shadow configuration are guarded at macOS 14. Manual runtime verification covers macOS 26.6.2 arm64 only. Detached dialogs are not automatically included or retargeted.
Blocked on covered-content freshness at current head
310c1efaa9681f86354373148238f4f106790965: native rebuild passed, but synchronous locked BGRA copying did not fix stale covered frames. A corrected native-main-loop harness and confirmed floating-cover occlusion reproduce the failure. In the latest diagnostic, incoming ScreenCaptureKit callbacks stopped for 29.662s while fully covered and resumed 0.0067s after uncovering. Received source frames, private copies and encoded images match when callbacks arrive. This localizes the observed gap to callback delivery or upstream backing refresh, not demonstrated copy/encoder corruption; it does not establish an Apple bug or why delivery stops. Fixture drawing callbacks continue, but returning from a draw is not proof of WindowServer publication. The SDK describesignoreGlobalClipSingleWindowas offscreen-placement clipping, not an occluded-refresh guarantee.Current310c confirmed floating-cover diagnostic: before · after · completed. Earlier intermediate runs without genuine occlusion are unoccluded baselines, not freshness passes. Videos below remain explicitly earlier-head3807 evidence, not current-head passing proof.
Linked Issue
APP-5102 — supersedes only the crop-based window-capture portion of #14811. Broader parity/overlay work remains separate; this PR does not close the shared issue.
ready-to-specorready-to-implement. Implementation was explicitly authorized; a spec was explicitly skipped.Testing
310c1ef: Linuxcargo check -p computer_use --libpassed; rustfmt and clang-format applied. macOS native rebuild passed; covered-content freshness verification failed as described above. Current-head full native tests/lint and final acceptance proof remain outstanding.3807ffd1ec6198701664ad5fc80560127c216b15, macOS 26.6.2 arm64 / SDK 26.4: 95computer_uselib tests passed, two intentional thumbnail tests skipped; targeted Clippy passed with warnings denied. Native compilation produced no candidate warnings.TargetUnavailable/StoppedEarlyoutput. Invalid window/owner requests failed closed. Two-second limit finalized at 2.000s. Active-drop/start-cancel cleanup left no partials.cargo check -p warp --libpassed. The unchanged real-X11 raise/visibility test fails in this sandbox and was excluded from the passing run../script/run. Native recorder was exercised through an external production-API harness on the macOS runner, not the full desktop app.Screenshots / Videos
Earlier3807 macOS GUI flow and actual output playback · still
Earlier3807 prepared native-window video · raw capture · 2s limit sample · checks, lifecycle and frame evidence
Agent Mode
Exact3807 native capture proof flow: Run lifecycle checks, capture target with cover/move/resize/close, finalize, then play final and raw output in QuickTime.
View video recording - 3807ffd exact-head native selected-window original MP4,60.940s,1440x944; covered clock freezes remain an unresolved observation.
View video recording - 3807ffd exact-head prepare_recording output40.730s,1440x944, both real text actions and undistorted tall resize; retains observed raw clock freezes.
View video recording - 3807ffd native2.000-second duration-bound output,LimitReached,StoppedEarly,1440x944.
Final.mp4 playback at 0:41 end: tall target top-left with FIRST and SECOND FINAL3807 strings, round circle, square, clock 101.5s, black padding on right
Native utility baseline final-status capture — QA fixture on macOS 26.6.2 (25G83) arm64 / Xcode 26.4.1, not this PR's production candidate. This desktop/status screenshot is not visual proof of decoded resize cropping or signal outcomes.
Native utility prerequisite assessment (not implemented)
The separate QA AppKit fixture exercised
/usr/sbin/screencapture -v -o -l<ID> -V10 <private.mov>on macOS 26.6.2 arm64. No source or permission changes were made.-Vstop; no graceful CLI/signal stop mechanism was found.-o, output was 1504×1088 surrounding the same 1280×864 target with opaque black; with-othe target filled the frame. This does not establish soft-shadow fidelity.Publication limitation: the helper's 20-file artifact cap rejected raw movies, decoded frames, and the evidence archive; no retries were made. The linked baseline status screenshot remains recoverable, but it does not show the failure symptoms above. Movies, decoded frames, logs and aggregate results were local-only and may be lost after helper reset; do not treat them as downloadable proof. The selected direct utility route is not yet compatible with agreed early-stop and full-resize behavior. A bounded screenshot-to-ffmpeg feasibility proposal is awaiting user authorization; this PR remains draft at
310c1ef.