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

WASM backend #25

Merged
merged 18 commits into from
Aug 7, 2019
Merged

WASM backend #25

merged 18 commits into from
Aug 7, 2019

Conversation

yoshuawuyts
Copy link
Member

@yoshuawuyts yoshuawuyts commented Aug 4, 2019

WIP wasm backend. Should work out of the box. A lot of changes here include changing our middleware and backends to "just work" in the browser.

Currently running into some problems where we can't use await and send JsObject's between threads, possibly related to rustwasm/wasm-bindgen#1695. Should probably spend more time figuring it out.

https://github.com/yoshuawuyts/surf/blob/b756107dfce8553a10c1bc1220ef627244b56b8a/src/http_client/wasm.rs#L33-L44

Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
@yoshuawuyts yoshuawuyts changed the title Wasm WASM backend Aug 4, 2019
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
@yoshuawuyts
Copy link
Member Author

Okay, into a bit of a corner here. Because:

  1. we can't send JS refs over Send bounds.
  2. threads aren't supported in WASM yet
  3. we shouldn't change the interface of our code just for WASM.

So I think we'll have to do a manual unsafe { impl Send for MyType } because threads don't exist in the browser yet, so we can't ever have multi-threaded problems anyway lmao.

Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
@ghost
Copy link

ghost commented Aug 5, 2019

I wonder what's the reason for JS refs not being sendable between threads. Do you think that's just an overly conservative measure in Rust's wasm bindings? Or is there a deeper reason truly preventing those values from being sendable?

Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
@yoshuawuyts
Copy link
Member Author

@stjepang Only JS vectors and strings can be sent over thread bounds (web workers). Rich data types such as DOM nodes have to be serialized / deserialized first. The Send bound is very real in this case.


This patch is good to go I think! We're using a whole lot of unwrap in the main code still tho, but I think that's just a matter of polishing. Going to open a separate issue for that.

@yoshuawuyts yoshuawuyts marked this pull request as ready for review August 6, 2019 10:03
@yoshuawuyts yoshuawuyts mentioned this pull request Aug 6, 2019
6 tasks
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
@yoshuawuyts
Copy link
Member Author

Okay, I kind of went off the rails here and started implementing parts of #26. In particular there's now an internal abstraction we could probably PR to gloo. I swear we're good for now, ahaha.

@yoshuawuyts
Copy link
Member Author

Going to go ahead and merge this!

@yoshuawuyts yoshuawuyts merged commit 00e5351 into master Aug 7, 2019
@delete-merged-branch delete-merged-branch bot deleted the wasm branch August 7, 2019 11:53
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.

1 participant