Comments (5)
Looking at the PR I'm guessing that you figured out the answer to your questions, if there's anything that still needs my help let me know. We can continue the discussion in the PR or here, which ever works better for you.
I rewrote the entire actor communication layer, so it should be fairly easy to use it to send a message and get the response back with data.
from maplibre-gl-js.
The only issue I can think of is the requirement to move the update process into the tile generation in the worker.
i.e. in theory, in the future we want all the manipulation logic of the tiles to happen in the worker and all the data to be stored in something that might not be easy to extract the information from.
Currently the data is duplicated: one copy in the worker is in the tiles and the other copy in an in-memory variable.
Having said that, there's no real progress to move all the logic of update into the tile generation as it requires changes to the geojson-vt package, which chances of seeing this happen are low right now.
To be on the safe side I would recommend getting the data from the worker so that we consider the worker data as the source of truth, and in the future see if we can facilitate getting the data on one hand while keeping on a single copy on the other.
I hope that make sense, if not, let me know.
Otherwise, I don't see any issues with this proposal.
from maplibre-gl-js.
The only issue I can think of is the requirement to move the update process into the tile generation in the worker.
Sounds to me like a separate task.
Currently the data is duplicated: one copy in the worker is in the tiles and the other copy in an in-memory variable.
I guess it's the _data
field I talk about in the OP. And yes, there's a line which updates it in setData
, but there's no such line in updateData
, which is expected since in the case with updateData
the diff
is sent to the worker, not the real "parsed" data. So it seems to me that
- this
_data
field is redundant (I don't really see any usages of it in the main thread code) - even if it's not redundant, it's not updated in
updateData
, so the code shouldn't rely on it anyway.
Given all that, there currently is a single source of truth: data inside the worker.
To be on the safe side I would recommend getting the data from the worker so that we consider the worker data as the source of truth
Exactly. I think there's no other option anyway.
The question, however, is how. Trying to dive deeper into the source code, but I'm getting confused with between-threads communication.
I can see that the main thread sends requests to the worker thread using the sendAsync
method of actor
. But how should I send the data back? Should it also be the same (or a similar one) call? Or maybe there's some events-based mechanism?
Namely, what I'm talking about, is the following:
here's the _updateWorkerData
method (which is called from either setData
and updateData
):
maplibre-gl-js/src/source/geojson_source.ts
Line 315 in 3d0f0db
then it calls (
maplibre-gl-js/src/source/geojson_source.ts
Line 328 in 3d0f0db
this.actor.sendAsync
to send some data to the worker thread.
My question is, whether there's an example somewhere of a vice-versa process? Where a worker needs to send data back to the main thread?
Another thing. There are events like sourcedata
which happen after the source data gets updated. Should I do anything about them? Like listening to that event to be fired before responding to the main thread with GeoJSON?
And is it OK for the getData
method to be async? As I understnand, it must be, since there is communication in-between threads going on. It's also the case with setData
and updateData
, but those are not async because 1) interaction is events-based and 2) it doesn't really matter when the data gets set/updated, as we don't really want to do anything with it.
from maplibre-gl-js.
Another question that came to my mind is what happens if the data is big? So the worker message have a size limit? Is paging needed in that case?
from maplibre-gl-js.
Another question that came to my mind is what happens if the data is big? So the worker message have a size limit? Is paging needed in that case?
That's a good question. Didn't think of it as I didn't even know there are limitations regarding the message size. I'll try to check what happens in such cases. Thanks for pointing that out.
from maplibre-gl-js.
Related Issues (20)
- Strange results of `raster-contrast` paint property HOT 3
- Id missing on MapGeoJsonFeature on map.on('click', layerid, event) HOT 2
- App using terrain (raster-dem) crashes when zooming out after zooming in quickly HOT 3
- Raster tiles are much lower detail when terrain is enabled HOT 12
- How to use raster source with varying zoom levels? HOT 7
- standard-minifier-js of Meteor.js remove Promise HOT 2
- Map freeze if easeTo during move event HOT 7
- Missing documentation: Popup Constructor and PopupOptions
- on load method: Occasionally the load method does not trigger a callback HOT 17
- MapLibre stops responding with weird, seemingly unrelated error message HOT 2
- Sustitute placeholder images from placekitten.com
- Ability to modify the map background HOT 1
- setLayoutProperty trigger blink of map layer HOT 2
- Add the actual projection matrix to transform HOT 5
- Is it time to move to ES2017 and how HOT 4
- preserveDrawingBuffer and marker dragging breaks down rendering HOT 2
- Geojson Circle broken / even on example page HOT 4
- Extrusion line geometry HOT 4
- Map makes unnecessary repeated requests against a source's tile HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from maplibre-gl-js.