snapauthapp / sdk-swift

Swift SDK for SnapAuth (all Apple platforms)
https://www.snapauth.app
BSD 3-Clause "New" or "Revised" License
1 stars 0 forks source link

Data race: transition from autofill to modal authn #25

Closed Firehed closed 2 months ago

Firehed commented 2 months ago

If you've started an autofill authn request and then subsequently start a modal authn request, it's possible for the internal state (used by the response processing system) to desync, and causing an assertion failure.

I suspect this is from ASAuthorizationController performing some sort of internal cancellation process that (now?) runs and triggers the sendError that resets the state to .idle after the second, user-initiated request.

Might be specific to building when targeting iOS 18, as I didn't run into this targeting iOS 17 (and generational equivalents) on XCode 15.

FWIW, I had an attempt to adopt Swift 6 semantics around data race safety (a goal regardless) and the it-at-least-compiles version still had the issue. I think there's some additional subtlety around delegate methods that will need work.

Idea: do more with the controller passed in to the delegate methods, so that controller:didCompleteWithError: calls can be situationally ignored?