Changing presentation style crashes app

Hello! I've been digging into this for a little bit now, and am hitting something of a wall. Our app is crashing occasionally, and googling the crash yields literally 0 results.

Tl;dr: Something related to adaptivePresentationStyle(for:traitCollection:) is resulting in our app crashing.

Context

In our app, we have a custom UIPresentationController that we use to present a small sheet of content overlaying other app content - similar to a UISheetPresentationController with a medium-ish size. So we have a custom UIViewController to present, and it conforms to the UIAdaptivePresentationControllerDelegate protocol. We also have custom present and dismiss animators.

The crash

However, we seem to be running into a really odd crash. I've attached a crash report as well, but here's what one sees in xcode on reproducing the crash:

The _computeToEndFrameForCurrentTransition block is nil inside the _transitionViewForCurrentTransition block, value of outerStrongSelf currently : <XxxYyyyyyZzz.PopupPresentationController: 0x12d017a40>. This most likely indicates that an adaptation is happening after a transtion cleared out _computeToEndFrameForCurrentTransition. Captured debug information outside block: presentationController : <XxxYyyyyyZzz.PopupPresentationController: 0x12d017a40> presentedViewController : <XxxYyyyyyZzz.SomeViewController: 0x12d03a690> presentingViewController : <UINavigationController: 0x12a817400>

Incident Identifier: 39F8711F-699B-4E97-9122-36AD863DCD63
Hardware Model:      iPhone15,2
Process:             XxxYyyyyyZzz [4101]
Path:                /private/var/containers/Bundle/Application/62F17CD5-0791-4527-88BC-3F4B2CD1C3F6/XxxYyyyyyZzz.app/XxxYyyyyyZzz
Identifier:          com.aaaaaaaaaaa.bbbbbbbbb
Version:             1.11.1 (1.11.1.111.1)
AppStoreTools:       14E221
AppVariant:          1:iPhone15,2:16
Code Type:           ARM-64 (Native)
Role:                Foreground
Parent Process:      launchd [1]
Coalition:           com.aaaaaaaaaaa.bbbbbbbbb [621]

Date/Time:           2023-09-25 08:02:33.6523 -0500
Launch Time:         2023-09-22 10:04:39.4774 -0500
OS Version:          iPhone OS 16.6.1 (20G81)
Release Type:        User
Baseband Version:    1.80.02
Report Version:      104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Termination Reason: SIGNAL 6 Abort trap: 6
Terminating Process: XxxYyyyyyZzz [4101]

Triggered by Thread:  0

Last Exception Backtrace:
0   CoreFoundation                	0x1afa28cb4 __exceptionPreprocess + 164 (NSException.m:202)
1   libobjc.A.dylib               	0x1a8abc3d0 objc_exception_throw + 60 (objc-exception.mm:356)
2   Foundation                    	0x1aa1b2688 -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 172 (NSException.m:251)
3   UIKitCore                     	0x1b1d05610 __80-[UIPresentationController _initViewHierarchyForPresentationSuperview:inWindow:]_block_invoke + 2588 (UIPresentationController.m:1594)
4   UIKitCore                     	0x1b21f1ff4 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke_3 + 300 (UIPresentationController.m:1228)
5   UIKitCore                     	0x1b1c2dca8 -[_UIAfterCACommitBlock run] + 72 (_UIAfterCACommitQueue.m:137)
6   UIKitCore                     	0x1b1c2dbdc -[_UIAfterCACommitQueue flush] + 168 (_UIAfterCACommitQueue.m:228)
7   UIKitCore                     	0x1b1c2daf0 _runAfterCACommitDeferredBlocks + 496 (UIApplication.m:3249)
8   UIKitCore                     	0x1b1acc428 _cleanUpAfterCAFlushAndRunDeferredBlocks + 108 (UIApplication.m:3213)
9   UIKitCore                     	0x1b1f8b4e4 _UIApplicationFlushCATransaction + 72 (UIApplication.m:3290)
10  UIKitCore                     	0x1b20dbd94 _UIUpdateSequenceRun + 84 (_UIUpdateSequence.mm:114)
11  UIKitCore                     	0x1b2740894 schedulerStepScheduledMainSection + 144 (_UIUpdateScheduler.m:1015)
12  UIKitCore                     	0x1b273fdf0 runloopSourceCallback + 92 (_UIUpdateScheduler.m:1164)
13  CoreFoundation                	0x1afaf2128 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28 (CFRunLoop.c:1957)
14  CoreFoundation                	0x1afafe7b4 __CFRunLoopDoSource0 + 176 (CFRunLoop.c:2001)
15  CoreFoundation                	0x1afa83648 __CFRunLoopDoSources0 + 340 (CFRunLoop.c:2046)
16  CoreFoundation                	0x1afa990d4 __CFRunLoopRun + 828 (CFRunLoop.c:2953)
17  CoreFoundation                	0x1afa9e3ec CFRunLoopRunSpecific + 612 (CFRunLoop.c:3418)
18  GraphicsServices              	0x1eafb435c GSEventRunModal + 164 (GSEvent.c:2196)
19  UIKitCore                     	0x1b1e2af58 -[UIApplication _run] + 888 (UIApplication.m:3782)
20  UIKitCore                     	0x1b1e2abbc UIApplicationMain + 340 (UIApplication.m:5372)
21  XxxYyyyyyZzz                  	0x100cb8944 main + 96 (main.m:17)
22  dyld                          	0x1cefd0dec start + 2220 (dyldMain.cpp:1165)

