Closed fedpre closed 1 year ago
version 3.0.0-rc10
fixed the problem for me
version
3.0.0-rc10
fixed the problem for me
Still getting the issue. If I disable the frame processor, I am able to build the app. That's a strange error too that I couldn't find any answer online.
Encountered the same issue, but it turns out that I forgot to update some configs:
Note: Take a look at this issue first. (I used patch-package for this one)
index.js
import 'react-native-reanimated';
import 'react-native-worklets-core/src'; // for frame processor with react-native-vision-camera@^3.0.0
import {AppRegistry} from 'react-native';
import {GestureHandlerRootView} from 'react-native-gesture-handler';
import {persistor, store} from './src/store';
import {Provider} from 'react-redux';
import {PersistGate} from 'redux-persist/integration/react';
import App from './src/App';
import {name as appName} from './app.json';
const Root = () => (
<GestureHandlerRootView style={{flex: 1}}>
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<App />
</PersistGate>
</Provider>
</GestureHandlerRootView>
);
AppRegistry.registerComponent(appName, () => Root);
babel.config.js
module.exports = api => {
const babelEnv = api.env();
const plugins = [
['react-native-worklets-core/plugin'], // this one
['react-native-reanimated/plugin'],
['@babel/plugin-transform-optional-chaining'],
];
//change to 'production' to check if this is working in 'development' mode
if (babelEnv !== 'development') {
plugins.push(['transform-remove-console', {exclude: ['error', 'warn']}]);
}
return {
presets: ['module:metro-react-native-babel-preset'],
plugins,
};
};
Based on react-native-worklets-core setup.
"react-native": "0.72.4",
"react-native-reanimated": "^3.4.2",
"react-native-vision-camera": "^3.0.0",
"react-native-worklets-core": "^0.2.0"
I am now in doubt if I actually did the fix through the process above. After testing something like updating and installing other packages and even deleting the
node_modules
folder, the issue came back :man_facepalming:.Did some cleaning like:
$ ./gradlew clean
But it failed again. It's kinda weird though cause I was able to build it even in prod without the last change :laughing:
Oh, adding this set(ENABLE_FRAME_PROCESSORS ON)
in node_modules/react-native-vision-camera/android/CMakeLists.txt
without using patch-package actually works fine.
project(VisionCamera)
cmake_minimum_required(VERSION 3.9.0)
set(ENABLE_FRAME_PROCESSORS ON)
set(CMAKE_VERBOSE_MAKEFILE ON)
...
After adding set(ENABLE_FRAME_PROCESSORS ON)
to CMakeLists.txt I'm getting this error.
without frameProcessor prop everything works fine, I think there is an issue with react-native-worklets-core.
"react-native-vision-camera": "3.0.0-rc.10",
"react-native-worklets-core": "^0.2.0",
"react-native": "0.72.0",
"react-native-reanimated": "^3.4.2",
babel.config.js
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [
['react-native-reanimated/plugin'],
['react-native-worklets-core/plugin'],
],
};
In my experience, set(ENABLE_FRAME_PROCESSORS ON)
actually disables the the frameprocessors instead of enabling them. This is why the build succeed as none of the worklets-core code is imported. The actual problem seemed to be that the CMake is not able to find the worklets-core library during the linking phase (at least for me the actual clang command did not include the worklets-core built library). This can be fixed by adding the direct path to the android/CMakeLists.txt file:
# Link everything together
target_link_libraries(
${PACKAGE_NAME}
${LOG_LIB} # <-- Logcat logger
android # <-- Android JNI core
ReactAndroid::jsi # <-- RN: JSI
ReactAndroid::reactnativejni # <-- RN: React Native JNI bindings
ReactAndroid::folly_runtime # <-- RN: For casting JSI <> Java objects
fbjni::fbjni # <-- fbjni
--->"${NODE_MODULES_DIR}/react-native-worklets-core/android/build/intermediates/cmake/debug/obj/${ANDROID_ABI}/librnworklets.so"
)
I think that there might be a cleaner way to do this but I found that this will work so left it at that.
Be sure to remove the set(ENABLE_FRAME_PROCESSORS ON)
if trying this.
@karri-lehtiranta could you please send your CMakeLists.txt ?
project(VisionCamera)
cmake_minimum_required(VERSION 3.9.0)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(PACKAGE_NAME "VisionCamera")
set(BUILD_DIR ${CMAKE_SOURCE_DIR}/build)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_CXX_STANDARD 17)
# Folly
include("${NODE_MODULES_DIR}/react-native/ReactAndroid/cmake-utils/folly-flags.cmake")
add_compile_options(${folly_FLAGS})
# Third party libraries (Prefabs)
find_package(ReactAndroid REQUIRED CONFIG)
find_package(fbjni REQUIRED CONFIG)
find_library(LOG_LIB log)
find_package(react-native-worklets-core REQUIRED CONFIG)
add_definitions(-DVISION_CAMERA_ENABLE_FRAME_PROCESSORS=${ENABLE_FRAME_PROCESSORS} -DVISION_CAMERA_ENABLE_SKIA=${ENABLE_SKIA})
# Add react-native-vision-camera sources
add_library(
${PACKAGE_NAME}
SHARED
../cpp/JSITypedArray.cpp
src/main/cpp/FrameHostObject.cpp
src/main/cpp/FrameProcessorPluginHostObject.cpp
src/main/cpp/JSIJNIConversion.cpp
src/main/cpp/VisionCamera.cpp
src/main/cpp/VisionCameraProxy.cpp
src/main/cpp/skia/SkiaRenderer.cpp
src/main/cpp/java-bindings/JFrame.cpp
src/main/cpp/java-bindings/JFrameProcessor.cpp
src/main/cpp/java-bindings/JFrameProcessorPlugin.cpp
src/main/cpp/java-bindings/JHashMap.cpp
src/main/cpp/java-bindings/JVisionCameraProxy.cpp
src/main/cpp/java-bindings/JVisionCameraScheduler.cpp
)
# Header Search Paths (includes)
target_include_directories(
${PACKAGE_NAME}
PRIVATE
"../cpp"
"src/main/cpp"
"${NODE_MODULES_DIR}/react-native/ReactCommon"
"${NODE_MODULES_DIR}/react-native/ReactCommon/callinvoker"
"${NODE_MODULES_DIR}/react-native/ReactAndroid/src/main/jni/react/turbomodule" # <-- CallInvokerHolder JNI wrapper
)
# Link everything together
target_link_libraries(
${PACKAGE_NAME}
${LOG_LIB} # <-- Logcat logger
android # <-- Android JNI core
ReactAndroid::jsi # <-- RN: JSI
ReactAndroid::reactnativejni # <-- RN: React Native JNI bindings
ReactAndroid::folly_runtime # <-- RN: For casting JSI <> Java objects
fbjni::fbjni # <-- fbjni
"${NODE_MODULES_DIR}/react-native-worklets-core/android/build/intermediates/cmake/debug/obj/${ANDROID_ABI}/librnworklets.so"
)
# Optionally also add Frame Processors here
if(ENABLE_FRAME_PROCESSORS)
find_package(react-native-worklets-core REQUIRED CONFIG)
target_link_libraries(
${PACKAGE_NAME}
react-native-worklets-core::rnworklets
)
message("VisionCamera: Frame Processors enabled!")
# Optionally also add Skia Integration here
if(ENABLE_SKIA)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSK_GL -DSK_GANESH -DSK_BUILD_FOR_ANDROID")
find_package(shopify_react-native-skia REQUIRED CONFIG)
set(SKIA_PACKAGE shopify_react-native-skia::rnskia)
set(RNSKIA_PATH ${NODE_MODULES_DIR}/@shopify/react-native-skia)
set (SKIA_LIBS_PATH "${RNSKIA_PATH}/libs/android/${ANDROID_ABI}")
add_library(skia STATIC IMPORTED)
set_property(TARGET skia PROPERTY IMPORTED_LOCATION "${SKIA_LIBS_PATH}/libskia.a")
add_library(svg STATIC IMPORTED)
set_property(TARGET svg PROPERTY IMPORTED_LOCATION "${SKIA_LIBS_PATH}/libsvg.a")
add_library(skshaper STATIC IMPORTED)
set_property(TARGET skshaper PROPERTY IMPORTED_LOCATION "${SKIA_LIBS_PATH}/libskshaper.a")
# We need to include the headers from skia
# (Note: rnskia includes all their files without any relative path
# so for example "include/core/SkImage.h" becomes #include "SkImage.h".
# That's why for the prefab of rnskia, we flatten all cpp files into
# just one directory. HOWEVER, skia itself uses relative paths in
# their include statements, and so we have to include the path to skia)
target_include_directories(
${PACKAGE_NAME}
PRIVATE
"${RNSKIA_PATH}/cpp/skia"
"${RNSKIA_PATH}/cpp/skia/include/config/"
"${RNSKIA_PATH}/cpp/skia/include/core/"
"${RNSKIA_PATH}/cpp/skia/include/effects/"
"${RNSKIA_PATH}/cpp/skia/include/utils/"
"${RNSKIA_PATH}/cpp/skia/include/pathops/"
"${RNSKIA_PATH}/cpp/skia/modules/"
# "${RNSKIA_PATH}/cpp/skia/modules/skparagraph/include/"
"${RNSKIA_PATH}/cpp/skia/include/"
"${RNSKIA_PATH}/cpp/skia"
)
target_link_libraries(
${PACKAGE_NAME}
GLESv2 # <-- Optional: OpenGL (for Skia)
EGL # <-- Optional: OpenGL (EGL) (for Skia)
${SKIA_PACKAGE} # <-- Optional: RN Skia
jnigraphics
skia
svg
skshaper
)
message("VisionCamera: Skia enabled!")
endif()
endif()
The worklets-core import should probably be under if(ENABLE_FRAME_PROCESSORS) but didn't try that as this version worked.
Thank you @karri-lehtiranta I will try
finally fixed with this line
"${NODE_MODULES_DIR}/react-native-worklets-core/android/build/intermediates/cmake/debug/obj/${ANDROID_ABI}/librnworklets.so"
Hey - this should be fixed with the latest update in VisionCamera V3 (๐ฅณ) - if not, please create a new issue.
If your issue has been fixed, consider sponsoring me on GitHub to say thanks ๐
I have seen similar build errors in RN Worklets cc @chrfalch
finally fixed with this line
"${NODE_MODULES_DIR}/react-native-worklets-core/android/build/intermediates/cmake/debug/obj/${ANDROID_ABI}/librnworklets.so"
It's necessery now?
Wait whats wrong with that line?
I think this could be a PR to RN Worklets Core to fix it cleaning up, no?
finally fixed with this line
"${NODE_MODULES_DIR}/react-native-worklets-core/android/build/intermediates/cmake/debug/obj/${ANDROID_ABI}/librnworklets.so"
It's necessery now?
I tried this and it works. But after opening the camera with frameprocessor it crashed.
package.json
"dependencies": { "react": "18.2.0", "react-native": "0.72.5", "react-native-reanimated": "^3.5.4", "react-native-vision-camera": "^3.2.2", "react-native-worklets-core": "^0.2.1" },
babel.config.js
module.exports = { presets: ['module:metro-react-native-babel-preset'], plugins: [ ['react-native-worklets-core/plugin'], 'react-native-reanimated/plugin', ], };
Crash log is below
@BuiHung1612 this is a different issue, follow https://github.com/mrousavy/react-native-vision-camera/issues/1776
@mrousavy I'm getting the same issue here. Using v3 and React Native 0.72.
> Task :react-native-vision-camera:compileDebugKotlin
'compileDebugJavaWithJavac' task (current target is 11) and 'compileDebugKotlin' task (current target is 1.8) jvm target compatibility should be set to the same Java version.
I saw you're defining JavaVersion.VERSION_1_8
in build.gradle
. Why is that so? I'm using latest version of Expo and some of its libraries are requiring at least version 11.
Hello @nnabinh , I've had the same problem since the last version. Have you found a solution? :)
thanks
same problem Invalid value for "PACKAGE_PATH": Directory "/Users/ombogdan/Projects/WebstormProjects/ReactNative/mobile/node_modules/react-native-worklets-core/android/build/intermediates/prefab_package_configuration/debug/prefab" is not readable.
I am facing the same error here
'compileDebugJavaWithJavac' task (current target is 11) and 'compileDebugKotlin' task (current target is 1.8) jvm target compatibility should be set to the same Java version.
@RP-alissonpaschoal This worked for me: https://github.com/mrousavy/react-native-vision-camera/issues/1547#issuecomment-1787296748
How were you trying to build the app?
I tried to build my app on Android with
npx react-native run-android
and it fails.Full build logs
Project dependencies
Target platforms
Android
Operating system
MacOS
Can you build the VisionCamera Example app?
Additional information