Potentially misleading NSLocalizedRecoverySuggestion for AR Failure "Required sensor failed."

Number:rdar://36929611 Date Originated:1/26/2018
Status:Open Resolved:
Product:iOS + SDK Product Version:ARKit
Classification:Suggestion Reproducible:
I'd seen this error in analytics logs before, but never myself. However, it popped up today after starting an ARKit app immediately after powering up an iPhone X.

Here's the code that displays the alert:

let title = NSLocalizedString("AR Failure", comment:"Augmented Reality failure")
        messageManager.show(message: title)
        arStateImageView.image = #imageLiteral(resourceName: "ar-unavailable")
        let nse = error as NSError
        let failureReason = nse.userInfo[NSLocalizedFailureReasonErrorKey] as? String  ?? ""
        let recoverySuggestion = nse.userInfo[NSLocalizedRecoverySuggestionErrorKey] as? String ?? ""
        let message = String(format:"%@\n\n%@\n%@", error.localizedDescription, failureReason, recoverySuggestion)
        let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
        switch nse.code {
        case ARError.Code.cameraUnauthorized.rawValue:
            // Redirect user to settings to fix things
            alert.addAction(UIAlertAction(title: NSLocalizedString("Settings", comment: ""), style: .cancel, handler: { (action:UIAlertAction) in
                UIApplication.shared.open(URL(string:"App-Prefs:root")!, options: [:], completionHandler: nil)
        alert.addAction(UIAlertAction(title: NSLocalizedString("OK", comment: ""), style: .default, handler: nil))
        self.present(alert, animated: true, completion: nil)

The recoverySuggestion text displayed was "Make sure that the application has the required privacy settings."

In this case, the error was unrelated to privacy settings - I retried to start the AR sessions a couple of seconds later and all was fine. I suspect it was related to the timing of starting a session immediately after a cold start on the device.

Suggestion: revise the recovery suggestion text to suggest waiting and retrying.


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!