Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
chizhavko committed Jul 23, 2024
1 parent f8f1932 commit ec6e1e9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
16 changes: 15 additions & 1 deletion Example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -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) {
Expand Down
3 changes: 0 additions & 3 deletions Sources/MapboxNavigation/CarPlayManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit ec6e1e9

Please sign in to comment.