Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UserCourseView should update instantaneously when user gestures cause camera changes #1731

Closed
1ec5 opened this issue Sep 19, 2018 · 3 comments · Fixed by #2047
Closed

UserCourseView should update instantaneously when user gestures cause camera changes #1731

1ec5 opened this issue Sep 19, 2018 · 3 comments · Fixed by #2047
Assignees
Labels
bug Something isn’t working
Milestone

Comments

@1ec5
Copy link
Contributor

1ec5 commented Sep 19, 2018

When the user manually rotates the map using gestures, the puck should rotate synchronously with the map. Currently, there’s a bit of a lag that, while smooth, makes the puck look like it’s on a turntable. Similarly and more noticeably, when the user manually pans the map using gestures, the puck should move synchronously with the map instead of casually mosying over to the new location.

Both these issues would be fixed by disabling UserCourseView’s animation (or setting the animation duration to 0 seconds) when the map view’s camera changes for reasons other than course tracking. #1506 fixed the same issue, but only when transitioning between overview and turn-by-turn modes.

/cc @vincethecoder

@1ec5 1ec5 added the bug Something isn’t working label Sep 19, 2018
@1ec5
Copy link
Contributor Author

1ec5 commented Sep 20, 2018

In CarPlay, it’s easy to reproduce this issue by showing and hiding the navigation bar:

delay

@akitchen
Copy link
Contributor

We've run into this pretty consistently recently. Per @1ec5 we should remove use of UIView animations in cases where the puck's location on screen changes in response to a map camera change.

Related: #1949 (comment) (likely the same fix)

@1ec5
Copy link
Contributor Author

1ec5 commented Mar 14, 2019

We are synchronizing the puck on every rendered frame, even when not in course tracking mode:

guard let location = userLocationForCourseTracking else { return }
userCourseView?.center = convert(location.coordinate, toPointTo: self)

All the while, location updates are coming in, so the map view has a legitimate reason to kick off animations:

UIView.animate(withDuration: duration, delay: 0, options: [.curveLinear, .beginFromCurrentState], animations: {
self.userCourseView?.center = self.convert(location.coordinate, toPointTo: self)
})

The problem is with beginFromCurrentState: we kick off an animation, then atomically set the center a number of times during the animation (due to user gestures). The animation builds upon those explicit camera changes, resulting in a wonky additive effect. We probably need to cancel any animations when synchronizing the puck to the map due to a frame getting rendered.

In general, the map SDK has already solved the issues around synchronizing views to the map. So we can look to the MGLMapView implementation for clues about how to solve this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn’t working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants