Unhandled promise rejection: ReferenceError: Can't find variable: WebAssembly
seyaobey-dev opened this issue · 1 comments
Description
In my react-native + expo
app (ios 15.1), I'm carefully following the javascript readme file instructions. I have installed @openmined/psi.js
and react-native-get-random-values
. Then I initialise the code as following:
import 'react-native-get-random-values';
import PSI from '@openmined/psi.js/combined_wasm_web';
(async () => {
// Spoof the browser document
global.document = {} as any;
// Wait for the library to initialize
const psi = await PSI();
const client = psi.client!.createWithNewKey();
//...
})();
When I start the app, I get the error:
no native wasm support detected
Unhandled promise rejection: ReferenceError: Can't find variable: WebAssembly
It works fine on android.
How to Reproduce
- Create new react-native + expo app:
expo init my_app
- install
@openmined/psi.js
andreact-native-get-random-values
- Add following code in file
App.tsx
:
import 'react-native-get-random-values';
import PSI from '@openmined/psi.js/combined_wasm_web';
(async () => {
// Spoof the browser document
global.document = {} as any;
// Wait for the library to initialize
const psi = await PSI();
const client = psi.client!.createWithNewKey();
//...
})();
- See error
Expected Behavior
App should start without error
Screenshots
System Information
- OS: IOS 15.1
- react-native: 0.64.3
- expo: 44
- node: v14.18.1
- npm: 8.3.0
Hey @seyaobey-dev, it turns out this library by itself, will not work with react-native directly. This is because JSC doesn't natively support WebAssembly. To work around it, you'd need to load the library in a WebView and build a bridge between it and your main application code. Think something similar to: https://github.com/inokawa/react-native-react-bridge