-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
attribution_control._updateAttribution causing Style Recalculation and Layout #4447
Comments
Nice catch! We're always looking for perf improvements to |
Thanks @Scarysize ! That demo you linked to is using an older version of mapbox-gl-js and I think the behavior is different now since we refactored our eventing for sourcedata #4347 . Its true that I haven't been able to reproduce what you're seeing with the most recent release, so I'm cautiously optimistic that this has been resolved. |
Great, thanks for the fast reaction. I will give it a try as soon as the PR is through. 👌 |
@Scarysize we just merged the fix into master! Mind letting us know if this helps with your issue? |
@mollymerp Thanks for the heads-up. Looks good so far, no more style recalculation or layout every frame! Glad this could be resolved so fast, I guess this can be closed now 🎉 |
Great to hear! thanks for the followup 😸 |
Seems the attribution control is updated every time
.setData
is called on a GeoJSON source (which makes sense). This update causes the browser to recalculate styles and layout. This is fine most of the time, because you are calling.setData
once. Though when animating features on the map in a animation loop (requestAnimationFrame
), this costs valuable milliseconds each frame. I observed between 0.5 and 4ms (!).In my application I'm doing something similar like the example below does (actual implementation-wise pretty much exactly that).
Versions I experienced this:
Steps to Trigger Behavior
Expected Behavior
Don't trigger Style Recalculation and Layout every frame
Actual Behavior
Above mentioned is happening every
Some screenshots taken on a MBP 13" (mid 2015), recent Chrome
The text was updated successfully, but these errors were encountered: