Our iOS app, when running as an iOS App on Mac, crashes consistently under the following scenario: 1. Launch the app on an external display. 2. Minimize the app window. 3. Disconnect the external display.
The app crashes every time under these conditions. The crash log shows the following call stack:
*** Assertion failure in -[UINSWorkspace _maximumContentSizeForWindowOnScreen:], UINSWorkspace.m:401 -[UINSWorkspace _maximumContentSizeForWindowOnScreen:]: screen parameter should not be nil ( 0 CoreFoundation 0x000000018e841df0 __exceptionPreprocess + 176 1 libobjc.A.dylib 0x000000018e306b60 objc_exception_throw + 88 2 Foundation 0x000000018fb6aa78 -[NSCalendarDate initWithCoder:] + 0 3 UIKitMacHelper 0x00000001a9a59110 -[UINSWorkspace _maximumContentSizeForWindowOnScreen:] + 184 4 UIKitMacHelper 0x00000001a9a3e748 -[UINSSceneViewController _usableScreenSizeWithSceneSize:shouldOverride:] + 412 5 UIKitMacHelper 0x00000001a9a3d55c -[UINSSceneViewController _effectiveScaleFactorForLayoutWithOverride:] + 88 6 UIKitMacHelper 0x00000001a9a3f3a8 -[UINSSceneViewController _updateZoomFactors] + 28 7 UIKitMacHelper 0x00000001a9a3f248 -[UINSSceneViewController _updateZoomFactorsAndDoLayout] + 24 8 UIKitMacHelper 0x00000001a9a3df80 -[UINSSceneViewController _doUpdates:] + 104 9 UIKitMacHelper 0x00000001a99ad460 -[UINSSceneViewController observeValueForKeyPath:ofObject:change:context:] + 176 10 Foundation 0x000000018facb0d8 -[NSKeyValueObservance observeValueForKeyPath:ofObject:change:context:] + 388 11 Foundation 0x000000018facb0d8 -[NSKeyValueObservance observeValueForKeyPath:ofObject:change:context:] + 388 12 Foundation 0x000000018fa8f7b4 NSKeyValueNotifyObserver + 252 13 Foundation 0x000000018fb3c560 NSKeyValueDidChange + 388 14 Foundation 0x00000001903149a0 NSKeyValueDidChangeWithPerThreadPendingNotifications + 160 15 AppKit 0x00000001924673d4 -[NSThemeFrame _didChangeContentLayoutRect] + 76 16 AppKit 0x000000019246521c -[NSWindow _oldPlaceWindow:fromServer:] + 744 )
It seems like the system attempts to access a screen object that is already nil after the external monitor is removed. This leads to an assertion failure in UINSWorkspace.
Is there any known workaround or update planned to address this issue?
Thank you.