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

Fix web-sys public agents and improve multithread web-sys #1006

Merged
merged 1 commit into from
Mar 10, 2020

Conversation

jstarry
Copy link
Member

@jstarry jstarry commented Mar 8, 2020

Problem

  • Web workers were not working in the web-sys multithread example project
  • No working example for web-sys web workers
  • wasm-bindgen tries to build ..._bg.wasm url but references document and therefore fails

Changes

  • Fix web-sys worker initialization by sending _bg.wasm url explicitly
  • Update gloo to github revision so that IntervalService works on workers for web_sys feature
  • Improve web-sys multithread example readme

@jstarry
Copy link
Member Author

jstarry commented Mar 8, 2020

@daxpedda @TheNeikos could you two please look over the changes in src/agent.rs? I noticed that wasm-bindgen tries to build the _bg.wasm link using document and so it needs to be worked around for workers

@daxpedda
Copy link
Contributor

I noticed that wasm-bindgen tries to build the _bg.wasm link using document and so it needs to be worked around for workers

I fixed it here: rustwasm/wasm-bindgen#2038.
But it is unrelated to us, because we are making a Blob, wasm-bindgen can't actually build the correct path anyway.
So the workaround is fine in my opinion.

@jstarry
Copy link
Member Author

jstarry commented Mar 10, 2020

I fixed it here: rustwasm/wasm-bindgen#2038.

Nice!

But it is unrelated to us, because we are making a Blob, wasm-bindgen can't actually build the correct path anyway.

Yes, exactly. I like the blob approach you added because it removes the need to have a simple js file which does that initialization

So the workaround is fine in my opinion.

Sweet, thanks for taking a look!

@jstarry jstarry merged commit 25b12d5 into yewstack:master Mar 10, 2020
@jstarry jstarry deleted the multithread-web-sys branch March 10, 2020 13:21
Comment on lines +1030 to +1033
self.onmessage = async (event) => {{
await initialized;
wasm_bindgen.child_entry_point(event.data);
}};"#,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, I was trying to figure out why we had a onmessage here, I couldn't figure it out, but in any case this code doesn't do anything.
If it does, but not in the example, it would error because wasm_bindgen.child_entry_point doesn't exist.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

#1013

nicklaswj pushed a commit to nicklaswj/yew that referenced this pull request Mar 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants