fix: initialise CoreGraphics before building a window capture filter (cherry-pick for 1.10.0-rc.4) - #490
Merged
EtienneLescot merged 1 commit intoAug 23, 2026
Conversation
Selecting a window in the source picker aborted the ScreenCaptureKit
helper before it produced a single frame:
Assertion failed: (did_initialize), function CGS_REQUIRE_INIT,
file CGInitialization.c, line 44
The helper is a plain command-line executable, so nothing in it ever
connects to the window server. SCContentFilter(desktopIndependentWindow:)
resolves which display a window sits on by calling into SkyLight
(SLSGetDisplaysWithRect), and SkyLight asserts when CoreGraphics was
never initialised in the process.
Display capture is unaffected, because SCContentFilter(display:excludingWindows:)
is handed an already-resolved display and never asks SkyLight to resolve a
rect. That is why only the window branch of makeCaptureTarget crashed.
Touching any CoreGraphics display API performs the initialisation, so a
single CGMainDisplayID() at the top of main() is enough. CoreGraphics is
already imported; this avoids pulling AppKit into the helper or standing
up an NSApplication in a CLI process.
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
EtienneLescot
deleted the
claude/macos-window-capture-cgs-init-rc4-cherrypick
branch
August 23, 2026 12:03
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.
Cherry-pick of #488 onto
release/v1.10.0, for rc.4.macOS window capture has never worked: picking any window in the source picker aborts the ScreenCaptureKit helper before it produces a frame, with
Assertion failed: (did_initialize), function CGS_REQUIRE_INIT, file CGInitialization.c, line 44. Fixed by touching a CoreGraphics display API (CGMainDisplayID()) at the top ofmain(), which performs the window-server initialisationSCContentFilter(desktopIndependentWindow:)otherwise needs SkyLight for and never gets in a plain CLI process.Per the release contract in
technical-documentation/engineering/release-and-secrets.md, only the bug-fix commit is cherry-picked here — the follow-up refactor and the manual E2E checklist entry from #488 are docs/refactor changes that stay onmainand ship in the next cycle, not on the frozen release branch.Build and all 22 Swift unit tests verified green on this branch before pushing.