Thread 0 name:
Thread 0 Crashed:
0   libsystem_kernel.dylib        	0x00000001ee9e5578 __pthread_kill + 8 (:-1)
1   libsystem_pthread.dylib       	0x000000020f860118 pthread_kill + 268 (pthread.c:1670)
2   libsystem_c.dylib             	0x00000001b6fa8c04 __abort + 128 (abort.c:155)
3   libsystem_c.dylib             	0x00000001b6f50184 abort + 192 (abort.c:126)
4   libc++abi.dylib               	0x000000020f79ebf8 abort_message + 132 (:-1)
5   libc++abi.dylib               	0x000000020f78e444 demangling_terminate_handler() + 348 (:-1)
6   libobjc.A.dylib               	0x00000001a8ac1ea4 _objc_terminate() + 144 (objc-exception.mm:498)
7   FirebaseCrashlytics           	0x0000000101242ba0 FIRCLSTerminateHandler() + 340 (FIRCLSException.mm:327)
8   libc++abi.dylib               	0x000000020f79dfbc std::__terminate(void (*)()) + 16 (:-1)
9   libc++abi.dylib               	0x000000020f7a0f44 __cxa_rethrow + 148 (:-1)
10  libobjc.A.dylib               	0x00000001a8abdd5c objc_exception_rethrow + 44 (objc-exception.mm:401)
11  CoreFoundation                	0x00000001afa9e4b0 CFRunLoopRunSpecific + 808 (CFRunLoop.c:3434)
12  GraphicsServices              	0x00000001eafb435c GSEventRunModal + 164 (GSEvent.c:2196)
13  UIKitCore                     	0x00000001b1e2af58 -[UIApplication _run] + 888 (UIApplication.m:3782)
14  UIKitCore                     	0x00000001b1e2abbc UIApplicationMain + 340 (UIApplication.m:5372)
15  XxxYyyyyyZzz                  	0x0000000100cb8944 main + 96 (main.m:17)
16  dyld                          	0x00000001cefd0dec start + 2220 (dyldMain.cpp:1165)

Thread 1:
0   libsystem_pthread.dylib       	0x000000020f859b74 start_wqthread + 0 (:-1)

Thread 2:
0   libsystem_pthread.dylib       	0x000000020f859b74 start_wqthread + 0 (:-1)

