Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
refactor(macos-capture): name the CoreGraphics init call, cross-reference the other one
Etienne Lescot439ef59c745b
diff --git a/electron/native/screencapturekit/Sources/OpenScreenScreenCaptureKitHelper/ScreenCaptureRecorder.swift b/electron/native/screencapturekit/Sources/OpenScreenScreenCaptureKitHelper/ScreenCaptureRecorder.swiftindex 2e88e5c41..5add8074d 100644--- a/electron/native/screencapturekit/Sources/OpenScreenScreenCaptureKitHelper/ScreenCaptureRecorder.swift+++ b/electron/native/screencapturekit/Sources/OpenScreenScreenCaptureKitHelper/ScreenCaptureRecorder.swift@@ -413,6 +413,9 @@ final class ScreenCaptureRecorder: NSObject, SCStreamOutput, SCStreamDelegate {let size = captureSize(for: filter,fallbackPointSize: window.frame.size,+ // Unrelated to `initializeCoreGraphicsWindowServerConnection()`: that call+ // exists purely for its side effect at process startup, this one wants the+ // actual display ID as a fallback when no display intersects the window.fallbackDisplayId: candidateDisplay?.displayID ?? CGMainDisplayID())return CaptureTarget(@@ -800,16 +803,20 @@ final class ScreenCaptureRecorder: NSObject, SCStreamOutput, SCStreamDelegate {@mainstruct OpenScreenScreenCaptureKitHelper {+ // This helper is a plain command-line executable, so nothing has connected it to the+ // window server yet. `SCContentFilter(desktopIndependentWindow:)` reaches into SkyLight+ // (`SLSGetDisplaysWithRect`) to find the display a window sits on, and SkyLight aborts+ // with `CGS_REQUIRE_INIT` when CoreGraphics was never initialised in the process — so+ // every window capture crashed before it produced a frame, while display capture (which+ // never resolves a rect) worked fine. Touching any CoreGraphics display API first+ // performs that initialisation.+ private static func initializeCoreGraphicsWindowServerConnection() {+ _ = CGMainDisplayID()+ }+static func main() async {do {- // This helper is a plain command-line executable, so nothing has connected it to- // the window server yet. `SCContentFilter(desktopIndependentWindow:)` reaches into- // SkyLight (`SLSGetDisplaysWithRect`) to find the display a window sits on, and- // SkyLight aborts with `CGS_REQUIRE_INIT` when CoreGraphics was never initialised- // in the process — so every window capture crashed before it produced a frame,- // while display capture (which never resolves a rect) worked fine. Touching any- // CoreGraphics display API first performs that initialisation.- _ = CGMainDisplayID()+ initializeCoreGraphicsWindowServerConnection()guard CommandLine.arguments.count == 2 else {throw HelperError.invalidArguments