ScreenCaptureKit crashes on Mac Catalyst apps

I'm trying to use ScreenCaptureKit on a Mac Catalyst app, on macOS 12.5.1. I'm not sure if I'm doing something wrong, but it crashes as soon as I try to request SCShareableContent. It crashes on internal code, calling a method it can't find, which makes me think this is a bug in the framework rather than incorrect configuration.

Any hints on how to work around this problem?

The crash is:

** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RPDaemonProxy fetchShareableContentWithOption:windowID:withCompletionHandler:]: unrecognized selector sent to instance 0x6000037d5dc0'

terminating with uncaught exception of type NSException

2022-09-04 18:05:14.493665-0700 TestCapture[22870:2568018] [General] -[RPDaemonProxy fetchShareableContentWithOption:windowID:withCompletionHandler:]: unrecognized selector sent to instance 0x6000037d5dc0
2022-09-04 18:05:14.493748-0700 TestCapture[22870:2568018] [General] (
	0   CoreFoundation                      0x0000000195aad1a8 __exceptionPreprocess + 240
	1   libobjc.A.dylib                     0x00000001957f7e04 objc_exception_throw + 60
	2   CoreFoundation                      0x0000000195b40f4c -[NSObject(NSObject) __retain_OA] + 0
	3   CoreFoundation                      0x0000000195a0c25c ___forwarding___ + 1004
	4   CoreFoundation                      0x0000000195a0bdb0 _CF_forwarding_prep_0 + 96
	5   ScreenCaptureKit                    0x00000001fb6aaba8 +[SCShareableContent fetchShareableContentWithOption:windowID:completionHandler:] + 300
	6   TestCapture                         0x00000001004f7594 $s11TestCapture14ViewControllerC11viewDidLoadyyF + 220
	7   TestCapture                         0x00000001004f7d80 $s11TestCapture14ViewControllerC11viewDidLoadyyFTo + 36
	8   UIKitCore                           0x00000001bdaf2864 -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 104
	9   UIKitCore                           0x00000001bdadc438 -[UIViewController loadViewIfRequired] + 1284
	10  UIKitCore                           0x00000001bdadbf0c -[UIViewController view] + 32
	11  UIKitCore                           0x00000001bdb33374 -[UIWindow addRootViewControllerViewIfPossible] + 180
	12  UIKitCore                           0x00000001bdac9230 -[UIWindow _updateLayerOrderingAndSetLayerHidden:actionBlock:] + 232
	13  UIKitCore                           0x00000001bdb315c4 -[UIWindow _setHidden:forced:] + 280
	14  UIKitCore                           0x00000001bdb313f8 -[UIWindow _mainQueue_makeKeyAndVisible] + 56
	15  UIKitCore                           0x00000001bdab4d88 -[UIWindowScene _makeKeyAndVisibleIfNeeded] + 204
	16  UIKitCore                           0x00000001bdaab92c +[UIScene _sceneForFBSScene:create:withSession:connectionOptions:] + 1768
	17  UIKitCore                           0x00000001bdaa9c54 -[UIApplication _connectUISceneFromFBSScene:transitionContext:] + 1256
	18  UIKitCore                           0x00000001bdaa8988 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 344
	19  UIKitCore                           0x00000001bdaa879c -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 388
	20  FrontBoardServices                  0x00000001a834cbc4 -[FBSScene _callOutQueue_agent_didCreateWithTransitionContext:completion:] + 440
	21  FrontBoardServices                  0x00000001a8371a68 __94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke.215 + 128
	22  FrontBoardServices                  0x00000001a8338ffc -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 240
	23  FrontBoardServices                  0x00000001a8371634 __94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke + 372
	24  libdispatch.dylib                   0x0000000100ade3a8 _dispatch_client_callout + 20
	25  libdispatch.dylib                   0x0000000100ae27ac _dispatch_block_invoke_direct + 388
	26  FrontBoardServices                  0x00000001a8338ee4 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 48
	27  FrontBoardServices                  0x00000001a838e5d0 -[FBSSerialQueue _targetQueue_performNextIfPossible] + 220
	28  FrontBoardServices                  0x00000001a8338e84 -[FBSSerialQueue _performNextFromRunLoopSource] + 28
	29  CoreFoundation                      0x0000000195a2d044 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
	30  CoreFoundation                      0x0000000195a2cf90 __CFRunLoopDoSource0 + 208
	31  CoreFoundation                      0x0000000195a2cc90 __CFRunLoopDoSources0 + 268
	32  CoreFoundation                      0x0000000195a2b610 __CFRunLoopRun + 828
	33  CoreFoundation                      0x0000000195a2ab34 CFRunLoopRunSpecific + 600
	34  HIToolbox                           0x000000019e66a338 RunCurrentEventLoopInMode + 292
	35  HIToolbox                           0x000000019e66a0b4 ReceiveNextEventCommon + 564
	36  HIToolbox                           0x000000019e669e68 _BlockUntilNextEventMatchingListInModeWithFilter + 72
	37  AppKit                              0x000000019859251c _DPSNextEvent + 860
	38  AppKit                              0x0000000198590e14 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1328
	39  AppKit                              0x0000000198582fe0 -[NSApplication run] + 596
	40  AppKit                              0x00000001985546fc NSApplicationMain + 1132
	41  AppKit                              0x000000019882a640 +[NSWindow _savedFrameFromString:] + 0
	42  UIKitMacHelper                      0x00000001ab2ef3c0 UINSApplicationMain + 1276
	43  UIKitCore                           0x00000001bda8cc2c UIApplicationMain + 164
	44  libswiftUIKit.dylib                 0x00000001d39e2e58 $s5UIKit17UIApplicationMainys5Int32VAD_SpySpys4Int8VGGSgSSSgAJtF + 104
	45  TestCapture                         0x00000001004f8918 $sSo21UIApplicationDelegateP5UIKitE4mainyyFZ + 104
	46  TestCapture                         0x00000001004f88a0 $s11TestCapture11AppDelegateC5$mainyyFZ + 44
	47  TestCapture                         0x00000001004f899c main + 28
	48  dyld                                0x000000010069908c start + 520
)

I filed this as FB11451378. In the mean time I'd appreciate any pointers on how to get this working. Some potential workarounds I'm considering are using an older API for screen capture, or make a small helper XPC service in native macOS code that'd do the capturing, but it'll probably be more complex than it needs to be.

Seeing the same crash from here, curious if you found the cause or found a workaround, thanks!

Having the same issue. With CGDisplayCreateImage being obsoleted it looks like there's no way to capture a window on mac catalyst?

ScreenCaptureKit crashes on Mac Catalyst apps
 
 
Q