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

Full-featured async support in the web (WASM)? #6178

Closed
fzyzcjy opened this issue Nov 30, 2023 · 8 comments
Closed

Full-featured async support in the web (WASM)? #6178

fzyzcjy opened this issue Nov 30, 2023 · 8 comments
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. T-wasm Topic: Web Assembly

Comments

@fzyzcjy
Copy link
Contributor

fzyzcjy commented Nov 30, 2023

Is your feature request related to a problem? Please describe.

Hi, thanks for the helpful async runtime! When working on https://github.com/fzyzcjy/flutter_rust_bridge v2, more specifically the async Rust support, I realize that tokio's async does not have full features on the web.

https://docs.rs/tokio/latest/tokio/#wasm-support says that, rt is supported, but rt-multi-thread is not. However, it seems useful sometimes to leverage multi threads instead of only one thread.

There seems already exists ways to utilize multiple threads in WASM. For example, here is a "thread pool" example https://github.com/rustwasm/wasm-bindgen/blob/main/examples/raytrace-parallel/src/pool.rs. In flutter_rust_bridge, we also already utilize that code (with citations, surely) for a slightly more general purposed worker pool: https://github.com/fzyzcjy/flutter_rust_bridge/blob/6f3fa295d192a3945aab6c63ab6b533dc2aef2a9/frb_rust/src/wasm_bindgen_src/pool.rs. Memory seems also possible to be shared between workers via SharedArrayBuffer.

Therefore, I wonder whether tokio's async system will be full-featured in WASM in the future? Thanks!

Describe the solution you'd like
(see above)

Describe alternatives you've considered
(see above)

Additional context
(see above)

@fzyzcjy fzyzcjy added A-tokio Area: The main tokio crate C-feature-request Category: A feature request. labels Nov 30, 2023
@Darksonn Darksonn added the T-wasm Topic: Web Assembly label Nov 30, 2023
@Darksonn
Copy link
Contributor

I don't really know that much about wasm. Maybe in the future, but not right now.

It's also important to distinguish between web wasm and non-web wasm. It makes a difference whether we can block for extended durations of time.

@fzyzcjy
Copy link
Contributor Author

fzyzcjy commented Nov 30, 2023

Thank you!

It's also important to distinguish between web wasm and non-web wasm. It makes a difference whether we can block for extended durations of time.

I am not sure, but it seems that the web workers (which tokio may create) do not block the main thread.

@Darksonn
Copy link
Contributor

Darksonn commented Dec 3, 2023

Right. Ultimately, that just means there are three cases to distinguish between, not two. Wasi and web worker are not really the same in terms of what operations they expose as far as I understand.

@Darksonn
Copy link
Contributor

Darksonn commented Feb 2, 2024

Closing as duplicate of #4827.

@Darksonn Darksonn closed this as not planned Won't fix, can't repro, duplicate, stale Feb 2, 2024
@banocean
Copy link

banocean commented Feb 2, 2024

Tokio supports only what it can support without OS APIs that are exposed by, for example, WASI. WEB API doesn't cover anything close to that, so I'd consider it impossible.

@Darksonn Darksonn reopened this Feb 2, 2024
@Darksonn
Copy link
Contributor

Darksonn commented Feb 2, 2024

You're right, I've reopened this.

@Darksonn
Copy link
Contributor

Darksonn commented Oct 7, 2024

I'm going to close support for browser wasm as out of scope for Tokio.

Please see issue #4827 for other types of wasm.

@Darksonn Darksonn closed this as not planned Won't fix, can't repro, duplicate, stale Oct 7, 2024
@fzyzcjy
Copy link
Contributor Author

fzyzcjy commented Oct 7, 2024

I see, thank you all the same!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. T-wasm Topic: Web Assembly
Projects
None yet
Development

No branches or pull requests

3 participants