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

Lack of support for other time-sources to control animations #114

Closed
JannikGM opened this issue Mar 23, 2021 · 4 comments
Closed

Lack of support for other time-sources to control animations #114

JannikGM opened this issue Mar 23, 2021 · 4 comments
Labels

Comments

@JannikGM
Copy link
Contributor

mapbox / maplibre does not have an intended way to control the timesource.

Most functions in maplibre will use browser.now which is defined here:

const now = window.performance && window.performance.now ?
window.performance.now.bind(window.performance) :
Date.now.bind(Date);

This also controls camera animations like flyTo / easeTo:

_renderFrameCallback() {
const t = Math.min((browser.now() - this._easeStart) / this._easeOptions.duration, 1);
this._onEaseFrame(this._easeOptions.easing(t));

While this is probably a good approach that inherently supports delta timing, it's not universally the best solution.

Motivation

We often call flyTo from a component update in the react framework. Once all the components are updated, react will start generating a new DOM and we can have lag spikes of 100ms or more (= 10% of the animation for a 1 second animation = roughly 6 frames).
We are trying to improve our react performance to avoid framedrops, but framedrop can also happen for other reasons (like window-resize); it's probably not avoidable.

So between starting the animation and rendering, 100ms will have passed already.
So when mapbox renders the animation, it will effectively drop 100ms of the animation and the result feels laggy.
The user loses visual context of the map scrolling past them.

For our other (custom-made map) animations we already have a custom time-source which detects these lag-conditions and pauses animations temporarily, rather than doing a frameskip.
maplibre should be able to support other time-sources so such strategies can be applied.

At our company, we have this problem in different products (also because #106 and flyTo at the same time) made by different developers. So I assume other people also have this problem - so this isn't as niche as it seems.

Another potential use-case might be testing / profiling. With a custom time-source, we could do more reproducible testing and profiling of rendering / tile-loading during animations (although this might be better to handle in the browser-test-driver by hooking the browser time-sources; I did not check if this is already implemented somewhere).

@JannikGM
Copy link
Contributor Author

JannikGM commented Apr 6, 2021

@github-actions
Copy link
Contributor

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale label Oct 22, 2021
@JannikGM JannikGM removed the Stale label Oct 22, 2021
@github-actions
Copy link
Contributor

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Apr 21, 2022
@github-actions
Copy link
Contributor

This issue was closed because it has been stalled for 30 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant