mapbox / mapbox/mapbox-gl-js

Allow limiting number of concurrent vector tile requests

Open
#13,211 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature :green_apple:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

## Motivation

If you have many vector tile sources present on the map then animations can send out a huge number of concurrent requests, potentially overwhelming the browser and throwing `ERR_INSUFFICIENT_RESOURCES` errors which don't get retried by mapbox resulting in missing tiles. More seriously it can disrupt all other concurrent requests being sent out by the browser.

I think this is also related to some of the problems outlined by #13208

## Design Alternatives

There was talk of a `TileQueue` on #6643 :

> I've looked into how OpenLayers handles raster tile loading, and I believe the reason why their equivalent is fast is that they use a [TileQueue](https://github.com/openlayers/openlayers/blob/master/src/ol/TileQueue.js) data structure [that makes sure](https://github.com/openlayers/openlayers/blob/df293d8a2e182b5add69365b0d5da054619bfe23/src/ol/source/Raster.js#L341) there are never more than 16 tiles loading in parallel or requested at once in one frame. This makes it avoid requesting short-lived tiles that e.g. get requested on zoom in near the borders of the map and then immediately go off the view when zooming further during an animation. This might be a possible solution to this feature request https://github.com/mapbox/mapbox-gl-js/issues/5482, and we should definitely explore a similar approach.

I'm wondering if such a thing could be added for vector sources too? Though maybe 16 is too conservative a number for vector tiles

### Mock-Up

It would be nice to expose a variable similar to the existing `mapboxgl.maxParallelImageRequests `, but applying to vector tiles rather than images. e.g. `mapboxgl.maxParallelVectorTileRequests`

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 locating the existing `mapboxgl.maxParallelImageRequests` entry point and the code that schedules vector tile requests. Compare its behavior with the referenced TileQueue approach, then define how a vector-request limit should apply during animations and verify that excessive concurrent requests are prevented without missing tiles.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.