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

Performance issues when using feature state with promoted string feature ids #13315

Open
dastardlylemon opened this issue Nov 4, 2024 · 0 comments

Comments

@dastardlylemon
Copy link

dastardlylemon commented Nov 4, 2024

When using Mapbox feature state to handle updating a source with a large number of features quickly, I find that there is a significant performance degradation when using the promoteId source feature to use a non-numeric string identifier, such as a UUID. The performance gets worse the more features get updated feature state, and is particularly noticeable when zooming in and out of the features on the map.

If I swap the source to use generateId, the issue goes away, and feature state performs as efficiently as expected. I suspect the same may be the case if the features had their own numeric ids, as well.

mapbox-gl-js version: 3.7.0

browser: Chrome Version 130.0.6723.70

Steps to Trigger Behavior

  1. Create a map with a GeoJSON FeatureCollection source. Create a unique string identifier in the properties field of each Feature in the collection, and use promoteId on the map source to point to that identifier field. The issue is more noticeable with a large quantity of data.
  2. Add a layer with paint properties that depend on feature state.
  3. Add mousemove hover behavior to update that feature state property.
  4. Hover over several different points and attempt to zoom in and out of the map. Observe the choppy behavior.
  5. (bonus) replace promoteId with generateId on the source and repeat step 4. Observe the smooth behavior.

Link to Demonstration

With promoteId: https://jsfiddle.net/cLav6hbm/4/
With generateId: https://jsfiddle.net/cLav6hbm/3/

Expected Behavior

Smooth panning and zooming on the map.

Actual Behavior

Choppy panning and zooming on the map.

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

No branches or pull requests

1 participant