Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load the route snapper in a web worker #23

Closed
dabreegster opened this issue Nov 7, 2022 · 7 comments
Closed

Load the route snapper in a web worker #23

dabreegster opened this issue Nov 7, 2022 · 7 comments
Labels
enhancement New feature or request
Milestone

Comments

@dabreegster
Copy link
Contributor

Many perf improvements to the snap tool needed, but one short-term might be to do the initial load in a web worker. Otherwise the map loading will hang

@dabreegster
Copy link
Contributor Author

https://stackoverflow.com/questions/44118600/web-workers-how-to-import-modules/45578811#45578811
I'm stuck here, Firefox still doesn't have support...

@dabreegster
Copy link
Contributor Author

https://rustwasm.github.io/wasm-bindgen/examples/wasm-in-web-worker.html
Need no-modules and more workaround above

dabreegster added a commit that referenced this issue Nov 17, 2022
dabreegster added a commit that referenced this issue Nov 17, 2022
... doesn't work, we can't ship a WASM thing across the web worker
channels
@dabreegster
Copy link
Contributor Author

Argh, this is really annoying. I can do the expensive step of deserializing in a web worker, but the resulting JS/WASM magic blob can't be passed back to the main thread due to https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers#transferring_data_to_and_from_workers_further_details

@dabreegster
Copy link
Contributor Author

The only way I can think to make this work is to totally keep the route snapper in the web worker. Only communicate with it asynchronously by sending messages and awaiting responses. That's a much bigger change, going to shelve this for now

@Robinlovelace
Copy link
Contributor

Seems to work fine for me on Firefox in any case.

@dabreegster
Copy link
Contributor Author

https://acteng.github.io/atip/scheme.html?authority=Greater%20London#9.86/51.4737/-0.1634

Once the progress bar reaches the end (download is done), for me there's a noticeable ~13 second lag when you can't drag the map. We're deserializing and blocking the main thread. That's the problem I want to solve here

@Robinlovelace
Copy link
Contributor

Sounds like a bonus feature, still faster than the PCT and all client side so not too shabby for the largest region we have.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants