rinf icon indicating copy to clipboard operation
rinf copied to clipboard

From `wasm32-unknown-unknown` to `wasm32-wasi`

Open temeddix opened this issue 1 year ago • 3 comments

Report

Rinf does smoothly connect Flutter and Rust right now, but there's one clunky part left: the web.

On the web, with the curren target wasm32-unknown-unknown, many native functionalities including std::thread, std::time::Instant, std::fs are not working. This limitation prevents many crates like tokio and rayon from working on the web, leaving the vast majority of Rust ecosystem being fallen out from the web platform.

The goal is to use wasm32-wasi target for the web, so that users can use Rusts's thread, time, file, network APIs and various crates just like they do on native platforms. If we are able to compile Rust crates to wasm32-wasi, the JavaScript polyfill libraries will handle the rest, utilizing existing web APIs.

This is a tracking issue, as this goal cannot be achieved without community support.

  1. [ ] wasmer-js or browser_wasi_shim supports threads polyfill
    • https://github.com/wasmerio/wasmer-js/issues/332
  2. [ ] wasm-bindgen supports wasm32-wasi target
    • https://github.com/rustwasm/wasm-bindgen/issues/3421
    • https://github.com/rustwasm/wasm-bindgen/issues/3454
  3. [ ] wasm-pack supports wasm32-wasi target
    • https://github.com/rustwasm/wasm-pack/issues/654
  4. [ ] Migrate the Rinf codebase to wasm32-wasi target

Steps to Reproduce

Use any kind of system I/O functionalities on the web. It's very clunky, sometimes even panicking.

System Information

Not really relevant.

temeddix avatar Oct 26 '23 07:10 temeddix

  • https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Proposal.20for.20a.20new.20target.20.60wasm32-wasi-js.60/near/400363817
  • https://github.com/bytecodealliance/cargo-component
  • https://github.com/bytecodealliance/jco

temeddix avatar Nov 05 '23 16:11 temeddix

https://github.com/temeddix/jco-test

temeddix avatar Nov 06 '23 10:11 temeddix

jco might be used as our new JavaScript shim in the future:

  • https://github.com/bytecodealliance/jco/issues/246
  • https://github.com/bytecodealliance/jco/issues/247

temeddix avatar Nov 06 '23 16:11 temeddix