Sharing StyleLayers between WorkerTiles is dangerous
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
`StyleLayer`s are shared between `WorkerTile`s, via the worker `StyleLayerIndex`. But `StyleLayer`s contain state consisting of the evaluated result of style properties at a certain zoom level, and `WorkerTile`s may have different zoom levels.
Currently, we avoid any issues that this shared state could cause by carefully calling `StyleLayer#recalculate` at the entry point to every async callback in `WorkerTile`. But this is relatively fragile and error prone, and also requires reevaluation of previously-evaluated properties.
A better solution would be to have each `WorkerTile` call `StyleLayer#recalculate` once for each necessary layer, and store the logical result state independently of any other `WorkerTile`s. This would likely require a significant refactor of the internals of style recalculation (refs #2739, #3044).
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
Start by reading the WorkerTile, StyleLayer, and worker StyleLayerIndex implementations to trace how shared layers and asynchronous callbacks use recalculated state. Compare the related discussions in issues #2739 and #3044, then define completion as each WorkerTile maintaining independent recalculation state without fragile callback-level reevaluation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- computer-graphics, frontend
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100