mapbox-maps-android
mapbox-maps-android copied to clipboard
Unintentional jump may still occur even after left the follow viewport state
Observed behavior and steps to reproduce
Sometimes, the location puck will jump to the map center even I pan the map to leave the follow viewport state.
This can occur more easily, if you set the bearing of FollowPuckViewportStateOptions to a constant value, and test in indoor environment where there is no GPS signal available. When switched to the follow state, just after the location puck moved to the map center, pan the map to leave the follow state. The location puck may jump to the map center after a while.
Expected behavior
The location puck should not jump to the map center after left the follow viewport state.
Notes / preliminary analysis
It seems that FollowPuckViewportStateImpl.removeIndicatorListenerIfNeeded may not run successfully sometimes, as dataSourceUpdateObservers is not empty. This may occur as DefaultViewportTransitionImpl does not remove its observer immediately after the transition completed. Currently, it relies on FollowPuckViewportStateImpl to remove the observer on next notifyViewportStateDataObserver.
To solve the issue, may make the following change to DefaultViewportTransitionImpl:
var keepObserving = true
+ var observeCancelable: Cancelable? = null
completionListener.onComplete(!isCanceled)
+ observeCancelable?.cancel()
+ observeCancelable = cancelable
return Cancelable {
It seems that the iOS version has similar logic.
Bug is still present in 11.1.0