microsoft / react-native-windows

A framework for building native Windows apps with React.
https://microsoft.github.io/react-native-windows/
Other
16.37k stars 1.14k forks source link

ABI-safe JavaScript Engine API #4552

Open vmoroz opened 4 years ago

vmoroz commented 4 years ago

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:

NickGerleman commented 4 years ago

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.