1

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.

oolionoo
  • 113
  • 11

1 Answers1

0

I configure out my problem. This does not relate to iOS 11. It's my fault.

I create one NSURLSession for each security download image request on the same host. Because TLS session is computationally expensive so that make my app slow down. My solution is create only one session for all download request. So evaluated server certificate’s result will be cached, and next request(on the same host, port) you don’t need evaluation server trust.

More info: https://developer.apple.com/library/content/qa/qa1727/_index.html

Why is a HTTPS NSURLSession connection only challenged once per domain?

oolionoo
  • 113
  • 11