Avoid retaining GeoJSONSource data on main thread
Nobody has claimed this yet.
- 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
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
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