Thread 3 name:
Thread 3:
0   CoreFoundation                	0x00000001afaa1f38 __CFStringCreateImmutableFunnel3 + 1256 (CFString.c:0)
1   CoreFoundation                	0x00000001afaa8700 CFStringCreateWithCString + 96 (CFString.c:1879)
2   XxxYyyyyyZzz                  	0x0000000100f24958 -[APMSqliteStore recordsForQuery:parameterValues:error:withFilter:] + 548
3   XxxYyyyyyZzz                  	0x0000000100f24704 -[APMSqliteStore recordsForQuery:parameterValues:error:] + 76
4   XxxYyyyyyZzz                  	0x0000000100ea3854 -[APMDatabase dataTypesFromTableWithName:columnName:columnValue:error:createDataTypeBlock:] + 384
5   XxxYyyyyyZzz                  	0x0000000100e985b8 -[APMDatabase dailyCounts:] + 224
6   XxxYyyyyyZzz                  	0x0000000100ed604c __57-[APMMeasurement(Event) writeFilteredEventOnWorkerQueue:]_block_invoke + 160
7   XxxYyyyyyZzz                  	0x0000000100f24dd8 -[APMSqliteStore performTransactionWithError:block:] + 176
8   XxxYyyyyyZzz                  	0x0000000100e97d38 -[APMDatabase performTransaction:] + 48
9   XxxYyyyyyZzz                  	0x0000000100ed5f80 -[APMMeasurement(Event) writeFilteredEventOnWorkerQueue:] + 264
10  XxxYyyyyyZzz                  	0x0000000100ed5bc4 -[APMMeasurement(Event) writeEventOnWorkerQueue:] + 1444
11  XxxYyyyyyZzz                  	0x0000000100ed54b0 -[APMMeasurement(Event) handleEventOnWorkerQueue:] + 540
12  XxxYyyyyyZzz                  	0x0000000100ecb684 -[APMMeasurement logEventOnWorkerQueue:notifyEventListeners:] + 76
13  XxxYyyyyyZzz                  	0x0000000100ecb634 -[APMMeasurement logEventOnWorkerQueueWithOrigin:isPublicEvent:name:parameters:timestamp:enabled:ignoreEnabled:ignoreInterceptor:interceptor:addedScreenParameters:] + 708
14  XxxYyyyyyZzz                  	0x0000000100ecb2c8 __151-[APMMeasurement logEventWithOrigin:isPublicEvent:name:parameters:timestamp:enabled:ignoreEnabled:ignoreInterceptor:interceptor:addedScreenParameters:]_block_invoke + 68
15  XxxYyyyyyZzz                  	0x0000000100f1a4b0 __51-[APMScheduler scheduleOnWorkerQueueBlockID:block:]_block_invoke + 44
16  libdispatch.dylib             	0x00000001b6eee320 _dispatch_call_block_and_release + 32 (init.c:1518)
17  libdispatch.dylib             	0x00000001b6eefeac _dispatch_client_callout + 20 (object.m:560)
18  libdispatch.dylib             	0x00000001b6ef7534 _dispatch_lane_serial_drain + 668 (queue.c:3885)
19  libdispatch.dylib             	0x00000001b6ef80a4 _dispatch_lane_invoke + 384 (queue.c:3976)
20  libdispatch.dylib             	0x00000001b6f02cdc _dispatch_workloop_worker_thread + 648 (queue.c:6507)
21  libsystem_pthread.dylib       	0x000000020f859ddc _pthread_wqthread + 288 (pthread.c:2618)
22  libsystem_pthread.dylib       	0x000000020f859b7c start_wqthread + 8 (:-1)

Thread 4:
0   libsystem_pthread.dylib       	0x000000020f859b74 start_wqthread + 0 (:-1)

Thread 5:
0   libsystem_pthread.dylib       	0x000000020f859b74 start_wqthread + 0 (:-1)

