react-native-windows icon indicating copy to clipboard operation
react-native-windows copied to clipboard

ABI-safe JavaScript Engine API

Open vmoroz opened this issue 5 years ago • 1 comments

Currently RNW could use different JavaScript engines: Hermes, V8, Chakra. As we go towards the DLL-based deployment we must make decision about the relationship between the Microsoft.ReactNative.dll and JavaScript engines. Since the JavaScript engines are compiled outside of the Microsoft.ReactNative.dll toolchain we must make sure that the interaction is done in an ABI safe way. E.g. use of Chakra engine is ABI safe because we always use it through the Chakra's C-style ABI safe API. For the V8 and Hermes engines we do not have ABI-safe APIs. It means that use of these engines with Microsoft.ReactNative.dll is not safe and subject to random crashes due to incompatibilities in MSVC CRT libraries.

We must make a decision that we either:

  • Use only Chakra JavaScript engine
  • Add ABI-safe on top of V8 and Hermes engines.
    • For V8 one of the options could be use of NAPI subset (Node.js API).
    • For Hermes we must write an API that supports "tunneling" of the JSI API.

vmoroz avatar Apr 09 '20 21:04 vmoroz

Another option that I've liked in the past is to sidestep the issue and try to build the core DLL and engines with the same version of Clang. Building the Core DLL with Clang/LLVM let's us get ABI compatibility with V8/Hermes with Clang (V8 no longer officially supports MSVC) assuming the same version is used when we build Hermes and V8jsi. Chakra is already ABI safe.

Assuming the core DLL exposes ABI safe interfaces this should be doable where other native modules, view managers use msvc.

The secondary motivation is that we frequently see msvc specific bugs pop up in changes to stock React Native. Building Yoga, stock RN, etc with Clang would make our lives easier.

NickGerleman avatar Apr 10 '20 01:04 NickGerleman