WebAssembly support?
stephenemslie opened this issue · comments
Will jsc-android include WebAssembly support?
From what I can see, WebAssembly seems to be explicitly disabled in jsc-android, but appears to be supported by the current JavascriptCore. Is there any intention to remove the --no-webassembly
flag from jsc-android?
My own motivation is to run emscripten-compiled modules in react-native. Unfortunately they aren't performing well under emscripten's fallback to asm.js.
I'm looking for the same thing.
We're developing an app that shares a module that compiles to WASM with a web app, and we're avoiding native module cause of the inability to upgrade via CodePush.
Can you share some insights on what the performance hit is with asm.js?
@Ivshti With expo 33 releasing the new expo-random api, I've been experimenting with running libsodium.js under managed expo. Everything runs smoothy on the emulator, but on my device the app crashes without explanation as soon as require('libsodium-wrappers')
is called.
Running logcat
during the crash spits out a lot of noise, but turned this up:
06-24 11:40:02.339 685 685 E lowmemorykiller: Error writing /proc/18483/oom_score_adj; errno=22
From what I can see, the emscripten-compiled libsodium library is attempting to detect the WebAssembly
global, falling back to asm.js when that fails, and then consuming a lot of memory and getting killed by the OS. It's unclear to me whether the application is actually running out of memory or just dying while adjusting it's oom score (not sure why it's failing to write to oom_score_adj
), but either way it seems to be consuming a significant chunk of memory and dying.
I'd be curious to compare the wasm and asm.js memory usage on a browser to see if there's a big difference.
JSC's WebAssembly support relies on FTL JIT which we disabled for memory usage and binary size.
Did you ever try WebAssembly on RN iOS?
AFAIK, WebAssembly is not supported on JSC iOS.
My latest investigation is WebAssembly is supported on JSC iOS Device, but not on JSC iOS Emulator.
WebAssembly works on both JSC iOS Device and JSC iOS Emulator (for iOS 14).
It doesn't work on JSC Android at all.
ios 15.2 simulator works with webassembly but real device with the same version fails with “Can’t find variable: WebAssembly” any clue how to solve it?
That's so strange. AFAIK WebKit never removed support for WebAssembly. Why would it not be able to find WebAssembly...?
Isn’t JSC used by default? Is there any reason why Simulator and Real device would use something different?
I’ve seen a similar issue being commented here: https://forum.dfinity.org/t/making-http-calls-from-mobile-apps/5192/33
Yeah, JSC is used by default. I have no idea why they'd be different. Is your simulator also using iOS 15.2, or is it 15.3 or something else?
WebAssembly is definitely supported by Safari 15.2, which is the version of Safari that's bundled by default with iOS 15.2 https://webkit.org/blog/12140/new-webkit-features-in-safari-15-2/
I can't imagine they removed WebAssembly from the JS globals either. In fact, on stackoverflow, I can see other developers are indeed running wasm apps on iOS 15. Have you tried on a different iOS device by any chance? (I will try with one as well once I get a chance.)
I could not get my hands on another device yet, but I filed a report with Apple and this is their answer:
React-Native is using JavaScriptCore.framework, and it does not have JIT.
WebAssembly implementation requires JIT, so, if we would like to use it, please use WKWebView.
I could not get my hands on another device yet, but I filed a report with Apple and this is their answer:
React-Native is using JavaScriptCore.framework, and it does not have JIT. WebAssembly implementation requires JIT, so, if we would like to use it, please use WKWebView.
Wow, can you ask them why it works on iOS 14 but not 15? And why it works on iOS Simulator but not an iPhone device?
I'd be very curious to see a link to the report, if it's public. Thanks.
React-Native is using JavaScriptCore.framework, and it does not have JIT. WebAssembly implementation requires JIT, so, if we would like to use it, please use WKWebView.
this aligns to my understandings. for security reason, ios has W^X
protection for apps, so JIT and WebAssembly are not feasible (Safari or WKWebView are exception).
other reference: NativeScript/ios#89
That's strange. I've called WebAssembly from within RN JS on my iPhone SE (iOS 14.6) device in both debug and release mode, and it's worked.
I wonder if they added JIT support in iOS 14.2 and then removed it again in iOS 15?
EDIT: From reading that thread you linked, I think it might also be because my app was built using XCode for local development. Apparently once you send the final app to the App Store, then JIT permissions are removed...