Thread 6 name:
Thread 6:
0   libsystem_kernel.dylib        	0x00000001ee9deca4 mach_msg2_trap + 8 (:-1)
1   libsystem_kernel.dylib        	0x00000001ee9f1b74 mach_msg2_internal + 80 (mach_msg.c:201)
2   libsystem_kernel.dylib        	0x00000001ee9f1e4c mach_msg_overwrite + 540 (mach_msg.c:0)
3   libsystem_kernel.dylib        	0x00000001ee9df1e8 mach_msg + 24 (mach_msg.c:323)
4   CoreFoundation                	0x00000001afa98024 __CFRunLoopServiceMachPort + 160 (CFRunLoop.c:2622)
5   CoreFoundation                	0x00000001afa99250 __CFRunLoopRun + 1208 (CFRunLoop.c:3005)
6   CoreFoundation                	0x00000001afa9e3ec CFRunLoopRunSpecific + 612 (CFRunLoop.c:3418)
7   Foundation                    	0x00000001a9d12fb4 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212 (NSRunLoop.m:373)
8   Foundation                    	0x00000001a9d12e9c -[NSRunLoop(NSRunLoop) runUntilDate:] + 64 (NSRunLoop.m:420)
9   UIKitCore                     	0x00000001b1f5dcc8 -[UIEventFetcher threadMain] + 416 (UIEventFetcher.m:1376)
10  Foundation                    	0x00000001a9d2c524 __NSThread__start__ + 716 (NSThread.m:963)
11  libsystem_pthread.dylib       	0x000000020f85a6b8 _pthread_start + 148 (pthread.c:893)
12  libsystem_pthread.dylib       	0x000000020f859b88 thread_start + 8 (:-1)

Thread 7 name:
Thread 7:
0   libsystem_kernel.dylib        	0x00000001ee9df7dc __ulock_wait + 8 (:-1)
1   libdispatch.dylib             	0x00000001b6ef089c _dlock_wait + 56 (lock.c:326)
2   libdispatch.dylib             	0x00000001b6ef0650 _dispatch_thread_event_wait_slow + 56 (lock.c:558)
3   libdispatch.dylib             	0x00000001b6eff714 __DISPATCH_WAIT_FOR_QUEUE__ + 368 (queue.c:1683)
4   libdispatch.dylib             	0x00000001b6eff2c0 _dispatch_sync_f_slow + 148 (queue.c:1769)
5   libsystem_trace.dylib         	0x00000001c6c500a8 ___os_state_request_for_self_block_invoke + 372 (state.c:313)
6   libdispatch.dylib             	0x00000001b6eee320 _dispatch_call_block_and_release + 32 (init.c:1518)
7   libdispatch.dylib             	0x00000001b6eefeac _dispatch_client_callout + 20 (object.m:560)
8   libdispatch.dylib             	0x00000001b6ef7534 _dispatch_lane_serial_drain + 668 (queue.c:3885)
9   libdispatch.dylib             	0x00000001b6ef80d8 _dispatch_lane_invoke + 436 (queue.c:3976)
10  libdispatch.dylib             	0x00000001b6f02cdc _dispatch_workloop_worker_thread + 648 (queue.c:6507)
11  libsystem_pthread.dylib       	0x000000020f859ddc _pthread_wqthread + 288 (pthread.c:2618)
12  libsystem_pthread.dylib       	0x000000020f859b7c start_wqthread + 8 (:-1)

Thread 8:
0   libsystem_pthread.dylib       	0x000000020f859b74 start_wqthread + 0 (:-1)

Thread 9 name:
Thread 9:
0   libobjc.A.dylib               	0x00000001a8aaaedc objc_retainAutoreleasedReturnValue + 136 (NSObject.mm:2262)
1   XxxYyyyyyZzz                  	0x0000000100eba454 __32-[APMIdentity updateIdentifiers]_block_invoke + 196
2   libdispatch.dylib             	0x00000001b6eee320 _dispatch_call_block_and_release + 32 (init.c:1518)
3   libdispatch.dylib             	0x00000001b6eefeac _dispatch_client_callout + 20 (object.m:560)
4   libdispatch.dylib             	0x00000001b6ef7534 _dispatch_lane_serial_drain + 668 (queue.c:3885)
5   libdispatch.dylib             	0x00000001b6ef80a4 _dispatch_lane_invoke + 384 (queue.c:3976)
6   libdispatch.dylib             	0x00000001b6f02cdc _dispatch_workloop_worker_thread + 648 (queue.c:6507)
7   libsystem_pthread.dylib       	0x000000020f859ddc _pthread_wqthread + 288 (pthread.c:2618)
8   libsystem_pthread.dylib       	0x000000020f859b7c start_wqthread + 8 (:-1)

