brunshte
brunshte

Reputation: 321

Main Thread Checker: UI API called on a background thread: -[UIImagePickerController didDisplayPhotoPickerSourceType:]

Upon clicking on the navigationItem which opens a UIImagePickerController, I get the below log in the debugger, and cannot find any documentation that speaks about didDisplayPhotoPickerSourceType. Note I am presenting the picker from the main thread and still getting this main thread issue.

partial code:

 ...
 override func viewDidLoad() {
    super.viewDidLoad()
    collectionView.backgroundColor = .blue
    register()
    setUp()
    collectionView.reloadData()
}

private func setUp() {
    navigationController?.isNavigationBarHidden = false
    let layout = collectionView.collectionViewLayout as! UICollectionViewFlowLayout
    layout.minimumInteritemSpacing = 2
    layout.minimumLineSpacing = 2
    collectionView.collectionViewLayout = layout
    
    navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(addNewPerson))
}

@objc private func addNewPerson() {
    DispatchQueue.main.async { [weak self] in
        let picker = UIImagePickerController()
        picker.allowsEditing = true
        picker.delegate = self
        self?.present(picker, animated: false)
    }
}
...

Debugger Log:

Main Thread Checker: UI API called on a background thread: -[UIImagePickerController didDisplayPhotoPickerSourceType:]
PID: 85527, TID: 2803975, Thread name: (none), Queue name: com.apple.NSXPCConnection.user.anonymous.85796, QoS: 0
Backtrace:
4   PhotosUI                            0x00000001ad0380c8 -[PUPhotoPickerExtensionHostContext didDisplayPhotoPickerSourceType:] + 96
5   Foundation                          0x0000000180fb6c10 __NSXPCCONNECTION_IS_CALLING_OUT_TO_EXPORTED_OBJECT_S1__ + 12
6   Foundation                          0x0000000180fb59e0 -[NSXPCConnection _decodeAndInvokeMessageWithEvent:reply:flags:] + 1664
7   Foundation                          0x0000000180fb79ec message_handler_message + 84
8   Foundation                          0x0000000180fb6f80 message_handler + 148
9   libxpc.dylib                        0x00000001800cca0c _xpc_connection_call_event_handler + 68
10  libxpc.dylib                        0x00000001800ce10c _xpc_connection_mach_event + 1048
11  libdispatch.dylib                   0x0000000105b3f904 _dispatch_client_callout4 + 12
12  libdispatch.dylib                   0x0000000105b42a90 _dispatch_mach_msg_invoke + 672
13  libdispatch.dylib                   0x0000000105b2d75c _dispatch_lane_serial_drain + 324
14  libdispatch.dylib                   0x0000000105b43d50 _dispatch_mach_invoke + 504
15  libdispatch.dylib                   0x0000000105b2d75c _dispatch_lane_serial_drain + 324
16  libdispatch.dylib                   0x0000000105b2e708 _dispatch_lane_invoke + 420
17  libdispatch.dylib                   0x0000000105b3b3ac _dispatch_root_queue_drain_deferred_wlh + 324
18  libdispatch.dylib                   0x0000000105b3a918 _dispatch_workloop_worker_thread + 732
19  libsystem_pthread.dylib             0x0000000247927b74 _pthread_wqthread + 284
20  libsystem_pthread.dylib             0x0000000247926934 start_wqthread + 8
Main Thread Checker: UI API called on a background thread: -[UIImagePickerController didDisplayPhotoPickerSourceType:]
PID: 85527, TID: 2803975, Thread name: (none), Queue name: com.apple.NSXPCConnection.user.anonymous.85796, QoS: 0
Backtrace:
4   PhotosUI                            0x00000001ad0380c8 -[PUPhotoPickerExtensionHostContext didDisplayPhotoPickerSourceType:] + 96
5   Foundation                          0x0000000180fb6c10 __NSXPCCONNECTION_IS_CALLING_OUT_TO_EXPORTED_OBJECT_S1__ + 12
6   Foundation                          0x0000000180fb59e0 -[NSXPCConnection _decodeAndInvokeMessageWithEvent:reply:flags:] + 1664
7   Foundation                          0x0000000180fb79ec message_handler_message + 84
8   Foundation                          0x0000000180fb6f80 message_handler + 148
9   libxpc.dylib                        0x00000001800cca0c _xpc_connection_call_event_handler + 68
10  libxpc.dylib                        0x00000001800ce10c _xpc_connection_mach_event + 1048
11  libdispatch.dylib                   0x0000000105b3f904 _dispatch_client_callout4 + 12
12  libdispatch.dylib                   0x0000000105b42a90 _dispatch_mach_msg_invoke + 672
13  libdispatch.dylib                   0x0000000105b2d75c _dispatch_lane_serial_drain + 324
14  libdispatch.dylib                   0x0000000105b43d50 _dispatch_mach_invoke + 504
15  libdispatch.dylib                   0x0000000105b2d75c _dispatch_lane_serial_drain + 324
16  libdispatch.dylib                   0x0000000105b2e708 _dispatch_lane_invoke + 420
17  libdispatch.dylib                   0x0000000105b3b3ac _dispatch_root_queue_drain_deferred_wlh + 324
18  libdispatch.dylib                   0x0000000105b3a918 _dispatch_workloop_worker_thread + 732
19  libsystem_pthread.dylib             0x0000000247927b74 _pthread_wqthread + 284
20  libsystem_pthread.dylib             0x0000000247926934 start_wqthread + 8

Upvotes: 1

Views: 33

Answers (0)

Related Questions