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.

Incorrect MyLocationView transformation #5438

Closed

Description

@justasm

Platform: Android
Mapbox SDK version: 4.1.0-beta.3

Steps to trigger behavior

  1. Enable MyBearingTracking.COMPASS tracking mode.
  2. Tilt map around x axis (i.e. pitch) using two-finger shove gesture.
  3. Rotate map around z axis (i.e. bearing, aka direction) using two-finger rotate gesture.

Expected behavior

screenshot_20160622-182419

Actual behavior

screenshot_20160622-182544

Discussion

The 3D transformation calculation for MyLocationView is

  1. incorrect - the compass bearing / direction rotation is applied as M' = R(degrees) * M using Matrix#postRotate(float), whereas it should be calculated as M' = M * R(degrees), e.g. by using Matrix#preRotate(float).
  2. incomplete - map rotation around the z axis, i.e. map bearing / direction, is not taken into account. The compass bearing indicator is therefore incorrect when the map is not pointing north. Map rotation gestures should be propagated to MyLocationView, similar to how tilt is, and accounted for when calculating the transformation.
  3. needlessly complex - it uses both the Camera and Matrix classes, whereas the entire transformation could be calculated using just Camera and applied using Camera#applyToCanvas(canvas).

Activity

  1. added
    Android
    on Jun 22, 2016
  2. tobrun commented on Jun 24, 2016

    @tobrun
    Member

    @justasm thank you for writing this up. I was able to reproduce the issue shown in the screenshot and patch it up by applying Matrix#preRotate(float) instead of Matrix#postRotate(float) in 0fd450e. I'm now looking into your suggestions from 2) and 3).

  3. added this to the android-v4.1.0 milestone on Jun 24, 2016
  4. added a commit that references this issue on Jun 24, 2016
  5. tobrun commented on Jun 24, 2016

    @tobrun
    Member

    Also noticing that when compass bearing is active and we don't have a tracking mode active. That the rotate gesture is disabled, while it should be enabled.

  6. tobrun commented on Jun 24, 2016

    @tobrun
    Member

    Noticing 2 JNI related items:

    • getMeterPerPixelAtLatitude is called for each onDraw which is not good for performance.
    • I'm thinking about caching this value, a not 100% correct value will not have that much impact since the value is used for the accuracy circle.
    • The MyLocationView is sometimes stuck in an invalidation loop. Resulting in constantly invalidating through JNI. While the map is actually not changing and is stable.
  7. tobrun commented on Jun 24, 2016

    @tobrun
    Member

    The MyLocationView is sometimes stuck in an invalidation loop.

    This occurred only when we receive a location update and were trying to animate the location update through an animator. For non-tracking behaviour we don't need to invalidate the map, we only need to invalidate the MyLocationView.

  8. tobrun commented on Jun 24, 2016

    @tobrun
    Member

    I'm thinking about caching this value, a not 100% correct value will not have that much impact since the value is used for the accuracy circle.

    I was wrong here because getMetersPerPixelAtLatitude uses current zoom level. I'm going try moving it to another place in the code than the onDraw.

  9. added 7 commits that reference this issue on Jun 24, 2016
  10. 1 remaining item

  11. tobrun commented on Jun 24, 2016

    @tobrun
    Member

    Here you can see the less optimal UX but with improved performance since we are no longer calling a JNI method directly in onDraw.

    ezgif com-video-to-gif 41

  12. tobrun commented on Jun 25, 2016

    @tobrun
    Member

    Looking into this issue has resulted me going into the rabbit hole and finding/fixing multiple things. To limit impact/regressions for the release we are planning next week I'm going to patch up a few things and revisit this issue after release.

    -> simplified version of this ticket in: #5479

  13. removed this from the android-v4.1.0 milestone on Jun 25, 2016
  14. added this to the android-v4.2.0 milestone on Jul 11, 2016
  15. tobrun commented on Jul 11, 2016

    @tobrun
    Member

    I'm running back at this issue, starting this off by cherry picking some ideas from #5468

  16. added 7 commits that reference this issue on Jul 12, 2016
  17. cammace commented on Aug 9, 2016

    @cammace
    Contributor

    This ticket seems to be tracking multiple issues with the location view, If they haven't been fixed yet can we ticket them out separately and close this one @tobrun?

  18. self-assigned this
    on Aug 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Android

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions