Skip to content

Commit 79617fe

Browse files
dzinadgithub-actions[bot]
authored andcommitted
NAVAND-6498: make public state update synchronous
GitOrigin-RevId: 226c67fea4b8c6f5d79bf96292b05644f767c1ac
1 parent e208fd3 commit 79617fe

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fix an issue where transitionEndListener passed to `NavigationCamera#requestNavigationCameraTo...` might not have been invoked.

ui-maps/src/main/java/com/mapbox/navigation/ui/maps/camera/NavigationCamera.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,8 +607,13 @@ internal constructor(
607607
}
608608

609609
finishAnimation(animation)
610-
transitionEndListeners.forEach { it.onTransitionEnd(isCanceled) }
610+
// Custom transitionEndListener might synchronously start another transition.
611+
// In this case we risk running into a race condition where the new transitionEndListeners
612+
// will be cleared at the next line before its animation is ended.
613+
// To avoid this, we first clear the existing listeners and only then notify them.
614+
val listeners = transitionEndListeners.toSet()
611615
transitionEndListeners.clear()
616+
listeners.forEach { it.onTransitionEnd(isCanceled) }
612617
updateFrame(viewportDataSource.getViewportData(), instant = false)
613618
}
614619

0 commit comments

Comments
 (0)