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

Question: WebAssembly support #107

Closed
ghost opened this issue Aug 13, 2018 · 10 comments
Closed

Question: WebAssembly support #107

ghost opened this issue Aug 13, 2018 · 10 comments

Comments

@ghost
Copy link

ghost commented Aug 13, 2018

Is WebAssembly supported on

  1. iOS
  2. Android

If supported, can you please comment on pthread support. See this for context - SharedArrayBuffer may cause issues for browsers, but enabling it in node for mobile should be perfectly safe as the sandboxing is done by the host OS (either iOS or Android)

@jaimecbernardo
Copy link
Member

Hi @writepubapp,

The iOS runtime is based on the ChakraCore engine, which at the version we currently have (node-chakracore 8.6.0) has WebAssembly disabled for cross-platform builds, so WebAssembly is not on in the released binary.

WebAssembly is working for Android, confirmed by trying to run this test: nodejs/node@74e7a4a

In terms of working features for WebAssembly, unit tests for WebAssembly features on node were added after the current fork version, so we don't have more in-depth information of what's working or not.

Please let us know if you give it a try and what results you have.

In terms of safety for mobile devices, it seems to have been disabled for Android mobile browsers as well. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer#Browser_compatibility (See implementation notes)
While not my area of expertise, so take it with a grain of salt, these sorts of attacks were able to sidestep the OS-provided sandbox features at the time they were discovered, since the exploits targeted the CPU. Security patches were issued for Android, which may not be applied by every vendor. https://security.googleblog.com/2018/01/todays-cpu-vulnerability-what-you-need.html
There's work being done now to also mitigate it on the browser side: https://www.chromium.org/Home/chromium-security/ssca

@ghost
Copy link
Author

ghost commented Aug 14, 2018

@jaimecbernardo - thank you for the detailed response.

  1. Does your roadmap for iOS include enabling WASM?
  2. As for enabling sharedArrayBuffer, browsers need to execute un-trusted code from the open wild-web. I believe enabling sharedArrayBuffers for the back-end on trusted code from the app store is (in my opinion) safe. Maybe you can make this a run-time option for app developers?

Thank you for all the clarifications. Great product!

Cheers

@jaimecbernardo
Copy link
Member

Hi @writepubapp ,

  1. WASM seems to have been turned on by default on more recent node-chakracore versions, so it should come as an engine update, unless there's some reason we may need to disable it (if it depends on JIT, that's not allowed in iOS, for example).
  2. It's hard to tell right now. From the source you shared, it seems that there will be engine flags to enable the feature, so in that case those will be available to pass when starting node.

Thank you! I hope this is helpful.

@ghost ghost closed this as completed Aug 16, 2018
@mjp0
Copy link

mjp0 commented Mar 5, 2019

Any news regarding this? I've a project where I need to compute en/decryption with nodejs and I'm already grinding my teeth about how much pain it will be performance-wise. WASM could help with these types of workloads a lot.

@jaimecbernardo
Copy link
Member

Hi @markopolojarvi , This can be re-evaluated once the update to 10.x LTS hits: #156

@notatestuser
Copy link

Hey everyone. Now that this release has happened, WebAssembly still does not appear to be available in iOS. It would be great to be able to use WebAssembly in the node environment!

@jaimecbernardo
Copy link
Member

Hi @notatestuser,

On iOS, WebAssembly is not supported yet, since ChakraCore currently enables WASM only if running on x86/x86_64 and JIT is enabled. This didn't change with the 10.x LTS release.

https://github.com/janeasystems/nodejs-mobile/blob/2101f2096d59d2a081f64da2f10fd7385222ac8a/deps/chakrashim/core/lib/Common/CommonDefines.h#L714-L722

@notatestuser
Copy link

notatestuser commented Sep 23, 2019 via email

@navneetgulati
Copy link

Hey Any updates on wether web Assembly will be available on iOS. Or if not can anyone point me to some alternative for webAssembly.

@jaimecbernardo
Copy link
Member

Even on V8, WebAssembly functionalities depend on JIT being enabled. And iOS Guidelines forbid use of JIT.

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

No branches or pull requests

4 participants