Thread 10 name:
Thread 10:
0   libsystem_kernel.dylib        	0x00000001ee9deca4 mach_msg2_trap + 8 (:-1)
1   libsystem_kernel.dylib        	0x00000001ee9f1b74 mach_msg2_internal + 80 (mach_msg.c:201)
2   libsystem_kernel.dylib        	0x00000001ee9f1e4c mach_msg_overwrite + 540 (mach_msg.c:0)
3   libsystem_kernel.dylib        	0x00000001ee9df1e8 mach_msg + 24 (mach_msg.c:323)
4   FirebaseCrashlytics           	0x000000010124acd4 FIRCLSMachExceptionReadMessage + 60 (FIRCLSMachException.c:192)
5   FirebaseCrashlytics           	0x000000010124acd4 FIRCLSMachExceptionServer + 108 (FIRCLSMachException.c:168)
6   libsystem_pthread.dylib       	0x000000020f85a6b8 _pthread_start + 148 (pthread.c:893)
7   libsystem_pthread.dylib       	0x000000020f859b88 thread_start + 8 (:-1)

Thread 11:
0   libsystem_pthread.dylib       	0x000000020f859b74 start_wqthread + 0 (:-1)


Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x0000000000000000   x1: 0x0000000000000000   x2: 0x0000000000000000   x3: 0x0000000000000000
    x4: 0x0000000000000000   x5: 0x0000000000989680   x6: 0x000000000000006e   x7: 0x0000000000000700
    x8: 0xc0da63ef9e85c442   x9: 0xc0da63ed98b90d02  x10: 0x00000000000003e8  x11: 0x000000000000000b
   x12: 0x000000000000000b  x13: 0x00000000001ff800  x14: 0x00000000000007fb  x15: 0x00000000a900b012
   x16: 0x0000000000000148  x17: 0x00000002063cc940  x18: 0x0000000000000000  x19: 0x0000000000000006
   x20: 0x0000000000000103  x21: 0x00000002063cca20  x22: 0x0000000000000007  x23: 0x0000000101267701
   x24: 0x0000000000000000  x25: 0x0000000000000001  x26: 0x0000000000000001  x27: 0x0000000000000000
   x28: 0x00000001d1b386c0   fp: 0x000000016f14f3f0   lr: 0x000000020f860118
    sp: 0x000000016f14f3d0   pc: 0x00000001ee9e5578 cpsr: 0x40001000
   esr: 0x56000080  Address size fault


