Skip to content
This repository has been archived by the owner on Sep 9, 2021. It is now read-only.

Bridge-1684 call becomeFirstResponder with dispatch to main queue aft… #65

Merged

Conversation

syoung-smallwisdom
Copy link
Collaborator

…er delay to prevent invisible keyboard when user hits ‘cancel’ in touch ID context

ResearchKit#915

…er delay to prevent invisible keyboard when user hits ‘cancel’ in touch ID context
@@ -369,7 +369,17 @@ - (void)promptTouchId {
}]];
[strongSelf presentViewController:alert animated:YES completion:nil];
} else if (error.code == LAErrorUserCancel) {
[strongSelf makePasscodeViewBecomeFirstResponder];

// call becomeFirstResponder here to show the keyboard. dispatch to main queue with
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the delay really necessary? From the documentation on evaluatePolicy:localizedReason:reply:, the reply block (i.e. this code) "[...] is evaluated on a private queue internal to the framework in an unspecified threading context", so I would expect odd behavior if you tried to set the first responder from here (UIKit not being thread-safe and all). Does dispatching async to the main queue without a delay not suffice?

ETA: Just noticed it dispatches sync to main at the top of the block--so the question becomes, does dispatching async there fix it? I can't see any reason this needs to happen synchronously from the private queue since we have no idea when that will happen anyway.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joshbruhin What do you think? Thanks!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I did dispatch without delay and it worked. I added a delay only because I thought it might be safer and and it seemed to make for a smoother transition. Based on what you read, it seems it makes no difference from a reliability perspective.

@syoung-smallwisdom syoung-smallwisdom merged commit bd87acc into build/sage-1.4-build-3 Mar 14, 2017
@syoung-smallwisdom syoung-smallwisdom deleted the third-party/joshbruhin/Bridge-1684 branch March 21, 2017 17:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants