Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Unresponsive MyBearingTracking.COMPASS behavior #5335

Closed

Description

@justasm

Platform: Android
Mapbox SDK version: 4.1.0-beta.2 + #5333

Steps to trigger behavior

  1. Open User tracking mode demo (i.e. MyLocationTrackingModeActivity) in Mapbox Android SDK TestApp.
  2. In top right dropdown, select Compass bearing.

Expected behavior

Bearing indicator starts responding immediately and correctly indicates the device's bearing.

Actual behavior

Bearing indicator remains stuck indicating north for multiple seconds. The indicator updates occasionally but eratically, and does not correctly indicate the device's bearing for the majority of the time.

There are two issues at play here:

  1. The logic in the CompassListener#onSensorChanged(SensorEvent) callback is throttled according to UPDATE_RATE_MS. Two types of events (accelerometer and magnetometer) are sent to this callback, but the arrival of either one subsequently blocks processing for UPDATE_RATE_MS. In my testing, it was common for e.g. multiple seconds of magnetometer events only to be processed. This would simultaneously block any accelerometer data for that period of time. If this happens at the start when either sensor value array is zeroed, the bearing output remains zero until both types of sensor data are processed. If this happens at a later time, either the magnetometer or the accelerometer data may become multiple seconds out-of-date, resulting in an incorrect bearing calculation.
  2. The bearing indicator rotation is reflected in MyLocationView#onDraw(Canvas). MyLocationView#setCompass(float) starts an animator to update the bearing indicator rotation. However, this animator does not call MyLocationView#invalidate() during the animation. This results in the bearing indicator updating only when something else coincidentally invalidates MyLocationView.

Activity

  1. added 2 commits that reference this issue on Jun 13, 2016
  2. justasm commented on Jun 13, 2016

    @justasm
    ContributorAuthor

    On a somewhat related note, the bearing indicator animation may appear more continuous if the animation duration matches the update rate, instead of using a seemingly arbitrary value of 375 ms.

  3. added 2 commits that reference this issue on Jun 17, 2016
  4. added
    Android
    on Jun 17, 2016
  5. tobrun commented on Jun 17, 2016

    @tobrun
    Member

    Still need to pick up suggestion in #5335 (comment) to close this issue.

  6. cammace commented on Nov 16, 2016

    @cammace
    Contributor

    The bearing indicator animation has been changed recently to be more continuous.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Androidbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions