File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed
changelog/unreleased/bugfixes
ui-maps/src/main/java/com/mapbox/navigation/ui/maps/camera Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change 1+ - Fix an issue where transitionEndListener passed to ` NavigationCamera#requestNavigationCameraTo... ` might not have been invoked.
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments