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

Error: Unable to bind Webassembly to React Native JSI., js engine: hermes #28

Open
greynewell opened this issue Apr 5, 2024 · 9 comments

Comments

@greynewell
Copy link

greynewell commented Apr 5, 2024

Hello there, @cawfree! First of all, incredible work on this library - I'm hoping it'll help me solve a very relevant problem for a project I'm working on to enable Matrix.org JS SDK in React Native Expo: https://github.com/greynewell/example-expo-matrix-js-sdk/issues/2

I'm attempting to load some Rust crypto cyphers into the React Native runtime to support end-to-end encryption using your WASM binding, and getting the following error when I try:

ERROR  Error: Unable to bind Webassembly to React Native JSI., js engine: hermes 
    at ContextNavigator (http://<MY_IP:PORT>/node_modules/expo-router/entry.bundle//&platform=ios&dev=true&hot=false&lazy=true&transform.engine=hermes&transform.bytecode=true&transform.routerRoot=app:148978:24)
    at ExpoRoot (http://<MY_IP:PORT>/node_modules/expo-router/entry.bundle//&platform=ios&dev=true&hot=false&lazy=true&transform.engine=hermes&transform.bytecode=true&transform.routerRoot=app:148934:28)
    at App
    at ErrorToastContainer (http://<MY_IP:PORT>/node_modules/expo-router/entry.bundle//&platform=ios&dev=true&hot=false&lazy=true&transform.engine=hermes&transform.bytecode=true&transform.routerRoot=app:378338:24)
    at ErrorOverlay
    at withDevTools(ErrorOverlay) (http://<MY_IP:PORT>/node_modules/expo-router/entry.bundle//&platform=ios&dev=true&hot=false&lazy=true&transform.engine=hermes&transform.bytecode=true&transform.routerRoot=app:377872:27)
    at RCTView
    at View (http://<MY_IP:PORT>/node_modules/expo-router/entry.bundle//&platform=ios&dev=true&hot=false&lazy=true&transform.engine=hermes&transform.bytecode=true&transform.routerRoot=app:40346:43)
    at RCTView
    at View (http://<MY_IP:PORT>/node_modules/expo-router/entry.bundle//&platform=ios&dev=true&hot=false&lazy=true&transform.engine=hermes&transform.bytecode=true&transform.routerRoot=app:40346:43)
    at AppContainer (http://<MY_IP:PORT>/node_modules/expo-router/entry.bundle//&platform=ios&dev=true&hot=false&lazy=true&transform.engine=hermes&transform.bytecode=true&transform.routerRoot=app:40157:36)
    at main(RootComponent) (http://<MY_IP:PORT>/node_modules/expo-router/entry.bundle//&platform=ios&dev=true&hot=false&lazy=true&transform.engine=hermes&transform.bytecode=true&transform.routerRoot=app:123933:28)

I'm not quite sure what the issue might be, but could you help me get pointed in the right direction? I've tried reinstalling, prebuilding, restarting the simulator, testing on a real device, and just about everything else I can think of.

@greynewell
Copy link
Author

@greynewell
Copy link
Author

After binding WebAssembly from this lib to global.WebAssembly, output looks more like this while loading libolm (which is presumably using the global WebAssembly provided by this lib):

 DEBUG  Crypto: Starting up crypto store...
 DEBUG  Crypto: initialising roomlist...
 DEBUG  Crypto: initialising crypto object...
 DEBUG  Crypto: initialising Olm...
 WARN  Aborted(no native wasm support detected)
 ERROR  no native wasm support detected

I am unsure if I've simply bound your implementation wrong or what, but there are also type errors when comparing between this implementation and the global.WebAssembly object - not sure if that's related, though.

@rayan1810tria
Copy link

@greynewell were you able to fix this?

@nitesh-habilelabs
Copy link

@greynewell i am also trying to integrate matrix into my react native app. can you please let me know if you were able to fix this webassembly issue?

i am using legacy olm version to bypass the wasm part but i am unable to make my session verified and unable to decrypt the message or able to create encrypted room from my app.

although i am able to send message in an encrypted room but it shows that “encrypted message was sent from an unverified or deleted device”

any help is highly appreciated. Thank you.

@nitesh-habilelabs
Copy link

@greynewell were you able to fix this?

hi, did you find anything regarding e2ee encryption and decryption in react native app for matrix?

@greynewell
Copy link
Author

FWIW, I am no longer working on the project where this mattered to me. I am leaving this open for the others who have experienced the same issue.

@cawfree
Copy link
Owner

cawfree commented Jul 5, 2024

It looks like a pretty generic error. Has anyone tried running the example?

@ghost
Copy link

ghost commented Sep 2, 2024

It doesn't work for me either - I added WebAssembly according to instructions and try to load a rust crypto library for matrix, however, it fails with some generic error like:
(NOBRIDGE) ERROR WebAssembly test failed: [Error: Expected string, encountered symbol.]

Here's the code I'm using for testing:

if (typeof global.WebAssembly === 'undefined') {
  global.WebAssembly = WebAssembly;
}

console.log(global.WebAssembly)

const testWebAssembly = async () => {
  try {
    const {
      data: bufferSource,
    } = await axios({
      url: 'https://github.com/torch2424/wasm-by-example/raw/master/examples/hello-world/demo/assemblyscript/hello-world.wasm',
      method: 'get',
      responseType: 'arraybuffer',
    });
    
    const module = await WebAssembly.instantiate(bufferSource);
    console.log('WebAssembly test passed:', module, module.instance.exports.add(1, 2));
    
  } catch (error) {
    console.error('WebAssembly test failed:', error);
  }
};

testWebAssembly();

@myarete
Copy link

myarete commented Sep 16, 2024

Running pod install inside the ios folder manually fixed this for me (after expo prebuild --platform ios). I'm using a development client on the latest expo version.

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

No branches or pull requests

5 participants