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

Concurrent transition animations #3625

Open
1ec5 opened this issue Jan 20, 2016 · 13 comments
Open

Concurrent transition animations #3625

1ec5 opened this issue Jan 20, 2016 · 13 comments
Labels
Core The cross-platform C++ core, aka mbgl feature navigation For the Mapbox Navigation SDK for Android or iOS or navigation use cases in general

Comments

@1ec5
Copy link
Contributor

1ec5 commented Jan 20, 2016

mbgl::Transform only supports one transition animation at a time, and starting an animation ends any existing animation (see #3624). mbgl::Transform should be refactored to manage multiple concurrent animations, potentially with staggered start and end times. At a minimum, it should be possible for two animations that animate different properties to run without conflicting with one another.

/cc @ansis @lucaswoj

@jfirebaugh
Copy link
Contributor

Can you say more about why it needs to support this?

@1ec5
Copy link
Contributor Author

1ec5 commented Jan 20, 2016

On iOS, in heading tracking mode, user location updates typically come in every second or so (less frequently when there’s poor GPS connectivity), while heading updates come in more or less in real time from the on-board magnetometer.

MGLMapView pans to the new location with animation and also independently rotates to the new heading with animation. However, if you’re in motion and aren’t keeping your device pointed in a constant direction, heading updates tend to interrupt animations to new locations. On master, this is perceived as the map jumping from location to location with smooth rotation. In #3589, this is perceived as a series of smooth rotations in one place, followed by rapid panning as the location updates catch up.

I considered less drastic approaches to addressing this issue, such as allowing callers to easeTo() to update the camera in the middle of the animation, but the resulting code was messier than what we would get by supporting multiple concurrent animations. To be clear, all the animations would continue to run on the Map thread, but we’d interleave their frame functions rather than canceling animations.

@ansis
Copy link
Contributor

ansis commented Jan 20, 2016

to update the camera in the middle of the animation

What does "update the camera" mean here? If I do map.getLatLng in the middle of an animation do I get the current location or the location of the beginning of the animation?

@1ec5
Copy link
Contributor Author

1ec5 commented Jan 20, 2016

What does "update the camera" mean here?

CameraOptions is passed in by reference, so I considered checking on each frame whether the CameraOptions fields had changed and adjust accordingly. But that would never yield a pleasing animation and introduces too much complexity into what are already complex easeTo() and flyTo() methods. I don’t see a whole lot of code in mbgl or the iOS or OS X SDKs that assumes only one animation can run at a time. The Android SDK does appear to rely on this assumption for its listeners (cc @tobrun), so there might need to be more significant changes there.

If I do map.getLatLng in the middle of an animation do I get the current location or the location of the beginning of the animation?

You get the current location. That won’t change.

@1ec5
Copy link
Contributor Author

1ec5 commented Jul 8, 2016

A completely different approach to this problem would be to have platform-specific SDK code drive the animation. iOS, macOS, and Qt (not sure about Android) all have rich animation APIs, with options for keyframe animation, spring animations, and physics modeling, all things we wouldn’t want to have to build in mbgl and expose as a somewhat foreign-looking API. Animation notifications also become more predictable because only one layer of the stack is involved.

However, perhaps mbgl::Transition is valuable in its own right as an analogue to GL JS’s animation options. In that case, we’ll want to implement the concurrent animations described above for parity with mapbox/mapbox-gl-js#2801.

/cc @tmpsantos

@1ec5
Copy link
Contributor Author

1ec5 commented Feb 22, 2017

It may be unnecessary for us to implement this feature at the mbgl level if we end up driving camera transitions at the SDK level on Android (#8175) and iOS/macOS (#8176) like we do in Qt.

@1ec5
Copy link
Contributor Author

1ec5 commented Mar 27, 2018

In #3589, this is perceived as a series of smooth rotations in one place, followed by rapid panning as the location updates catch up.

#10906 describes this behavior as well.

@stale
Copy link

stale bot commented Oct 25, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the archived Archived because of inactivity label Oct 25, 2018
@1ec5 1ec5 removed the archived Archived because of inactivity label Oct 25, 2018
@juliengdt
Copy link

Hello everyone.
I encountered this issue in my app (indoor location with heading)

This is really annoying, especially with a minimal zoom on the user position (many animation when I walk + many animation for heading)

Any workaround for this ?

@juliengdt
Copy link

Ahoy, I up it ! Any announcements or any good workaround ?

thanks anyway

@stale
Copy link

stale bot commented Nov 12, 2019

This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

@stale stale bot closed this as completed Nov 12, 2019
@1ec5
Copy link
Contributor Author

1ec5 commented Apr 13, 2020

This is still a need, particularly so that heading tracking isn’t mutually exclusive of location tracking: #3625 (comment).

@stale
Copy link

stale bot commented Oct 12, 2020

This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Core The cross-platform C++ core, aka mbgl feature navigation For the Mapbox Navigation SDK for Android or iOS or navigation use cases in general
Projects
None yet
Development

No branches or pull requests

5 participants