Replace ScreenCaptureKit with SkyLight for tile previews (#21)#22
Merged
Conversation
Move live tile previews off per-window SCStream onto a polled SkyLight private API (CGSHWCaptureWindowList). Switch window enumeration from SCShareableContent to CGWindowListCopyWindowInfo. Tighten the onboarding window and auto-relaunch when Accessibility is granted. ScreenCaptureKit is gone from the runtime path. Screen Recording is still required on current macOS — CGSHWCaptureWindowList is gated on it and the menu-bar recording indicator still attributes capture to us.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The window picker grid used Apple's ScreenCaptureKit framework to render a live preview of every open window. That had three problems we wanted to address (issue #21):
Solution
What this does not do: it does not remove the Screen Recording permission requirement, and it does not remove the menu-bar recording indicator while the picker is open. The SkyLight function still requires the permission on current macOS, and the system still attributes the capture to us in the indicator. Getting rid of those would mean a much larger change (mirroring each window's layer directly into our process), which we have not done here.
Technical Summary
SkyLightCapture.swift: thin wrapper that looks upCGSMainConnectionIDandCGSHWCaptureWindowListin/System/Library/PrivateFrameworks/SkyLight.frameworkusingdlsym, so a future macOS that renames or removes those symbols degrades to a still-functional picker with no live thumbnails rather than a crash.WindowInfo.swift: plain struct populated fromCGWindowListCopyWindowInfo+NSRunningApplication, replacing every place we used to depend onSCWindow.Tile.swiftwas rewritten end-to-end. TheSCStream/SCStreamOutput/SCStreamDelegatemachinery, the stop-and-restart watchdog, theCVPixelBuffertoCGImagepromotion, and the serialization queue from issue Crash in Tile.start() — EXC_BAD_ACCESS in -[SCContentFilter initWithDesktopIndependentWindow:] (concurrent overlay install) #18 are all gone. Capture is now a singleDispatchSourceTimerthat callsSkyLightCapture.captureImage(windowID:)and assigns the resultingCGImageto the tile's layer on the main queue. Net change: ~750 lines down to ~430.Overlay.swiftno longer imports ScreenCaptureKit. Window enumeration isWindowInfo.enumerate(). TheprewarmShareablewarm-up call and theSCShareableContentround trip are gone. The window-eligibility filter is rewritten againstWindowInfo(and now requireskCGWindowLayer == 0, whichSCShareableContentalready implied).main.swiftdrops itsSCShareableContent.currentwarm-up.Onboarding.swift: removes the explicit Continue button, replaces it with a 0.5 s poll ongranted(), and on success relaunches the app viaNSWorkspace.openApplicationwithcreatesNewApplicationInstance = trueso any event tap re-registers under the fresh permission state. The window now sizes tocontent.fittingSizeinstead of a fixed 520×400. The permission row exposes a new "pending" state that swaps the rationale to "Find ⌘ ⌘ in the list and turn it on…" the moment the user clicks Grant.--stressthat exercised the very setup race we have now removed, and is no longer reachable from normal startup.