From ec6e1e9489ac223622e7570c834d9b2df07da7c9 Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 23 Jul 2024 12:14:06 +0100 Subject: [PATCH] Update --- CHANGELOG.md | 8 +++++++- Example/ViewController.swift | 16 +++++++++++++++- Sources/MapboxNavigation/CarPlayManager.swift | 3 --- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b36ee6130..6756680038 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,16 @@ # Changes to the Mapbox Navigation SDK for iOS +## v2.18.2 + +### CarPlay + +* Fixed CarPlay crash when calling `CarPlayManager.routePreview()` function for iOS 14+. + ## v2.18.1 ### CarPlay -* Fixed CarPlay crash when calling `CarPlayManager.routePreview()` function. +* Partially fixed CarPlay crash when calling `CarPlayManager.routePreview()` function. ## v2.18.0 diff --git a/Example/ViewController.swift b/Example/ViewController.swift index 77e9206f81..6dd6cc27d0 100644 --- a/Example/ViewController.swift +++ b/Example/ViewController.swift @@ -237,6 +237,12 @@ class ViewController: UIViewController { guard let delegate = UIApplication.shared.delegate as? AppDelegate else { return } if let indexedRouteResponse = indexedRouteResponse { delegate.carPlayManager.previewRoutes(for: indexedRouteResponse) + + // debug + // By enabling following lines, it makes easy to reproduce the same crash. + DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { + delegate.carPlayManager.previewRoutes(for: indexedRouteResponse) + } } else { delegate.carPlayManager.cancelRoutesPreview() } @@ -251,7 +257,15 @@ class ViewController: UIViewController { } @IBAction func simulateButtonPressed(_ sender: Any) { - simulationButton.isSelected = !simulationButton.isSelected +// simulationButton.isSelected = !simulationButton.isSelected + + let destinationCoordinate = CLLocationCoordinate2D(latitude: 37.957453, longitude: -122.523200) + let waypoint = Waypoint(coordinate: destinationCoordinate, name: "Dropped Pin #\(waypoints.endIndex + 1)") + + waypoint.targetCoordinate = destinationCoordinate + waypoints = [waypoint] + + requestRoute() } @IBAction func clearMapPressed(_ sender: Any) { diff --git a/Sources/MapboxNavigation/CarPlayManager.swift b/Sources/MapboxNavigation/CarPlayManager.swift index b324bbcbe4..c835009c6b 100644 --- a/Sources/MapboxNavigation/CarPlayManager.swift +++ b/Sources/MapboxNavigation/CarPlayManager.swift @@ -102,7 +102,6 @@ public class CarPlayManager: NSObject { private weak var navigationService: NavigationService? private var idleTimerCancellable: IdleTimerManager.Cancellable? private var indexedRouteResponse: IndexedRouteResponse? - private let semaphore = DispatchSemaphore(value: 1) /** Programatically begins a CarPlay turn-by-turn navigation session. @@ -654,8 +653,6 @@ extension CarPlayManager { } func previewRoutes(for trip: CPTrip) { - semaphore.wait() - defer { semaphore.signal() } guard let traitCollection = (self.carWindow?.rootViewController as? CarPlayMapViewController)?.traitCollection, let interfaceController = interfaceController else {