Binary Images:
        0x100cb0000 -         0x100ffffff XxxYyyyyyZzz arm64  <56e8b0740be232df91fd8a9f0a65540b> /private/var/containers/Bundle/Application/62F17CD5-0791-4527-88BC-3F4B2CD1C3F6/XxxYyyyyyZzz.app/XxxYyyyyyZzz
        0x101198000 -         0x1011a7fff FBLPromises arm64   /private/var/containers/Bundle/Application/62F17CD5-0791-4527-88BC-3F4B2CD1C3F6/XxxYyyyyyZzz.app/Frameworks/FBLPromises.framework/FBLPromises
        0x1011c8000 -         0x1011d3fff FirebaseABTesting arm64  <22b814b35ce1300cb7924bcb0257525f> /private/var/containers/Bundle/Application/62F17CD5-0791-4527-88BC-3F4B2CD1C3F6/XxxYyyyyyZzz.app/Frameworks/FirebaseABTesting.framework/FirebaseABTesting
        0x1011e8000 -         0x1011f7fff FirebaseCore arm64  <27c0924879b9372896407106b7661dfe> /private/var/containers/Bundle/Application/62F17CD5-0791-4527-88BC-3F4B2CD1C3F6/XxxYyyyyyZzz.app/Frameworks/FirebaseCore.framework/FirebaseCore
        0x10121c000 -         0x101223fff FirebaseCoreDiagnostics arm64  <940bdf1bfd6036d9af781d0875611e2a> /private/var/containers/Bundle/Application/62F17CD5-0791-4527-88BC-3F4B2CD1C3F6/XxxYyyyyyZzz.app/Frameworks/FirebaseCoreDiagnostics.framework/FirebaseCoreDiagnostics
        0x101234000 -         0x101273fff FirebaseCrashlytics arm64  <079843ad6d4834adaeb79557253e958d> /private/var/containers/Bundle/Application/62F17CD5-0791-4527-88BC-3F4B2CD1C3F6/XxxYyyyyyZzz.app/Frameworks/FirebaseCrashlytics.framework/FirebaseCrashlytics
        0x1012f0000 -         0x101307fff FirebaseInstallations arm64  <3b48221eb8ef3e02ac381566a7a2163e> /private/var/containers/Bundle/Application/62F17CD5-0791-4527-88BC-3F4B2CD1C3F6/XxxYyyyyyZzz.app/Frameworks/FirebaseInstallations.framework/FirebaseInstallations
        0x10133c000 -         0x10134bfff GoogleToolboxForMac arm64  <7343759df29f3b379321d7773f0f6d88> /private/var/containers/Bundle/Application/62F17CD5-0791-4527-88BC-3F4B2CD1C3F6/XxxYyyyyyZzz.app/Frameworks/GoogleToolboxForMac.framework/GoogleToolboxForMac
        0x10140c000 -         0x10142bfff FirebaseRemoteConfig arm64   /private/var/containers/Bundle/Application/62F17CD5-0791-4527-88BC-3F4B2CD1C3F6/XxxYyyyyyZzz.app/Frameworks/FirebaseRemoteConfig.framework/FirebaseRemoteConfig
        0x101460000 -         0x10147ffff GoogleDataTransport arm64  <290bf8156c603885a987424119ab4c30> /private/var/containers/Bundle/Application/62F17CD5-0791-4527-88BC-3F4B2CD1C3F6/XxxYyyyyyZzz.app/Frameworks/GoogleDataTransport.framework/GoogleDataTransport
        0x1014bc000 -         0x1014d7fff GoogleUtilities arm64   /private/var/containers/Bundle/Application/62F17CD5-0791-4527-88BC-3F4B2CD1C3F6/XxxYyyyyyZzz.app/Frameworks/GoogleUtilities.framework/GoogleUtilities
        0x10150c000 -         0x1015a3fff Lottie arm64  <0ab516b8c66439579884e8b2c7b2d1ef> /private/var/containers/Bundle/Application/62F17CD5-0791-4527-88BC-3F4B2CD1C3F6/XxxYyyyyyZzz.app/Frameworks/Lottie.framework/Lottie
        0x101778000 -         0x101787fff MBProgressHUD arm64  <76404a377d913266851ae6dd498583a2> /private/var/containers/Bundle/Application/62F17CD5-0791-4527-88BC-3F4B2CD1C3F6/XxxYyyyyyZzz.app/Frameworks/MBProgressHUD.framework/MBProgressHUD
        0x1017a4000 -         0x1017affff OrderedDictionary arm64  <351d0be87f713d55898810f07fb11fe9> /private/var/containers/Bundle/Application/62F17CD5-0791-4527-88BC-3F4B2CD1C3F6/XxxYyyyyyZzz.app/Frameworks/OrderedDictionary.framework/OrderedDictionary
        0x1017c4000 -         0x1017cbfff Reachability arm64  <2b67fb47ef10384b8d75b27409dd830c> /private/var/containers/Bundle/Application/62F17CD5-0791-4527-88BC-3F4B2CD1C3F6/XxxYyyyyyZzz.app/Frameworks/Reachability.framework/Reachability
        0x1017dc000 -         0x101803fff TrustKit arm64  <370fc832c9fa3d2d9c64a88eb5b740f7> /private/var/containers/Bundle/Application/62F17CD5-0791-4527-88BC-3F4B2CD1C3F6/XxxYyyyyyZzz.app/Frameworks/TrustKit.framework/TrustKit
        0x10182c000 -         0x101833fff nanopb arm64  <4c9dd759e86e37b18eeb1d645615bf09> /private/var/containers/Bundle/Application/62F17CD5-0791-4527-88BC-3F4B2CD1C3F6/XxxYyyyyyZzz.app/Frameworks/nanopb.framework/nanopb
        0x101840000 -         0x10187ffff Services arm64   /private/var/containers/Bundle/Application/62F17CD5-0791-4527-88BC-3F4B2CD1C3F6/XxxYyyyyyZzz.app/Frameworks/Services.framework/Services
        0x1018b4000 -         0x1018c7fff Logging arm64  <69d81dde266f38dcae332043c4a21b49> /private/var/containers/Bundle/Application/62F17CD5-0791-4527-88BC-3F4B2CD1C3F6/XxxYyyyyyZzz.app/Frameworks/Logging.framework/Logging
        0x1018dc000 -         0x101937fff Cccccc arm64  <8a26dfee26cb3119ab2c09a50eb46454> /private/var/containers/Bundle/Application/62F17CD5-0791-4527-88BC-3F4B2CD1C3F6/XxxYyyyyyZzz.app/Frameworks/Cccccc.framework/Cccccc
        0x101978000 -         0x10197ffff Localized arm64   /private/var/containers/Bundle/Application/62F17CD5-0791-4527-88BC-3F4B2CD1C3F6/XxxYyyyyyZzz.app/Frameworks/Localized.framework/Localized
        0x101990000 -         0x1019a3fff Utility arm64  <43c437e69ce03cdba9d33a839e472552> /private/var/containers/Bundle/Application/62F17CD5-0791-4527-88BC-3F4B2CD1C3F6/XxxYyyyyyZzz.app/Frameworks/Utility.framework/Utility
        0x1019bc000 -         0x1019f7fff Models arm64   /private/var/containers/Bundle/Application/62F17CD5-0791-4527-88BC-3F4B2CD1C3F6/XxxYyyyyyZzz.app/Frameworks/Models.framework/Models
        0x101a30000 -         0x101a53fff Analytics arm64   /private/var/containers/Bundle/Application/62F17CD5-0791-4527-88BC-3F4B2CD1C3F6/XxxYyyyyyZzz.app/Frameworks/Analytics.framework/Analytics
        0x10382c000 -         0x103837fff libobjc-trampolines.dylib arm64e  <7e77fc541c3331c086e81fb7bf12836c> /private/preboot/Cryptexes/OS/usr/lib/libobjc-trampolines.dylib
        0x1a8aa4000 -         0x1a8ae7f9f libobjc.A.dylib arm64e   /usr/lib/libobjc.A.dylib
        0x1a9cd1000 -         0x1aa5aefff Foundation arm64e  <1715de5d08933af0b0c0550bb14f91ec> /System/Library/Frameworks/Foundation.framework/Foundation
        0x1afa1f000 -         0x1afe06fff CoreFoundation arm64e   /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
        0x1b1a8e000 -         0x1b32b2fff UIKitCore arm64e  <7d57a1d1856f338d97db880c4ec8b02e> /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore
        0x1b6eec000 -         0x1b6f32fff libdispatch.dylib arm64e  <5d16936b4e4c3276ba7a69c9bc760aba> /usr/lib/system/libdispatch.dylib
        0x1b6f33000 -         0x1b6fb0ff3 libsystem_c.dylib arm64e  <073251d1d4c937748cee75210751a5d8> /usr/lib/system/libsystem_c.dylib
        0x1c6c46000 -         0x1c6c60fff libsystem_trace.dylib arm64e  <5db7e298f0e33a1088723ab0fb861240> /usr/lib/system/libsystem_trace.dylib
        0x1cefbb000 -         0x1cf040a53 dyld arm64e   /usr/lib/dyld
        0x1eafb3000 -         0x1eafbbfff GraphicsServices arm64e   /System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices
        0x1ee9de000 -         0x1eea15fe7 libsystem_kernel.dylib arm64e  <681b06a07f6b3fa3a2ce063dc1da7b1b> /usr/lib/system/libsystem_kernel.dylib
        0x20f78d000 -         0x20f7a4fff libc++abi.dylib arm64e  <1e834588aca6327a9a965aa8b13a2ae2> /usr/lib/libc++abi.dylib
        0x20f859000 -         0x20f864ff3 libsystem_pthread.dylib arm64e   /usr/lib/system/libsystem_pthread.dylib

