fix: initialise CoreGraphics before building a window capture filter (cherry-pick for 1.10.0-rc.4) - #490
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.
|
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 |
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.