Skip to content

ExodusMovement/react-native-wasm

Repository files navigation

desired usage

A true shim for the WebAssembly global would be best, but is probably impossible, due to the async nature of communcation with WebView

A nice second best would be an almost-shim, a la:

// load
const wasmModule = await WebAssembly.instantiateStreaming('/path/to/assets/somemodule.wasm')
// use as with WebAssembly, but everything's async
const result = await wasmModule.instance.exports.doSomething('hi', { blah: 'ho' })

potential approaches:

for now, it looks like async is enough

JS only vs JS + Native-side WebView manipulation

JS-only would be cleanest, but we may need additional control over the WebView, e.g. to make it load .wasm from local assets. Still need to experiment to see if fetch('/path/to/somemodule.wasm') can be made to work

alternatives to WASM

  • emscripten
  • convert wasm to JS with binaryen's experimental wasm2js. But at this point you might as well just use emscripten to convert to asm.js in the first place

iOS nonsense

How to load WASM

Questions

  • how to load WASM in WebView?
    • fetch() from local assets (so far unsuccessful)
    • load WASM from some server - requires being online, but can maybe be cached until next app upgrade
    • inline in HTML
    • inline in main bundle, send as base64 via postMessage. This sounds slow. Monero's wasm alone is a >1MB binary.
    • load from native-side (don't know if possible)

potentially useful tools / modules / SO questions

comlink module that creates a proxy object that works across postMessage. Will need proxy-polyfill

wkwebview (not exactly what's needed but could be helpful)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published