My apps could slow down in iOS 11, iPhone 6 plus. (Other iOS run as expected.)
I know SecTrustEvaluate() method is a reason that make the app slow down. I run its in main thread takes about 3 seconds. So i use gcd to move its to background thread.
- (void)URLSession:(NSURLSession *)session didReceiveChallenge(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential * _Nullable credential))completionHandler {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
BOOL allowConnect = //Server Trust Evaluation in here
dispatch_async( dispatch_get_main_queue(), ^{
if (allowConnect) {
//completionHandler;
} else {
//cancel
}
});
});
}
}
Then it do not block UI, but take 20 seconds for server trust validation.
Can someone know this issue? Please help me. Thanks.