mapbox / mapbox/mapbox-gl-js

Collision detection is unstable for very dense sets of labels

Open
#5,526 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug :lady_beetle:
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)**
![dense_label_instability](https://user-images.githubusercontent.com/375121/32027855-4862d550-b9a0-11e7-9998-c56907f938ca.gif)

![dense_label_instability_rotate](https://user-images.githubusercontent.com/375121/32027854-4848627e-b9a0-11e7-8c89-1ecc75ffcf37.gif)

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

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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.