Build fails when using @react-native-community/javascriptcore instead of Hermes
Description
Starting from react-native version 0.80 javascript core was removed as a runtime, and instead @react-native-community/javascriptcore is suggested to use. For performance reasons we need to do that, but this is incompatible with react-native-reanimated.
The build fails with a CMake error related to ReactAndroid::jsctooling.
Expected Behavior
App should build and run successfully using @react-native-community/javascriptcore instead of Hermes.
Actual Behavior Build fails with the following CMake errors:
Execution failed for task ':react-native-reanimated:configureCMakeDebug[arm64-v8a]'.
CMake Error at src/main/cpp/worklets/CMakeLists.txt:16 (add_library):
Target "worklets" links to target "ReactAndroid::jsctooling" but the target
was not found.
Perhaps a find_package() call is missing for an IMPORTED target,
or an ALIAS target is missing?
CMake Error at src/main/cpp/reanimated/CMakeLists.txt:10 (add_library):
Target "reanimated" links to target "ReactAndroid::jsctooling" but the target
was not found.
This seems to be the result from: https://github.com/software-mansion/react-native-reanimated/blob/bddcfc8ba92bc3fc836719ab81750db0af673b38/packages/react-native-worklets/android/CMakeLists.txt#L107
react-native removed jsctooling for external jsc versions with https://github.com/facebook/react-native/pull/49365
This is also an issue with the New Architecture enabled and react-native-reanimated version 4.
How do you make react-native-reanimated work with @react-native-community/javascriptcore?
Any help or suggestions would be greatly appreciated!
Steps to reproduce
- Download the repository created from the following steps:
a. Create a React Native Comunity CLI project.
b. Install
@react-native-community/javascriptcoreand update Gradle files. c. Installreact-native-reanimated. - Run the app:
npx react-native run-android. - Observe the build failure during the CMake configuration step in
react-native-reanimated.
Snack or a link to a repository
https://github.com/emjeku/test-react-native-reanimated-with-jsc-community
Reanimated version
3.19.3
Worklets version
React Native version
0.81.4
Platforms
Android
JavaScript runtime
JSC
Workflow
React Native CLI
Architecture
Legacy Architecture (Paper renderer)
Reanimated feature flags
No
React Native release level
Stable
Build type
Debug app & dev bundle
Device
Real device
Host machine
Linux
Device model
Samsung Galaxy A51 Android 13
Acknowledgements
Yes
What could we try to get it working? Would @react-native-community/javascriptcore need to re-add the tooling, or could rn-reanimated get a fix to work without it?
Probably build.gradle or CMakeLists.txt configurations must be amended because the names of the packages/targets changed. PRs are welcome!
I face the same. Any resolve?
JSC is still needed for intensive computations, do we have a way to make it works ?
I fixed this issue by enabling hermes in gradle.properties. If you encounter performance issues, simply update your react-native-reanimated to 4.1.0
"react-native": "0.81.1",
"react-native-reanimated": "4.1.0",
"react-native-worklets": "0.5.0",
I fixed this issue by enabling hermes in gradle.properties.
That's the only thing we cannot do. React-native team thought it was a good idea to keep hermes but until very recently JSON parsing was taking 3x time than JSC. So for persisting data and database calls we cannot have a 300% regression by using hermes unfortunately and everyone is pushing us to choose a very slow JS engine (hopefully it will be nearly as fast in few month)
That's the only thing we cannot do.
Same for us - in our case it is the horrific performance with promises, which apparently is improved with the static hermes, but for now this is incompatible with a different dependency