1

In my application, I attempt to login with Face ID using evaluatePolicy, and after 1 or 2 logins, I get an error in the callback. In that error, I call an async completion handler which calls another and eventually it calls canEvaluatePolicy. My app then freezes, allowing no further interaction with the UI. Why would this be happening? Does it have something to do with thread-safety? Some sample code that recreates this issue, can be found here

Here is a code snippet from that sample code for reference:

    let localAuthenticationContext = LAContext()
    if localAuthenticationContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: nil) {

        localAuthenticationContext.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: "To access secure data") { success, evaluateError in

            if success {
                print("Success")
            } else {
                print("Face ID Error")
                let context = LAContext()
                let status = context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: nil)
                print("Status: \(status)")
            }
        }
    }

I've been using Xcode 9.1 Beta 2 with the iPhone X simulator.

tfrank377
  • 1,858
  • 2
  • 22
  • 34
  • 3
    The documentation very clearly says not to do what you're doing, and why. And it tells you that what is happening is exactly what will happen. – jscs Oct 27 '17 at 20:38
  • Makes perfect sense. I guess I need a workaround to use `canEvaluatePolicy` after a failed login, in order to setup my UI properly. Since the docs also say not to save the value for `canEvaluatePolicy`. – tfrank377 Oct 28 '17 at 05:12
  • Weirdly, my code doesn't and never did have problems with devices that support Touch ID. Just iPhone X at the moment. – tfrank377 Oct 28 '17 at 05:13
  • Yeah, I can only get the deadlock to occur if the error from `evaluatePolicy` is ["Lost connection to coreauthd."](https://openradar.appspot.com/radar?id=6086985273835520) – Adam Johns Oct 29 '17 at 22:05

0 Answers0