EOF

Whenever we present one of these view controllers, things work just fine. When we try to present another one though, if someone is aggressively changing the phone orientation, the app crashes. This crash occurs somewhere in between dismissing the old VC and presenting the new one. It occurs before I ever hit any breakpoints in the "present" animator for the second view controller.

I've narrowed things down a bit, and by commenting out our implementation of adaptivePresentationStyle(for:traitCollection:), the crash can't be reproduced anymore. The downside there being that the app no longer functions how we want it to. Our definition of that function (which causes crashes) looks like this:

public func adaptivePresentationStyle(for controller: UIPresentationController, traitCollection: UITraitCollection) -> UIModalPresentationStyle {
        guard forceUsingFullScreenIfCompact else {
            return .none
        }

        return traitCollection.verticalSizeClass == .compact ? .overFullScreen : .none
    }

A bit more testing, and it seems like if that function returns the same thing consistently, nothing crashes. Are we not allowed to put conditional logic in this function?

In the crash, we can see that it occurs due to a failing assertion internal to UIPresentationController:

Last Exception Backtrace:
0   CoreFoundation                	0x1afa28cb4 __exceptionPreprocess + 164 (NSException.m:202)
1   libobjc.A.dylib               	0x1a8abc3d0 objc_exception_throw + 60 (objc-exception.mm:356)
2   Foundation                    	0x1aa1b2688 -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 172 (NSException.m:251)
3   UIKitCore                     	0x1b1d05610 __80-[UIPresentationController _initViewHierarchyForPresentationSuperview:inWindow:]_block_invoke + 2588 (UIPresentationController.m:1594)
4   UIKitCore                     	0x1b21f1ff4 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke_3 + 300 (UIPresentationController.m:1228)

