From c33fce49537ed1082886c193acfacf560ecb2626 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Wed, 25 Mar 2020 09:03:20 -0400 Subject: Ensure that session is kept alive till completion. --- platform/darwin/src/http_file_source.mm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platform/darwin/src/http_file_source.mm b/platform/darwin/src/http_file_source.mm index 5c4a9c1b82..1b5a67ea5d 100644 --- a/platform/darwin/src/http_file_source.mm +++ b/platform/darwin/src/http_file_source.mm @@ -250,7 +250,7 @@ std::unique_ptr HTTPFileSource::request(const Resource& resource, [MGLNativeNetworkManager.sharedManager startDownloadEvent:url.relativePath type:@"tile"]; } - NSURLSession *session; + __block NSURLSession *session; // Use the delegate's session if there is one, otherwise use the one that // was created when this class was constructed. @@ -268,6 +268,8 @@ std::unique_ptr HTTPFileSource::request(const Resource& resource, request->task = [session dataTaskWithRequest:req completionHandler:^(NSData* data, NSURLResponse* res, NSError* error) { + session = nil; + if (error && [error code] == NSURLErrorCancelled) { [MGLNativeNetworkManager.sharedManager cancelDownloadEventForResponse:res]; return; -- cgit v1.2.1