Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

ios - Xcode AX Lookup problem - Only occurs on real device

This error does not crash the app although is concerning. I have been unable to determine why it is occurring although I have figured out that it occurs only whenever I call present(picker, animated: true) where picker is a UIImagePickerController(). I have added all of the necessary permissions to my info.plist and even created a small test app to reproduce this bug.

It does not occur when using any of the simulators and I have only been able to find one other SO post about an error like this, although that post is also unanswered.

The test app I made consists of a simple storyboard with a button to call the UIImagePickerController()present function and then an imageView to accept that photo.

Here is the code for the ViewController.swift:

import UIKit

class ViewController: UIViewController {
    @IBOutlet var imageView: UIImageView!

    override func viewDidLoad() {
        super.viewDidLoad()
    }
    @IBAction func setPicture(_ sender: Any) {
        let picker = UIImagePickerController()
        if UIImagePickerController.isSourceTypeAvailable(.photoLibrary) {
            picker.delegate = self
            picker.sourceType = .photoLibrary
            picker.allowsEditing = true
            present(picker, animated: true)
        }
}
extension ViewController: UIImagePickerControllerDelegate, UINavigationControllerDelegate {
    func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
        if let image = info[UIImagePickerController.InfoKey.originalImage] as? UIImage {
           imageView.image = image
        }
        picker.dismiss(animated: true, completion: nil)
    }
    func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
        picker.dismiss(animated: true, completion: nil)
    }
}

I will include the full error I am seeing in the console below:

2021-01-21 09:40:00.160241-0500 Outdoorist[2480:608042] [AXRuntimeCommon] Unknown client: Outdoorist
2021-01-21 09:40:07.259911-0500 Outdoorist[2480:608307] [AXRuntimeCommon] AX Lookup problem - errorCode:1100 error:Permission denied portName:'com.apple.iphone.axserver' PID:2483 (
    0   AXRuntime                           0x00000001a3f9eeac 0C4A28F7-3959-3709-8C05-A1A91EED978B + 347820
    1   AXRuntime                           0x00000001a3f4dfb8 _AXGetPortFromCache + 548
    2   AXRuntime                           0x00000001a3f4f610 AXUIElementPerformFencedActionWithValue + 460
    3   UIKit                               0x00000001ce67823c 737C2677-858F-3820-AD45-0EBAABC788BB + 852540
    4   libdispatch.dylib                   0x0000000102e8bce4 _dispatch_call_block_and_release + 24
    5   libdispatch.dylib                   0x0000000102e8d528 _dispatch_client_callout + 16
    6   libdispatch.dylib                   0x0000000102e945ac _dispatch_lane_serial_drain + 748
    7   libdispatch.dylib                   0x0000000102e95234 _dispatch_lane_invoke + 452
    8   libdispatch.dylib                   0x0000000102ea0a5c _dispatch_workloop_worker_thread + 1456
    9   libsystem_pthread.dylib             0x00000001ce3935a4 _pthread_wqthread + 272
    10  libsystem_pthread.dylib             0x00000001ce396874 start_wqthread + 8
)
2021-01-21 09:40:07.260672-0500 Outdoorist[2480:608307] [AXRuntimeCommon] AX Lookup problem - errorCode:1100 error:Permission denied portName:'com.apple.iphone.axserver' PID:2483 (
    0   AXRuntime                           0x00000001a3f9eeac 0C4A28F7-3959-3709-8C05-A1A91EED978B + 347820
    1   AXRuntime                           0x00000001a3f4dfb8 _AXGetPortFromCache + 548
    2   AXRuntime                           0x00000001a3f4f610 AXUIElementPerformFencedActionWithValue + 460
    3   UIKit                               0x00000001ce67823c 737C2677-858F-3820-AD45-0EBAABC788BB + 852540
    4   libdispatch.dylib                   0x0000000102e8bce4 _dispatch_call_block_and_release + 24
    5   libdispatch.dylib                   0x0000000102e8d528 _dispatch_client_callout + 16
    6   libdispatch.dylib                   0x0000000102e945ac _dispatch_lane_serial_drain + 748
    7   libdispatch.dylib                   0x0000000102e95234 _dispatch_lane_invoke + 452
    8   libdispatch.dylib                   0x0000000102ea0a5c _dispatch_workloop_worker_thread + 1456
    9   libsystem_pthread.dylib             0x00000001ce3935a4 _pthread_wqthread + 272
    10  libsystem_pthread.dylib             0x00000001ce396874 start_wqthread + 8
)
2021-01-21 09:40:07.261213-0500 Outdoorist[2480:608307] [AXRuntimeCommon] AX Lookup problem - errorCode:1100 error:Permission denied portName:'com.apple.iphone.axserver' PID:2483 (
    0   AXRuntime                           0x00000001a3f9eeac 0C4A28F7-3959-3709-8C05-A1A91EED978B + 347820
    1   AXRuntime                           0x00000001a3f4dfb8 _AXGetPortFromCache + 548
    2   AXRuntime                           0x00000001a3f4f610 AXUIElementPerformFencedActionWithValue + 460
    3   UIKit                               0x00000001ce67823c 737C2677-858F-3820-AD45-0EBAABC788BB + 852540
    4   libdispatch.dylib                   0x0000000102e8bce4 _dispatch_call_block_and_release + 24
    5   libdispatch.dylib                   0x0000000102e8d528 _dispatch_client_callout + 16
    6   libdispatch.dylib                   0x0000000102e945ac _dispatch_lane_serial_drain + 748
    7   libdispatch.dylib                   0x0000000102e95234 _dispatch_lane_invoke + 452
    8   libdispatch.dylib                   0x0000000102ea0a5c _dispatch_workloop_worker_thread + 1456
    9   libsystem_pthread.dylib             0x00000001ce3935a4 _pthread_wqthread + 272
    10  libsystem_pthread.dylib             0x00000001ce396874 start_wqthread + 8
)

I would greatly appreciate any assistance with solving this problem or how to avoid it.

I am using Xcode Version 12.3 if that is of any relevance.

question from:https://stackoverflow.com/questions/65829998/xcode-ax-lookup-problem-only-occurs-on-real-device

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I think this is related to iOS 14's restricted image picker permission dialog, which opens in a separate thread. So when the callback returns you should perform UI tasks on main thread. Please try below:

    let picker = UIImagePickerController()
    if UIImagePickerController.isSourceTypeAvailable(.photoLibrary) {
        picker.delegate = self
        picker.sourceType = .photoLibrary
        picker.allowsEditing = true
        
        DispatchQueue.main.async {
            self.present(picker, animated: true)
        }
    }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...