-
Notifications
You must be signed in to change notification settings - Fork 23
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
Global improvement for wasm_thread #13
Conversation
Thanks for the PR! 2nd and 3rd commits look good. However, I'm not sure about the global vars for setting URL and name prefix. Why not just use |
My use case for the 1st commit is that I'm plug-in wasm into a lib, and changing each thread builder was a pain, but I'm ok removing it |
But anyway, the js script doesn't work for workers in workers :/ |
I think you're right that mutable variable in a lib is bad |
I haven't used wasm/webworkers in a while so I'm trying to remember all the quirks. Now that I think about it, there isn't a usecase where you would use different wasm bindgen scripts (correct me) in the same binary without doing some really weird things. So it might make sense to setup configuration only once on startup and then have all the dependencies use the same configuration. I'll need some time to think about it. |
And to be honest, most worker.js are identical |
Okay, so instead of having separate So at the start of main, you could do: wasm_thread::Builder::default()
.wasm_bindgen_shim_url("somewhere/script.js")
.prefix("wasm_thread_")
.set_as_default(); Prefixing should work as such. Builder has two options: Btw, there is no need to introduce new dependencies for global variables, you could just do: Let me know what you think. If you agree, then update your first commit with these changes. Or revert it so I can merge the other two and I will implement the rest. |
I'll make a draft replacing my first commit & let me know if that ok for you :) |
@chemicstry I think it's close to what you want :) |
- Allowing user to have a fixed worker (worker.js), mainly used to spawn workers from workers - Allowing user to prefix all spawned worker
I repushed commit n°1 because it included a trash include |
Thanks! A tip for future: create separate PRs so that you don't have to rebase commits on each change, everything can be squashed during merge. It's also easier to review. |
Yeah, my bad! Thanks |
Could you ping me when you'll release it on crates.io ? :) Upgrading my Cargo.toml would be nice :) |
Yes, I want to do some refactoring and cleanup before releasing though. Will ping you once done. |
Very good |
@erwanvivien It turned out to be quite a large refactor, so could you check if #14 did not break anything for you? Also, I noticed that neither this nor any older version of the library works on newest google chrome. The |
@chemicstry I'll look into it! I didn't get notified for the message, I was looking for an update, so sorry for the delayed response |
@chemicstry In my company, we also have bugs using Wasm on GChrome 110 & 111, on canary (113) everything works just fine |
Looking into PR now, then testing |
First commit adds
script_path.js
doesn't workSecond commit adds
Third commit adds