Skip to content

Commit 9d976f3

Browse files
authored
Fixed the delay on camera changes. (#9082)
1 parent 0ec8168 commit 9d976f3

File tree

3 files changed

+4
-10
lines changed

3 files changed

+4
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
* Fixed an issue where the user interface did not necessarily display distances in the same measurement system as the requested route by default.
3434
* Fixed the fallback to the `RouteOptions.locale` for on-device speech synthesizing if the Mapbox Voice API does not support the requested language.
35+
* Fixed the delay on camera changes during heading updates with using the walking routing profile.
3536

3637
### Packaging
3738

Sources/MapboxNavigationCore/Map/Camera/NavigationCamera.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public class NavigationCamera {
8585
observe(viewportDataSource: self.viewportDataSource)
8686

8787
_states
88-
.debounce(for: 0.2, scheduler: DispatchQueue.main)
88+
.throttle(for: 0.2, scheduler: DispatchQueue.main, latest: true)
8989
.sink { [weak self] newState in
9090
guard let self else { return }
9191
if let location = newState.location {

Tests/MapboxNavigationCoreTests/Map/Camera/NavigationCameraTests.swift

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -244,15 +244,8 @@ class NavigationCameraTests: BaseTestCase {
244244
}
245245

246246
@MainActor
247-
func testViewportDataSourceForActiveGuidance() async {
247+
func testViewportDataSourceForActiveGuidance() async throws {
248248
let navigationViewportDataSource = navigationCamera.viewportDataSource as? MobileViewportDataSource
249-
250-
let expectation = XCTestExpectation(description: "Camera options expectation.")
251-
navigationCamera.cameraStates
252-
.sink { _ in
253-
expectation.fulfill()
254-
}.store(in: &subscriptions)
255-
256249
let location = CLLocation(latitude: 37.112341, longitude: -122.1111678)
257250
locationPublisher.send(location)
258251

@@ -261,7 +254,7 @@ class NavigationCameraTests: BaseTestCase {
261254
progress.update(using: status)
262255
routeProgressPublisher.send(progress)
263256

264-
await fulfillment(of: [expectation], timeout: 1)
257+
try await Task.sleep(nanoseconds: NSEC_PER_SEC)
265258

266259
let cameraOptions = navigationViewportDataSource?.currentNavigationCameraOptions
267260
guard let temporaryPitch = cameraOptions?.followingCamera.pitch else {

0 commit comments

Comments
 (0)