Repository navigation
sharper, smoother window recordings on macos - #1089
Kevin-Liu-01 wants to merge 2 commits into
Conversation
Window recordings captured the whole display and cropped every frame to the window with a CoreImage render on the sample queue. At display resolution that render took up to 200 ms per frame, which dropped video frames and delayed everything else on the queue. ScreenCaptureKit now crops the display to the window with sourceRect, and window tracking updates that rectangle as the window moves or resizes. A window that is not changing sends one complete frame when capture starts, and it could arrive before the writer was ready. The recording then never started. The newest frame is now kept until the writer can take it, and it starts the timeline when it is written. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The crop rectangle followed the window frame in points, and the output size was rounded down to an even number of pixels. On a 1x display a window with an odd width or height was therefore scaled by a fraction of a pixel, which turned one-pixel detail into gray. The crop now snaps to whole pixels and trims to an even size, so the recording holds the screen's own pixels. AVOutputSettingsAssistant sizes its bitrate and keyframe interval for 30 fps, but recordings run at 60. Scale the bitrate to the capture rate and keep one keyframe per second, so text stays sharp while the screen scrolls. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughWindow capture now uses ScreenCaptureKit’s native crop and updates it as the window moves or changes displays. The recorder also retries a pending first frame until the writer is ready, and configures encoding parameters from the requested frame rate. ChangesScreen Capture Recording
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant ScreenCaptureKit
participant Recorder
participant AVAssetWriter
ScreenCaptureKit->>Recorder: Deliver screen sample
Recorder->>Recorder: Save pending first frame and schedule retries
Recorder->>AVAssetWriter: Append retimed frame when writer is ready
AVAssetWriter-->>Recorder: Report append result
Recorder->>Recorder: Mark first accepted frame as ready
Suggested reviewers: Merge Risk: ⚪ Minimal · up to No actionable merge-blocking regression was established; the change is mergeable after the normal build and recording checks. Security Architecture ReviewSecurity architecture risk: 🟡 Moderate · up to Failed crop updates can leave recording active with stale geometry, particularly when a window changes displays. This could capture unintended screen content. Actual frame delivery during that state remains unverified, and the existing caller authority is not expanded. Retained concerns
Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
window recordings were slower and blurrier than they needed to be.
the same 401×301 window recorded on a 1x display. upstream squeezes 401 pixels into 400 and smears the one-pixel detail. this branch keeps every pixel.
what was going on
to record a window, recordly captured the whole display and cut the window out of every frame with core image. that cut took up to 210 ms per frame on my macbook, so a 1440×960 window recorded at 45.8 fps, and it ran on the same queue as the audio.
the cut also rounded the window down to an even number of pixels and scaled the window into that. on a 1x display, any window with an odd width or height came out blurry.
the bitrate came from settings meant for 30 fps, but recordly records at 60, so text broke up while scrolling.
one frame of fast scrolling. at upstream's 25 mbps the text breaks up, and at 43 mbps it stays close to the original. the bottom row shows how far each frame is from the original, brightened 8×.
what this changes
ScreenCaptureKitcrops the display itself withsourceRect, so there's no per-frame cut anymore. the same window now records at 56.9 fpshow to check
npx vitest run electron/nativenpm run build:native-helpersbuilds the helper. the binaries aren't in this prthis pr and #1088 both touch
ScreenCaptureKitRecorder.swift, so i'll rebase whichever lands second.🤖 Generated with Claude Code
Summary by CodeRabbit