Globe view downloading more tiles than necessary
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
As pointed out by @ansis in https://github.com/mapbox/mapbox-gl-js/pull/11917#issuecomment-1141160639
### Steps to Trigger Behavior
1. Go to http://localhost:9966/debug/projections.html#3.11/2.01/0.71
2. Switch projection to globe and enable debug tiles
3. Shrink window so that only four tiles are visible

4. In console:
```js
Object.keys(map.style._sourceCaches['other:composite']._tiles).length
8
```
Logging the tiles, we can see that tiles columns 2 and 5 are included, which are to the right and left of the visible screen:
```js
[
[3, 4, 3],
[3, 4, 4],
[3, 3, 3],
[3, 3, 4],
[3, 5, 3],
[3, 5, 4],
[3, 2, 3],
[3, 2, 4]
];
```
This issue also occurs with raster tiles and can be tested with:
```js
Object.keys(map.style._sourceCaches['other:mapbox']._tiles).length
```
Removing these extra tiles should be a low-hanging fruit for improving performance, though it may require a more involved collision detection algorithm than the axis-aligned-bounding-box approach introduced in https://github.com/mapbox/mapbox-gl-js/pull/11508.
On the other hand, it's possible that including these extra tiles in the cache could improve performance on subsequent panning. (Though even if this was included as a feature, they should not cause additional draw calls).
cc @ansis @akoylasar
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
Reproduce the issue from debug/projections.html#3.11/2.01/0.71 with globe projection and debug tiles, then inspect the source cache tile lists for vector and raster sources. Read the axis-aligned-bounding-box approach introduced in pull request 11508 and compare visible tiles, cached tiles, and draw calls. Done means unnecessary downloads or rendering are avoided without breaking subsequent panning behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100