Git Product home page Git Product logo

react-native-wasm's Introduction

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)

react-native-wasm's People

Contributors

mvayngrib avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.