Family Controls crash when app launching

Hey 👋 I have an app that uses Device Activity Monitor. For the previous releases there was no problem. However I made some improvements in my app and send it to review. Review team getting following crash log but I couldn't find the issue. It's working both in my simulator and a real devices.(iPhone, iPad). I removed some logs from here because of character limitations.

Exception Codes: 0x0000000000000000, 0x0000000000000000
Termination Reason: FRONTBOARD 2343432205 
<RBSTerminateContext| domain:10 code:0x8BADF00D explanation:scene-create watchdog transgression: application<>:15592 exhausted real (wall clock) time allowance of 19.97 seconds
ProcessVisibility: Foreground
ProcessState: Running
WatchdogEvent: scene-create
WatchdogVisibility: Foreground
WatchdogCPUStatistics: (
"Elapsed total CPU time (seconds): 7.760 (user 4.070, system 3.690), 5% CPU",
"Elapsed application CPU time (seconds): 0.111, 0% CPU"
) reportType:CrashLog maxTerminationResistance:Interactive>

Triggered by Thread:  0

Thread 0 name:   Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libsystem_kernel.dylib        	       0x1d8256ca4 mach_msg2_trap + 8
1   libsystem_kernel.dylib        	       0x1d8269b74 mach_msg2_internal + 80
2   libsystem_kernel.dylib        	       0x1d8269e4c mach_msg_overwrite + 540
3   libsystem_kernel.dylib        	       0x1d82571e8 mach_msg + 24
4   libdispatch.dylib             	       0x1a108320c _dispatch_mach_send_and_wait_for_reply + 548
5   libdispatch.dylib             	       0x1a108359c dispatch_mach_send_with_result_and_wait_for_reply + 60
6   libxpc.dylib                  	       0x1f8fa9218 xpc_connection_send_message_with_reply_sync + 240
7   Foundation                    	       0x193f6ff18 __NSXPCCONNECTION_IS_WAITING_FOR_A_SYNCHRONOUS_REPLY__ + 16
8   Foundation                    	       0x193f032c4 -[NSXPCConnection _sendInvocation:orArguments:count:methodSignature:selector:withProxy:] + 2192
9   Foundation                    	       0x193f01ac0 -[NSXPCConnection _sendSelector:withProxy:arg1:] + 116
10  Foundation                    	       0x193f019f8 _NSXPCDistantObjectSimpleMessageSend1 + 60
11  FamilyControls                	       0x1e772388c 0x1e76ee000 + 219276
12  FamilyControls                	       0x1e7722b0c 0x1e76ee000 + 215820
13  libdispatch.dylib             	       0x1a1067eac _dispatch_client_callout + 20
14  libdispatch.dylib             	       0x1a10696ec _dispatch_once_callout + 32
15  FamilyControls                	       0x1e7722d18 0x1e76ee000 + 216344
16  MyApp                      	           0x102314bfc AppUsagesViewModel.init(dependencies:) + 510972 (AppUsagesViewModel.swift:29)
17  MyApp                      	           0x1022b2b00 closure #1 in MainTabBarController.setupTabbar() + 109312 (MainTabBarController.swift:55)
18  MyApp                      	           0x1022b3904 specialized Sequence.compactMap<A>(_:) + 112900 (<compiler-generated>:0)
19  MyApp                      	           0x1022b2750 MainTabBarController.setupTabbar() + 108368 (MainTabBarController.swift:47)
20  MyApp                      	           0x1022b29a8 @objc MainTabBarController.viewDidLoad() + 108968 (<compiler-generated>:0)
21  UIKitCore                     	       0x19bf381f4 -[UITabBarController initWithNibName:bundle:] + 156
22  MyApp                      	           0x1022b3a7c specialized static MainTabBarController.build(_:) + 113276 (MainTabBarController.swift:96)
23  MyApp                      	           0x102313f80 specialized AppDelegate.application(_:didFinishLaunchingWithOptions:) + 507776 (AppDelegate.swift:45)
24  MyApp                      	           0x1023132d8 @objc AppDelegate.application(_:didFinishLaunchingWithOptions:) + 504536 (<compiler-generated>:17)

As far as I understood from the log the crash is happened right there AppUsagesViewModel.swift:29. I have a following variable in that line. private let parentalControls = AuthorizationCenter.shared

What could be the reason of that crash? If someone can help me I really appreciate it. Thanks!

Hey ! Accessing AuthorizationCenter.shared is sometime hangging, blocking the thread on wish it was called. We've opened a bug report for this (FB11833456), and would be super nice if you could do the same, so this issue has more chance to be fixed !

The crash is not really a crash, since you do the call on the main thread at your app start, it's delaying your appLaunch. IOS has a mechanism called the Watchdog that kills app that take too long to launch, this is what's happening in your case.

Seeing the same issue and will file a bug report too!

@atalayasa Try to move your access to AuthorizationCenter.shared outside the main thread. That shouldn't be too problematic apart from from manipulating authorizationstatus which, according to the documentation, should only be accessed on the main thread.

Thank you very much for your response I solved issue as you described.

Hi @_lilpit @thomas_maht @atalayasa! How did you all resolve this? I've been trying to move let center = AuthorizationCenter.shared outside the main thread for a while now but still haven't seem to get it to work. Any tips would be much appreciated!!!

Family Controls crash when app launching
 
 
Q