Collision detection is unstable for very dense sets of labels
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
#5150 makes it so that we're continually re-running collision detection, and a change anywhere on the screen can "cascade" to affect every other label on the screen. We experimented a fair amount with different styles using `mapbox-streets-v7` as a data source, and found that the effect was not very noticeable.
Our assumptions break down a little bit for GeoJSON label sources that don't use clustering -- because at low zoom levels, labels will end up very densely placed. Small changes in camera position then lead to large differences in the collision results.
**Examples from https://github.com/mapbox/mapbox-gl-js/issues/5447 (there are hundreds of labels all trying to show in the same space)**


The bad news:
- There's more instability on zooming than there was before
- There's also potential for instability on panning
The good news:
- Rotation/pitching is pretty much the same as before (since we always re-did placement for pitch/rotate)
- Fade animations make the overall effect less visually jarring
We previously discussed adding some logic that would do something like "if you started fading in within the last second, don't let yourself be knocked out by a label that's currently invisible and in the same layer". Something like that might be workable for dealing with this case. Or... we could just encourage people to use clustering...
/cc @ansis @mollymerp @nickidlugash @jfirebaugh
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review #5150 and the examples from #5447, then reproduce the dense GeoJSON label case at low zoom while panning and zooming. Done means collision placement is stable enough for dense, non-clustered sources without regressing the stated rotation and pitch behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- computer-graphics, frontend
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100