In our mac catalyst app we access AppKit api's by using MacOS bundle(plugin).
when using CGDisplayCreateImage(_: CGDirectDisplayID, rect: CGRect) method the plugin crashes.
Implementation:
@objc
func windowMoved(_ notification: NSNotification) {
guard let win = self.window else {
return
}
let displayId = CGMainDisplayID()
let winRect = win.contentView?.convert(qrRect, from: self)
var rect = win.convertToScreen(winRect ?? self.bounds)
if let screenFrame = NSScreen.main?.visibleFrame {
rect.origin.y = screenFrame.height - rect.maxY
rect.origin.y += screenFrame.minY + win.titlebarHeight
}
guard let image = CGDisplayCreateImage(
displayId,
rect: rect) else {
return
}
guard let qrString = image.detectQRCode().first else { return }
// ...
}
Crash report in printed in console:
-[RPDaemonProxy proxyCoreGraphicsWithMethodType:config:machPort:completionHandler:]: unrecognized selector sent to instance 0x600000500960
(
0 CoreFoundation 0x00000001931deccc __exceptionPreprocess + 176
1 libobjc.A.dylib 0x0000000192cc6788 objc_exception_throw + 60
2 CoreFoundation 0x000000019329102c -[NSObject(NSObject) __retain_OA] + 0
3 CoreFoundation 0x0000000193148a80 ___forwarding___ + 976
4 CoreFoundation 0x00000001931485f0 _CF_forwarding_prep_0 + 96
5 ScreenCaptureKit 0x0000000227d9d95c SLSHWCaptureDesktopProxying + 692
6 SkyLight 0x0000000198b370a8 SLSHWCaptureDesktop + 488
7 SkyLight 0x0000000198b3b1ac SLSDisplayCreateImage + 252
8 MacPlugin 0x0000000112e0d374 $s9MacPlugin14MZMacQrScannerC11windowMovedyySo14NSNotificationCF + 1500
9 MacPlugin 0x0000000112e0d714 $s9MacPlugin14MZMacQrScannerC11windowMovedyySo14NSNotificationCFTo + 52
10 CoreFoundation 0x000000019315eb1c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 148
11 CoreFoundation 0x00000001931f2db8 ___CFXRegistrationPost_block_invoke + 88
12 CoreFoundation 0x00000001931f2d00 _CFXRegistrationPost + 440
13 CoreFoundation 0x000000019312d648 _CFXNotificationPost + 768
14 Foundation 0x0000000194249434 -[NSNotificationCenter postNotificationName:object:userInfo:] + 88
15 AppKit 0x00000001969ffbfc -[NSWindow _setFrameCommon:display:fromServer:] + 2056
16 AppKit 0x0000000197475080 -[NSWindow _windowMovedToRect:dueToMoveEvent:] + 184
17 AppKit 0x0000000196ae8630 -[NSWindow _windowMoved:] + 832
18 AppKit 0x0000000196ae82a4 -[NSWindow _internalHandleAppKitDefinedEvent:] + 152
19 AppKit 0x0000000196ae8074 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 528
20 AppKit 0x0000000196ae7c90 -[NSWindow(NSEventRouting) sendEvent:] + 284
21 AppKit 0x00000001971adda8 -[NSApplication(NSEventRouting) sendEvent:] + 1800
22 UIKitMacHelper 0x00000001acb964f8 -[NSApplication(UINSApplicationSwizzling) _uinsSwizzledSendEvent:] + 252
23 AppKit 0x0000000196dfb954 -[NSApplication _handleEvent:] + 60
24 AppKit 0x00000001969afd24 -[NSApplication run] + 512
25 AppKit 0x0000000196986fa4 NSApplicationMain + 880
26 AppKit 0x0000000196bd9798 +[NSWindow _savedFrameFromString:] + 0
27 UIKitMacHelper 0x00000001acb82198 UINSApplicationMain + 972
28 UIKitCore 0x00000001c2ea2924 UIApplicationMain + 148
29 MyApp-DEBUG 0x00000001049d2d04 main + 64
30 dyld 0x0000000192d020e0 start + 2360
This is working fine in all previous version but crashing in macOS beta 14.4 and 14.4.1.