I'm trying migrate some critical loops to Web Workers, as they need to process many points, and I can't have the page unresponsive or even crash the browser.
These loops are used to go through all points and create the respective leaflet objects (eg: L.circle, Generate MaskCanvas layers) for future use, as they get loaded for the current bounding box. These points, and its information and Leaflet object are stored on TaffyDB.
In the migration process I've found that Web Workers don't have access to the window, document and parent global objects. Even though I can bypass the window is undefined error by assigning the self object as self.window, in the Web Worker.
It would be useful to be able to use utility functions that don't require the map, to generate leaflet objects, and don't require window or document.
It would be useful to be able to use utility functions that don't require the map, to generate leaflet objects.
This wouldn't help. You can't transfer the Leaflet objects from a Worker to the main execution context -- they depend on having the right object prototype, which isn't preserved by structured cloning.
Basically, you can do mathematical / algorithmic work on the Worker, and transfer the resulting data, but it's not going to help with object creation.
Most helpful comment
This wouldn't help. You can't transfer the Leaflet objects from a Worker to the main execution context -- they depend on having the right object prototype, which isn't preserved by structured cloning.
Basically, you can do mathematical / algorithmic work on the Worker, and transfer the resulting data, but it's not going to help with object creation.