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

[WIP] wasm32 backend #99

Closed
wants to merge 2 commits into from
Closed

[WIP] wasm32 backend #99

wants to merge 2 commits into from

Conversation

jjl
Copy link

@jjl jjl commented May 9, 2020

I've thrown together an example harness to be able to test it (based on druid's) and i've made smol compile by effectively commenting out all the code with cfg.

Will eventually close #87.

I'll start actually implementing it now, but I thought it would be good to open a PR for tracking since a few people seem interested in contributing.

@jjl
Copy link
Author

jjl commented May 9, 2020

The last commit sketches a possible structure out. I've created a new 'WebExecutor' and I've replaced the innards of Task with a PhantomData on wasm, and removed everything but the ability to forget it.

I'm not sure how I feel about this. I don't personally use the task handles, so I'm not sure if this is likely to be problematic for some users.

@jjl jjl mentioned this pull request May 9, 2020
@ghost
Copy link

ghost commented May 14, 2020

Thank you for starting work on this!

Quick question: how are we going to implement timers and task spawning? What crate does provide that? (sorry, not super familiar with web)

We can implement task cancelation by using something like https://docs.rs/futures/0.3.5/futures/future/fn.abortable.html

@jjl
Copy link
Author

jjl commented May 14, 2020

Hiya,

So timers are pretty easy, they can just be the equivalent of window.setTimeout, task spawning is... more complicated...

  1. I discovered the wasm environment is not as single threaded as previously thought (though not yet as multithreaded as one would hope)
  2. I had some difficulties attempting to just delegate the work to the browser APIs. The error messages from wasm-bindgen are often less than spectacular so i'm not entirely sure why.

I had another play a few hours ago and my gut feeling is that we should actually do something similar to the rest of smol, except probably in the first instance it should be limited to the thread local executor because we can't really get the full benefit of multithreading. I actually tried to just reuse your thread local executor, but it depends on io_event, which looks not so easily disentangled (for a start, it wants Async...).

So the current avenue I'm looking at involves async-task and essentially replicating the local executor, without the dependence on the IO stuff.

I have no idea what I'm doing :)

@jjl
Copy link
Author

jjl commented May 14, 2020

Oh, and it's web-sys that has all the relevant browser apis, but the moment you have to actually pass data across the boundary it gets a bit tedious.

@jjl
Copy link
Author

jjl commented May 14, 2020

Oh, one more thing I should mention, I have been taking inspiration (although not too much of it) from wasm-bindgen-futures.

@ghost
Copy link

ghost commented May 14, 2020

Thank you for elaborating! I am currently working on untangling the reactor from the executor so this will soon become much easier.

@FuriouZz
Copy link

FuriouZz commented Jun 9, 2020

Maybe we can use WebWorker for multithreading tasks?

@kwek20
Copy link

kwek20 commented Oct 30, 2020

Hey @jjl whats the status on this?

@jjl
Copy link
Author

jjl commented Oct 30, 2020

@kwek20 I haven't done anything on it in a while, nor am I likely to in the rest of this year.

i expect the status of the wasm backend makes some of this a bit easier now than it did when i started, if you were interested in picking up where i left off. Although given smol has changed so much since then, not sure how much of it you'd want to salvage.

@notgull
Copy link
Member

notgull commented Dec 31, 2023

Closing this PR as it is far out of date with the current master and would likely require a significant rework. Thanks anyways @jjl!

See #87 for WASM progress on specific subcrates

@notgull notgull closed this Jan 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Wasm support
4 participants