react-native-reanimated
react-native-reanimated copied to clipboard
chore(Worklets): detect runtime initialization failures with experimental bundling
Summary
Throw a QoL error when something went wrong and we received a different error than expected during Worklet Runtime initialization when using experimental bundling.
I had to move reportFatalErrorOnJS to C++ to be able to invoke it on a wrong error. The changes are backwards compatible with legacy bundling.
Test plan
Enable experimental bundling as per instructions in packages/react-native-worklets/experimentalBundling.md and see that there are no crashes.
If a Worklet Runtime failed to initialize, you'll get the following error in JS now (I modified workletRuntimeEntry.ts to achieve those configurations of errors):
| Initialization failure of UI Runtime (sync invocation) | Initialization failure of Worklet Runtime (sync invocation) | Initialization failure of Worklet Runtime (spawned from the UI Thread, async invocation) |
|---|---|---|
For legacy bundling, throw an error in EmptyExample and see that it works just as before.