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

Popups and markers lag behind the map during pan animation #4670

Closed
bicubic opened this issue May 3, 2017 · 14 comments
Closed

Popups and markers lag behind the map during pan animation #4670

bicubic opened this issue May 3, 2017 · 14 comments
Labels

Comments

@bicubic
Copy link

bicubic commented May 3, 2017

Issue can be seen at https://www.mapbox.com/mapbox-gl-js/example/popup/
Perform a pan gesture with the mouse and lift the mouse button while still moving the cursor so the map continues to pan for a bit. Alternatively, use the arrow buttons to pan the map.

During the animation, the popup appears to be located a few pixels (one frame?) behind the map. Quite jarring on touch screen experiences.

@kkaefer
Copy link
Contributor

kkaefer commented May 3, 2017

Here's a slowed down version of the bug.
out2

@dagjomar
Copy link
Contributor

dagjomar commented May 3, 2017

This is true not only for popups for markers also. Generally, things that are DOM elements placed on top of the rendered canvas.

@bicubic
Copy link
Author

bicubic commented May 4, 2017

Looks like it may be a timing issue after all. The DOM appears to be a frame ahead of the canvas when the pan easing animation is in effect.

The attached gist is a proof of concept which injects one frame of latency to the popup transform. The latency is added only if the _update() was called from browser.tick() and not if it originated from a mouse event.

It doesn't completely solve the misalignment but does significantly improve it for me. I believe the remainder of the misalignment may be due to the camera._ease logic which is panning the camera by sub-pixel amounts. During mouse panning, the point is always integer. I can't figure out how to fix the remaining error, but hopefully this gives some clue where to look.

I'm happy to work towards a PR if you guys have an idea of how to tackle this. I don't think that latency hack is a viable solution in itself.

https://gist.github.com/bicubic/272f56341b55689982c60e32c7b28242

@bicubic
Copy link
Author

bicubic commented May 4, 2017

Please take a look at #4681

I was able to get popups fully aligned with two changes:

DOM transform updates are not applied immediately but buffered via new function util.pushTransform() and applied via util.applyTransforms() which is invoked by painter.render(). This ensures that layout changes happen at the same time as canvas painting. This involved a change to DOM.setTransform(), but it is backwards compatible and callers must explicitly pass in a new parameter to buffer the change, otherwise it is invoked immediately as before.

Second change is Popup.offsetedPos rounding is prevented if and only if a pan easing animation is in progress. This allows the popup to match the sub-pixel map animation and eliminates the final source of perceived jitter. Upon the completion of the animation, the offset is rounded off. Rounding is still applied in all other scenarios.

@joedjc
Copy link

joedjc commented May 8, 2017

It would be great if this could be fixed. I find it is highly dependent on the browser. Chrome and Firefox are pretty much always in sync, but most other browsers (Safari, IE, Edge) have a noticeable lag which doesn't look good.

@mourner mourner changed the title Popups lag behind the map during pan animation Popups and markers lag behind the map during pan animation Jul 4, 2017
@keyofj
Copy link

keyofj commented Aug 9, 2017

@dagjomar I experience the same mostly in IE 11 and Safari. When dragging mapboxgl.Marker drags behind so it gives a rubber band effect. I have not figured out a way to stop this other than have users use Chrome.

@omasback
Copy link

Not sure if this is the same bug, but map.fitBounds() exhibits the same behavior, even on Chrome. It seems that the markers are one frame ahead of the map. As a workaround I used an ease-in easing to keep the marker from jumping way ahead on the first frame

@andy-mcdonald
Copy link

Still seeing the issue as described on Safari (not tested on IE / Edge) with the latest version (v0.42.1) of mapbox-gl. Wondering if this has been verified as a bug and is there a fix in the works?

Overall, MapBox looks incredible and far more appealing than Google Maps but unfortunately, this is pretty much a deal-breaker in terms of using it in our current project.

Any update on the status of this issue (even if it's a 'no fix coming soon') would be greatly appreciated :)

@joedjc
Copy link

joedjc commented Nov 20, 2017

I agree it would be great to know if this can be fixed. I am hoping it might be related to this issue #5390 as the behaviour looks very similar so it may fix that as well

@ChrisLoer
Copy link
Contributor

@jfirebaugh I'm still seeing this on Safari and Mobile Safari (but not Chrome or Firefox):

marker_lag

@joedjc
Copy link

joedjc commented Jan 9, 2018

@ChrisLoer @jfirebaugh It's still there in IE11 and Edge as well (where it has always been worse). I was hoping it would also fix this #5390 but I still see it...especially in IE11 and Edge. Although its a different use case it does look like similar behaviour.

@jfirebaugh
Copy link
Contributor

Tracking the "map lags popups and markers" issue in #5390.

@Bryce-Davidson
Copy link

Any update on this? I'm experiencing the same issues here

@mateusz-kawka
Copy link

Hey, I still have this problem, regardless of the browser it works the same.
Is there any chance to fix it?

3b584b404db49dbe1c5f65cbbcd937e1.mp4

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