We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I'm trying to read file main.wasm with WebAssembly.instantiate() and get function add() . But got this error:
main.wasm
Error: Exception in HostFunction: function lookup failed
File main.wasm build with go:
Go code:
package main import ( "fmt" "syscall/js" ) func add(this js.Value, inputs []js.Value) interface{} { a := inputs[0].Float() b := inputs[1].Float() return a + b } func main() { fmt.Println("Hello world!") ch := make(chan struct{}, 0) js.Global().Set("add", js.FuncOf(add)) <-ch }
Build wasm file and linking custom assets to iOS and Android project:
GOOS=js GOARCH=wasm go build -o main.wasm cd ../ react-native-asset
Code of js in React-Native:
import * as WebAssembly from 'react-native-webassembly'; import {Dirs, FileSystem} from 'react-native-file-access'; import {Base64Url} from './src/base64url'; async function wasmTest() { const src = `${Dirs.MainBundleDir}`; const result = await FileSystem.readFile(`${src}/main.wasm`, "base64") // console.log('result', result); const buffer = Base64Url.toBuffer(result); console.log('buffer', buffer.length); const module = await WebAssembly.instantiate<{ add: (a: number, b: number) => number; }>(new Uint8Array(buffer)); const secondResult = module.instance.exports.add(300, 200); console.log('second result = ', secondResult); }
The text was updated successfully, but these errors were encountered:
Sounds like it was unable to find the functions we expect the Wasm to.
I'm unfamiliar with the formatting of this file - can you confirm that it works within a different runtime than react-native-webassembly?
react-native-webassembly
Sorry, something went wrong.
No branches or pull requests
I'm trying to read file
main.wasm
with WebAssembly.instantiate() and get function add() . But got this error:File
main.wasm
build with go:Go code:
Build wasm file and linking custom assets to iOS and Android project:
GOOS=js GOARCH=wasm go build -o main.wasm cd ../ react-native-asset
Code of js in React-Native:
Versions
The text was updated successfully, but these errors were encountered: