mapbox / mapbox/mapbox-gl-js

Fast feature replacement causing desynchronisation

Open
#11,953 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs investigation :mag:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

**mapbox-gl-js version**: 2.8.2 (seen on previous ones too)

**browser**: Google Chrome Version 102.0.5005.61 (Official Build) (x86_64)

### Steps to Trigger Behaviour

1. Replace icon features on the map very rapidly (I think that the more the icon weight, the easier it is to reproduce)

### Link to Demonstration
https://codepen.io/sienki-jenki/pen/xxYzGGM

I'm replacing features every 4ms (can be lower or higher, it's just to stress test mapbox) in interval with 200 new features, 1000 times. At the very last time, so at the 1000 time I'm setting 200 features but right after I set only 199 features.

### Expected Behaviour

One of the 200 icons should disappear and only 199 should be shown.

### Actual Behaviour

200 icons stay rendered, zooming in or out will make this "ghost" icon (top right icon) disappear, but it will come back if we zoom in to the initial state where this icon was rendered. After few seconds icon will disappear.
```
map.queryRenderedFeatures().filter(x => x.source === sourceID);
```
`queryRenderedFeatures` returns 200 features, after few seconds map gets updated internally and returns 199 features, even though new data wasn't set
Fast_feature_replacement_bug

Let me know if maybe my approach to replacing features is wrong or at least how could I avoid having this issue with ghost icon when I'm replacing features very rapidly. 🙏

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the linked CodePen case in Chrome, focusing on rapid replacement of 200 features and the queryRenderedFeatures result for the source. Trace the update and rendering behavior involved in that reproduction; done means replacing 200 features with 199 reliably leaves 199 rendered features without a ghost icon.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.