openlayers / openlayers/openlayers
Modify interaction breaking map when using webworkers
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 12.6k
- Forks
- 3.2k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 21
Description
Describe the bug
I have used this example as the foundation for my code for getting WebWorkers working with loading Vector tiles into OpenLayers:
https://openlayers.org/en/latest/examples/offscreen-canvas.html
After adding Feature objects to the map, it works very well until I start adding interactions. When adding a Modify interaction (either before or adding the Vector tiles) the map stops working. CPU usage goes up and the map tab blows up.
The Feature objects are being added to a separate VectorLayer which is not being loaded by the web worker.
I have tested if this is actually an issue with using the Vector Tiles - it's not. If I add the Features and interactions to the map with the "Advanced Mapbox Vector Tiles" example everything works ok.
Also, if I delay the adding of the modify interaction by using setTimeout() the map tiles load OK but as soon as the function inside the setTimeout() function fires the map blows up and the browser tab crashes.
This seems that it is not actually the loading that is breaking. Instead, the map itself is breaking.
To Reproduce
This can be replicated by combining the following examples:
- https://openlayers.org/en/latest/examples/offscreen-canvas.html
- https://openlayers.org/en/latest/examples/regularshape.html
Instructions
- Start with this example: https://github.com/openlayers/openlayers/files/7507032/offscreen-canvas.txt
- Replace the contents of
offscreen-canvas.jsfile with the contents of the attachedoffscreen-canvas.txtfile. - See lines 263 - 281. Add/remove the modify interaction.
Expected behavior
When using a web worker to load the map tiles, a Modify interaction can be added to the amp without crashing the map.
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 with the offscreen-canvas example and attached offscreen-canvas.txt, especially lines 263–281, then compare with the regularshape example. Reproduce the crash by adding or removing the Modify interaction while loading Vector tiles in a web worker; done means the map continues loading and the browser tab does not crash.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100