The question

This all leads us to wonder if we're doing something wrong, or if there could be a bug in one of the iOS APIs that we're consuming. Thus, posting here. Does anyone have any insight into how this could be occurring, or has seen this before and has ideas? Thanks!

Miscellaneous info

  • We target iOS 14+
  • We've seen this issue in debug and release builds from Xcode 14 and 15
  • We see the issue on users with iOS 15+, though it could be occurring on 14 in just incredibly low numbers
  • This is a re-post of https://developer.apple.com/forums/thread/738257, because I accidentally closed that out as resolved

Hey @bfreib any updates on that? I've got the same issue but can't figure out the reason

I'm running into the same issue, as well. In my situation I've noticed that the issue (for our circumstances at least) is not reproducible on iPhone 15 Pro running iOS 17+. Our QA was running an iPhone X on 16.?.? (still trying to get that info from them) at the time he found this bug.

Our main Home View can be run in landscape or portrait. We have another View that is used elsewhere in the app. This view is forced into portrait, because it is nearly useless as a landscape View.

In our situation we started showing that secondary view as a sheet over the Home View. When the user is in landscape orientation on the Home View, and taps the button to open this secondary View as a sheet, that is when the crash occurs. Removing the code to force the secondary View into portrait orientation does prevent the bug from occurring (Though not ideally how we'd want to go about things from a UI standpoint).

While I don't think this information will help OP, I figure I'd tack on to this thread in case it ended up helping anyone.

Can you please file a feedback report (https://feedbackassistant.apple.com) with a reproducible testcase that you can attach (even if it only reproduces rarely)? That would help us investigate this issue.

Same issue, marked.

Changing presentation style crashes app
 
 
Q