Skip to content

Commit c157456

Browse files
authored
Replace ImageCache, DataCache with URLCache (#3930)
1 parent 9602cf0 commit c157456

File tree

47 files changed

+616
-483
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+616
-483
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
### Banners and guidance instructions
2323

2424
* Added replacement for `VisualInstruction.maneuverImageSet(side:)` method to generate a maneuver image on iOS 13 and above. ([#4161](https://github.com/mapbox/mapbox-navigation-ios/pull/4161))
25+
* Road shield images are now cached and re-used across multiple application sessions. ([#3930](https://github.com/mapbox/mapbox-navigation-ios/pull/3930))
26+
* Fixed an issue where the CarPlay style change would affect the style of Mapbox designed shields on mobile. ([#3930](https://github.com/mapbox/mapbox-navigation-ios/pull/3930))
27+
* Fixed an issue where the Mapbox designed shields and generic shields have different sizes in instruction banner. ([#3930](https://github.com/mapbox/mapbox-navigation-ios/pull/3930))
2528

2629
### Other changes
2730

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,10 @@ The .strings files should still be in the original English – that’s expecte
126126

127127
### Supported devices:
128128
- iPhone 11 Pro Max, iOS 13.7
129+
- iPhone 11 Pro Max, iOS 15.0
129130
- iPhone 12 Pro Max, iOS 14.5
130131
- iPhone 13 Pro Max, iOS 15.2
132+
- iPhone 14 Pro Max, iOS 16.0
131133

132134
### Adding a unit test suite
133135

MapboxNavigation.xcodeproj/project.pbxproj

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,9 @@
357357
B426FF0525FFD679001884C8 /* SimulatedLocationManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3597ABCF21553B6F00C12785 /* SimulatedLocationManagerTests.swift */; };
358358
B430D2FA25534FDC0088CC23 /* UserHaloCourseView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B430D2F925534FDC0088CC23 /* UserHaloCourseView.swift */; };
359359
B4319F2F27A35EA8005A706E /* SpriteRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4319F2E27A35EA8005A706E /* SpriteRepository.swift */; };
360+
B432985D28D53A6F005AFB98 /* URLRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = B432985C28D53A6F005AFB98 /* URLRequest.swift */; };
361+
B432985F28D53AB8005AFB98 /* URLSessionDelegateProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = B432985E28D53AB8005AFB98 /* URLSessionDelegateProxy.swift */; };
362+
B432986228D53AF4005AFB98 /* URLDataCacheTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B432986028D53AEB005AFB98 /* URLDataCacheTests.swift */; };
360363
B44177F82649B08400781319 /* UserLocationStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = B44177F72649B08400781319 /* UserLocationStyle.swift */; };
361364
B443A48B27BB0CB8000AF101 /* sprite-info.json in Resources */ = {isa = PBXBuildFile; fileRef = B443A48A27BB0CB8000AF101 /* sprite-info.json */; };
362365
B456A8C12620C9C300FD86D8 /* MMEEventsManager+Spy.h in Headers */ = {isa = PBXBuildFile; fileRef = B456A8B82620C9C000FD86D8 /* MMEEventsManager+Spy.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -406,8 +409,6 @@
406409
B4C4FFA028ADB19600C7C253 /* RouteLineLayerPositionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4C4FF9F28ADB19600C7C253 /* RouteLineLayerPositionTests.swift */; };
407410
B4C8E39E286B72FA004D3EDD /* FeedbackViewControllerSnapshotTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4C8E39D286B72FA004D3EDD /* FeedbackViewControllerSnapshotTests.swift */; };
408411
B4E19C47268114840011581F /* NavigationLocationProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4E19C46268114840011581F /* NavigationLocationProvider.swift */; };
409-
B4E6711F27BB09D6004EE9C1 /* SpriteInfoCacheTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4E6711E27BB09D6004EE9C1 /* SpriteInfoCacheTests.swift */; };
410-
B4E6712227BB0A56004EE9C1 /* SpriteInfoCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4E6712027BB09EF004EE9C1 /* SpriteInfoCache.swift */; };
411412
B4F4FEAD27AB1E11003915A9 /* SpriteRepositoryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4B61B9627A882E200AA127E /* SpriteRepositoryTests.swift */; };
412413
B4FD842827ED1980002662C4 /* UserPuckStyleKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4FD842727ED1980002662C4 /* UserPuckStyleKit.swift */; };
413414
C51511D120EAC89D00372A91 /* CPMapTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C51511D020EAC89D00372A91 /* CPMapTemplate.swift */; };
@@ -972,6 +973,9 @@
972973
B419BFF125F00A9C0086639B /* Feature.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Feature.swift; sourceTree = "<group>"; };
973974
B430D2F925534FDC0088CC23 /* UserHaloCourseView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserHaloCourseView.swift; sourceTree = "<group>"; };
974975
B4319F2E27A35EA8005A706E /* SpriteRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpriteRepository.swift; sourceTree = "<group>"; };
976+
B432985C28D53A6F005AFB98 /* URLRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = URLRequest.swift; sourceTree = "<group>"; };
977+
B432985E28D53AB8005AFB98 /* URLSessionDelegateProxy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = URLSessionDelegateProxy.swift; sourceTree = "<group>"; };
978+
B432986028D53AEB005AFB98 /* URLDataCacheTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = URLDataCacheTests.swift; sourceTree = "<group>"; };
975979
B44177F72649B08400781319 /* UserLocationStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserLocationStyle.swift; sourceTree = "<group>"; };
976980
B443A48A27BB0CB8000AF101 /* sprite-info.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "sprite-info.json"; sourceTree = "<group>"; };
977981
B456A8B72620C9C000FD86D8 /* MMEEventsManager+Spy.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = "MMEEventsManager+Spy.m"; path = "include/MMEEventsManager+Spy.m"; sourceTree = "<group>"; };
@@ -1025,8 +1029,6 @@
10251029
B4C8E39D286B72FA004D3EDD /* FeedbackViewControllerSnapshotTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedbackViewControllerSnapshotTests.swift; sourceTree = "<group>"; };
10261030
B4D4291826260D5900EE92A8 /* MBXInfo.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = MBXInfo.plist; sourceTree = "<group>"; };
10271031
B4E19C46268114840011581F /* NavigationLocationProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NavigationLocationProvider.swift; sourceTree = "<group>"; };
1028-
B4E6711E27BB09D6004EE9C1 /* SpriteInfoCacheTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpriteInfoCacheTests.swift; sourceTree = "<group>"; };
1029-
B4E6712027BB09EF004EE9C1 /* SpriteInfoCache.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpriteInfoCache.swift; sourceTree = "<group>"; };
10301032
B4FD842727ED1980002662C4 /* UserPuckStyleKit.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserPuckStyleKit.swift; sourceTree = "<group>"; };
10311033
C51511D020EAC89D00372A91 /* CPMapTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CPMapTemplate.swift; sourceTree = "<group>"; };
10321034
C51DF8651F38C31C006C6A15 /* Locale.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Locale.swift; sourceTree = "<group>"; };
@@ -1549,7 +1551,6 @@
15491551
8A0E0A6D257AE4B300C2E924 /* Cache */ = {
15501552
isa = PBXGroup;
15511553
children = (
1552-
B4E6712027BB09EF004EE9C1 /* SpriteInfoCache.swift */,
15531554
3EA93A10227A7DAF1861D9F5 /* Cache.swift */,
15541555
160D8278205996DA00D278D6 /* DataCache.swift */,
15551556
3EA938479CF48D7AD1B6369B /* ImageCache.swift */,
@@ -1653,7 +1654,7 @@
16531654
8AB316C126BC9FFC00C3AC76 /* Cache */ = {
16541655
isa = PBXGroup;
16551656
children = (
1656-
B4E6711E27BB09D6004EE9C1 /* SpriteInfoCacheTests.swift */,
1657+
B432986028D53AEB005AFB98 /* URLDataCacheTests.swift */,
16571658
160D827A2059973C00D278D6 /* DataCacheTests.swift */,
16581659
1662244A2029059C00EA4824 /* ImageCacheTests.swift */,
16591660
);
@@ -1939,6 +1940,8 @@
19391940
isa = PBXGroup;
19401941
children = (
19411942
8A7FD08928D9369C000C448F /* UIViewController.swift */,
1943+
B432985E28D53AB8005AFB98 /* URLSessionDelegateProxy.swift */,
1944+
B432985C28D53A6F005AFB98 /* URLRequest.swift */,
19421945
8A99F18828821AA70034F5BD /* UILayoutGuide.swift */,
19431946
8A50A3D026EC0AA300894A8E /* StyleURI.swift */,
19441947
F46FF186260277F7007CC0E0 /* DateComponentsFormatter+NavigationAdditions.swift */,
@@ -2826,6 +2829,7 @@
28262829
8A285E242637859800B11ECD /* OrnamentsController.swift in Sources */,
28272830
8A1943A92685DC680066E2F8 /* NavigationGeocodedPlacemark.swift in Sources */,
28282831
8A0E0A52257AD9C300C2E924 /* NightStyle.swift in Sources */,
2832+
B432985D28D53A6F005AFB98 /* URLRequest.swift in Sources */,
28292833
8A50A3C526EC09FB00894A8E /* FeedbackViewControllerType.swift in Sources */,
28302834
8AD220B127C097F3000734A5 /* HighlightedButton.swift in Sources */,
28312835
8A12E864282484B20071AF00 /* BannerContainerViewDelegate.swift in Sources */,
@@ -2874,10 +2878,10 @@
28742878
8DEB4066220CE596008BAAB4 /* NavigationMapViewDelegate.swift in Sources */,
28752879
359D283C1F9DC14F00FDE9C9 /* UICollectionView.swift in Sources */,
28762880
8A2354F028877890003E42B4 /* BottomBannerViewControllerLayout.swift in Sources */,
2877-
B4E6712227BB0A56004EE9C1 /* SpriteInfoCache.swift in Sources */,
28782881
8A17635B25CC89D800737520 /* Expression.swift in Sources */,
28792882
8A04DFBC275EBC1B00D87959 /* TopBannerViewControllerDelegate.swift in Sources */,
28802883
8A2081CC25E07CED00F9B8A6 /* RouteLineType.swift in Sources */,
2884+
B432985F28D53AB8005AFB98 /* URLSessionDelegateProxy.swift in Sources */,
28812885
2B3ED38C2609FA7900861A84 /* ArrivalController.swift in Sources */,
28822886
8AD2212327C43DEB000734A5 /* StylableView.swift in Sources */,
28832887
8D24A2F820409A890098CBF8 /* CGSize.swift in Sources */,
@@ -2955,6 +2959,7 @@
29552959
8AD6F25B272216A500326D13 /* MapViewStyleTests.swift in Sources */,
29562960
2E82B9DE26E6237600B7837F /* CongestionLevelTests.swift in Sources */,
29572961
35EFD009207CA5E800BF3873 /* ManeuverViewSnapshotTests.swift in Sources */,
2962+
B432986228D53AF4005AFB98 /* URLDataCacheTests.swift in Sources */,
29582963
8AD12F4D26C1A5C10008AE55 /* Snapshot++.swift in Sources */,
29592964
DA85D5EF25DB4AA4008A2AD4 /* LaneViewTests.swift in Sources */,
29602965
35A262B92050A5CD00AEFF6D /* InstructionsBannerViewSnapshotTests.swift in Sources */,
@@ -2981,7 +2986,6 @@
29812986
B4F4FEAD27AB1E11003915A9 /* SpriteRepositoryTests.swift in Sources */,
29822987
160D827B2059973C00D278D6 /* DataCacheTests.swift in Sources */,
29832988
16E3625C201265D600DF0592 /* ImageDownloadOperationSpy.swift in Sources */,
2984-
B4E6711F27BB09D6004EE9C1 /* SpriteInfoCacheTests.swift in Sources */,
29852989
B40B1C61270380EC0065F57D /* VanishingRouteLineTests.swift in Sources */,
29862990
1662244B2029059C00EA4824 /* ImageCacheTests.swift in Sources */,
29872991
DA1755F82357B6BD00B06C1D /* StringTests.swift in Sources */,

Sources/MapboxNavigation/Cache.swift

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,55 @@ public protocol BimodalDataCache: BimodalCache {
2727
func data(forKey: String?) -> Data?
2828
}
2929

30+
protocol URLCaching {
31+
func store(_ cachedResponse: CachedURLResponse, for url: URL)
32+
func response(for url: URL) -> CachedURLResponse?
33+
func clearCache()
34+
func removeCache(for url: URL)
35+
}
36+
37+
/**
38+
A general purpose URLCache used by `SpriteRepository` implementations.
39+
*/
40+
internal class URLDataCache: URLCaching {
41+
let defaultDiskCacheURL: URL = {
42+
let fileManager = FileManager.default
43+
let basePath = fileManager.urls(for: .cachesDirectory, in: .userDomainMask).first!
44+
let identifier = Bundle.mapboxNavigation.bundleIdentifier!
45+
return basePath.appendingPathComponent(identifier).appendingPathComponent("URLDataCache")
46+
}()
47+
48+
let urlCache: URLCache
49+
let defaultCapacity = 5 * 1024 * 1024
50+
51+
init(memoryCapacity: Int? = nil, diskCapacity: Int? = nil, diskCacheURL: URL? = nil) {
52+
let memoryCapacity = memoryCapacity ?? defaultCapacity
53+
let diskCapacity = diskCapacity ?? defaultCapacity
54+
let diskCacheURL = diskCacheURL ?? defaultDiskCacheURL
55+
if #available(iOS 13.0, *) {
56+
urlCache = URLCache(memoryCapacity: memoryCapacity, diskCapacity: diskCapacity, directory: diskCacheURL)
57+
} else {
58+
urlCache = URLCache(memoryCapacity: memoryCapacity, diskCapacity: diskCapacity, diskPath: diskCacheURL.path)
59+
}
60+
}
61+
62+
func store(_ cachedResponse: CachedURLResponse, for url: URL) {
63+
urlCache.storeCachedResponse(cachedResponse, for: URLRequest(url))
64+
}
65+
66+
func response(for url: URL) -> CachedURLResponse? {
67+
return urlCache.cachedResponse(for: URLRequest(url))
68+
}
69+
70+
func clearCache() {
71+
urlCache.removeAllCachedResponses()
72+
}
73+
74+
func removeCache(for url: URL) {
75+
urlCache.removeCachedResponse(for: URLRequest(url))
76+
}
77+
}
78+
3079
/**
3180
A general purpose on-disk cache used by both the ImageCache and DataCache implementations
3281
*/

Sources/MapboxNavigation/CarPlayMapViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ open class CarPlayMapViewController: UIViewController {
304304
let roadNameFromStatus = notification.userInfo?[PassiveLocationManager.NotificationUserInfoKey.roadNameKey] as? String
305305
if let roadName = roadNameFromStatus?.nonEmptyString {
306306
let representation = notification.userInfo?[PassiveLocationManager.NotificationUserInfoKey.routeShieldRepresentationKey] as? VisualInstruction.Component.ImageRepresentation
307-
wayNameView.label.updateRoad(roadName: roadName, representation: representation)
307+
wayNameView.label.updateRoad(roadName: roadName, representation: representation, idiom: .carPlay)
308308
wayNameView.containerView.isHidden = false
309309
} else {
310310
wayNameView.text = nil
@@ -406,7 +406,7 @@ extension CarPlayMapViewController: StyleManagerDelegate {
406406
let styleURI = StyleURI(url: style.mapStyleURL)
407407
mapboxMapStyle.uri = styleURI
408408
// Update the sprite repository of wayNameView when map style changes.
409-
wayNameView?.label.updateStyle(styleURI: styleURI)
409+
wayNameView?.label.updateStyle(styleURI: styleURI, idiom: .carPlay)
410410
}
411411
}
412412

Sources/MapboxNavigation/CarPlayNavigationViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ open class CarPlayNavigationViewController: UIViewController, BuildingHighlighti
844844
let roadNameFromStatus = notification.userInfo?[RouteController.NotificationUserInfoKey.roadNameKey] as? String
845845
if let roadName = roadNameFromStatus?.nonEmptyString {
846846
let representation = notification.userInfo?[RouteController.NotificationUserInfoKey.routeShieldRepresentationKey] as? VisualInstruction.Component.ImageRepresentation
847-
wayNameView.label.updateRoad(roadName: roadName, representation: representation)
847+
wayNameView.label.updateRoad(roadName: roadName, representation: representation, idiom: .carPlay)
848848
wayNameView.containerView.isHidden = false
849849
} else {
850850
wayNameView.text = nil
@@ -1036,7 +1036,7 @@ extension CarPlayNavigationViewController: StyleManagerDelegate {
10361036
let styleURI = StyleURI(url: style.mapStyleURL)
10371037
mapboxMapStyle?.uri = styleURI
10381038
// Update the sprite repository of wayNameView when map style changes.
1039-
wayNameView?.label.updateStyle(styleURI: styleURI)
1039+
wayNameView?.label.updateStyle(styleURI: styleURI, idiom: .carPlay)
10401040
}
10411041

10421042
updateMapTemplateStyle()

Sources/MapboxNavigation/ExitView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public class ExitView: StylableView {
109109
}
110110

111111
func buildConstraints() {
112-
let height = heightAnchor.constraint(equalToConstant: pointSize * 1.2)
112+
let height = heightAnchor.constraint(equalToConstant: pointSize * InstructionPresenter.labelShieldScaleFactor)
113113

114114
let imageHeight = imageView.heightAnchor.constraint(equalTo: heightAnchor, multiplier: 0.4)
115115
let imageAspect = imageView.widthAnchor.constraint(equalTo: imageView.heightAnchor, multiplier: imageView.image?.size.aspectRatio ?? 1.0)

Sources/MapboxNavigation/GenericRouteShield.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public class GenericRouteShield: StylableView {
7979
}
8080

8181
func buildConstraints() {
82-
let height = heightAnchor.constraint(equalToConstant: pointSize * 1.2)
82+
let height = heightAnchor.constraint(equalToConstant: pointSize * InstructionPresenter.labelShieldScaleFactor)
8383

8484
let labelCenterY = routeLabel.centerYAnchor.constraint(equalTo: centerYAnchor)
8585

Sources/MapboxNavigation/ImageDownload.swift

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ enum DownloadError: Error {
88

99
protocol ImageDownload: URLSessionDataDelegate {
1010
init(request: URLRequest, in session: URLSession)
11-
func addCompletion(_ completion: @escaping ImageDownloadCompletionBlock)
11+
func addCompletion(_ completion: @escaping CachedResponseCompletionHandler)
1212
var isFinished: Bool { get }
1313
}
1414

@@ -77,15 +77,15 @@ final class ImageDownloadOperation: Operation, ImageDownload {
7777

7878
private var dataTask: URLSessionDataTask?
7979
private var incomingData: Data?
80-
private var completionBlocks: [ImageDownloadCompletionBlock] = .init()
80+
private var completionBlocks: [CachedResponseCompletionHandler] = .init()
8181
private let lock: NSLock = .init()
8282

8383
required init(request: URLRequest, in session: URLSession) {
8484
self.request = request
8585
self.session = session
8686
}
8787

88-
func addCompletion(_ completion: @escaping ImageDownloadCompletionBlock) {
88+
func addCompletion(_ completion: @escaping CachedResponseCompletionHandler) {
8989
withLock {
9090
completionBlocks.append(completion)
9191
}
@@ -145,41 +145,36 @@ final class ImageDownloadOperation: Operation, ImageDownload {
145145
}
146146

147147
func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) {
148-
let (incomingData, completions) = withLock { () -> (Data?, [ImageDownloadCompletionBlock]) in
148+
let (incomingData, completions) = withLock { () -> (Data?, [CachedResponseCompletionHandler]) in
149149
let returnData = (self.incomingData, self.completionBlocks)
150150
self.completionBlocks.removeAll()
151151
return returnData
152152
}
153153

154-
let completionData: (UIImage?, Data?, Error?)
154+
let completionData: (CachedURLResponse?, Error?)
155155

156156
if error != nil {
157157
if let urlResponse = task.response as? HTTPURLResponse,
158158
urlResponse.statusCode >= 400 {
159-
completionData = (nil, nil, DownloadError.serverError)
159+
completionData = (nil, DownloadError.serverError)
160160

161161
}
162162
else {
163-
completionData = (nil, nil, DownloadError.clientError)
163+
completionData = (nil, DownloadError.clientError)
164164
}
165165
}
166166
else {
167-
if let data = incomingData {
168-
if let image = UIImage(data: data, scale: UIScreen.main.scale) {
169-
completionData = (image, data, nil)
170-
}
171-
else {
172-
completionData = (nil, data, nil)
173-
}
167+
if let data = incomingData, let urlResponse = task.response {
168+
completionData = (CachedURLResponse(response: urlResponse, data: data), nil)
174169
}
175170
else {
176-
completionData = (nil, nil, nil)
171+
completionData = (nil, nil)
177172
}
178173
}
179174

180175
// The motivation is to call completions outside the lock to reduce the likehood of a deadlock.
181176
for completion in completions {
182-
completion(completionData.0, completionData.1, completionData.2)
177+
completion(completionData.0, completionData.1)
183178
}
184179

185180
withLock {

0 commit comments

Comments
 (0)