mapbox / mapbox/mapbox-maps-android

Unintentional jump may still occur even after left the follow viewport state

Open
#2,147 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

auto-triaged bug :beetle:
Dominant language
Kotlin
Stars
578
Forks
161
PR merge metrics
No merged PRs in 30d

Description

## 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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing FollowPuckViewportStateImpl.removeIndicatorListenerIfNeeded and DefaultViewportTransitionImpl, focusing on dataSourceUpdateObservers and the transition completion listener. Reproduce the follow-state, panning, and no-GPS scenario, then verify that leaving the follow state prevents any later jump to the map center; compare the similar iOS logic if useful.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.