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 Support #138

Open
commial opened this issue Dec 29, 2022 · 1 comment
Open

WASM Support #138

commial opened this issue Dec 29, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@commial
Copy link
Contributor

commial commented Dec 29, 2022

Supporting a WASM version of MLA would be nice.
For instance, it would allow the support of:

  • in-the-browser opening of compressed and encrypted HTML reports
  • a platform agnostic GUI (in the browser)

Targeting WASM in Rust has some requirements. This issue is made to track them.


For now, compiling to WASM WASI is working:

# Compile to WASI
$ cd mlar
$ cargo build --target=wasm32-wasi --release

# Get the resulting `wasm` file
$ cd /workspace/MLA/target/wasm32-wasi/release/
$ file mlar.wasm 
mlar.wasm: WebAssembly (wasm) binary module version 0x1 (MVP)

# Execute it using `wasmtime` (file access is sandboxed)
$ wasmtime  mlar.wasm list -i /workspaces/MLA/samples/archive_v1.mla -k /workspaces/MLA/samples/test_x25519_archive_v1.pem
...
[ERROR]
...
failed to find a pre-opened file descriptor
...

# Allow accesses to the source directory
$ wasmtime --dir /workspaces/MLA/samples/  mlar.wasm list -i /workspaces/MLA/samples/archive_v1.mla -k /workspaces/MLA/samples/test_x25519_archive_v1.pem | head
big
file_0
file_1
file_10
file_100
file_101
file_102
...
@commial commial added the enhancement New feature or request label Dec 29, 2022
@extiop
Copy link

extiop commented Nov 22, 2024

As of today, Rust glue, to enable Wasm interactions in the browser, to web components can made with polyfills from the well-known wasm-bindgen toolchain such as :

Also, there is WASI which aims to be an ABI standard for Wasm thus running anywhere (https://wasi.dev/). WASI 0.2 preview (https://bytecodealliance.org/articles/WASI-0.2) is stable enough to be used in browsers with jco transpiler (https://bytecodealliance.org/articles/jco-1.0) which is a native JavaScript WebAssembly toolchain and runtime built for WebAssembly Components (cf. https://component-model.bytecodealliance.org/design/why-component-model.html) and WASI 0.2 preview.

Thereby, we need to evaluate the need to interact with WebIDL and JS in a Wasm version of MLA which targets in-the-browser opening of compressed and encrypted HTML reports, thus a browser GUI.

Then, options are :

  • The GUI interaction (WebIDL or JS) could be incorporated in Rust, thus importing JS functions : this one is not preferred as web languages are well-suited for web design and scripting for the moment (thus the GUI).
  • MLA could be imported as a Wasm module and used in a HTML / JS GUI without the need to import JS functions on the Rust side. Still there will be HTML / JS interaction. Two suboptions :

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants