mapbox / mapbox/mapbox-gl-js

Avoid retaining GeoJSONSource data on main thread

Open
#3,220 1 comment 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

GeoJSONSource retains any data set via Map#addSource(...) or GeoJSONSource#setData in a _data member. This data is included in the serialized representation of the source, but as far as I can tell, that's unnecessary: the only thing that serialized sources are used for is style validation, which does not care about GeoJSON data.

Because the data is also passed to the worker, we are effectively doubling the memory requirements of GeoJSON sources. We could avoid creating a member variable, or set it to null after sending the data to the worker, which would eliminate this overhead.

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

Trace GeoJSONSource data flow from Map#addSource and GeoJSONSource#setData through the _data member and serialized representation. Check how serialized sources are used for style validation and how data is passed to the worker. Done means style validation still works without retaining the GeoJSON data on the main thread.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
performance
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.