[UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone on iPad???

Hi,

in an App I maintain we have a huge crash count at launch on the iPad. While I can't reproduce it, looking at the stack trace it seems

[UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone

evaluates to true under some conditions on iPadOS 15. (the crash occurs in an UIViewController that is allocated only on the iPhone in one code location)

Is there anything that can cause [UIDevice currentDevice] to return nil, e.g. blocking the main thread?

Thanks!

Could you show the code where it occurs ? What are those "special conditions" ?

.

Is there anything that can cause [UIDevice currentDevice] to return nil, e.g. blocking the main thread?

If .userInterfaceIdiom == UIUserInterfaceIdiomPhone, it is not nil ?

Same crash on widget

Hardware Model: iPhone13,3

OS Version: iPhone OS 17.3 (21D50)

Exception Type: EXC_CRASH (SIGABRT)

Termination Reason: OBJC 1

call stack:

0 libsystem_kernel.dylib 0x00000001fc0c9bf8 __ulock_wait + 8 (:-1)

1 libdispatch.dylib 0x00000001bc962cf0 _dlock_wait + 56 (lock.c:326)

2 libdispatch.dylib 0x00000001bc962c20 _dispatch_once_wait + 112 (lock.c:679)

3 UIKitCore 0x00000001b6d7fb04 -[_UIApplicationConfigurationLoader _loadInitializationContext] + 164 (_UIApplicationConfigurationLoader.m:107)

4 UIKitCore 0x00000001b6d26f00 -[_UIApplicationConfigurationLoader applicationInitializationContext] + 24 (_UIApplicationConfigurationLoader.m:169)

5 UIKitCore 0x00000001b6dca77c -[_UIDeviceInitialDeviceConfigurationLoader initialDeviceContext] + 92 (_UIDeviceInitialDeviceConfigurationLoader.m:70)

6 UIKitCore 0x00000001b6e91c90 ___UIDeviceNativeUserInterfaceIdiom_block_invoke + 60 (UIDevice.m:752)

7 libdispatch.dylib 0x00000001bc962300 _dispatch_client_callout + 20 (object.m:561)

8 libdispatch.dylib 0x00000001bc963b3c _dispatch_once_callout + 32 (once.c:52)

9 UIKitCore 0x00000001b75c299c __initializeActiveUserInterfaceIdiom_block_invoke + 72 (UIDevice.m:1220)

10 libdispatch.dylib 0x00000001bc962300 _dispatch_client_callout + 20 (object.m:561)

11 libdispatch.dylib 0x00000001bc963b3c _dispatch_once_callout + 32 (once.c:52)

12 UIKitCore 0x00000001b6c1b150 -[UIDevice userInterfaceIdiom] + 64 (UIDevice.m:1232)

[UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone on iPad???
 
 
Q