react-native-vision-camera: 🐛 undefined symbol: RNWorklet::JsiWrapper
What were you trying to do?
Trying to build my project again – it worked this morning! All I did was try to use vision-camera-code-scanner with 3.0.0-rc3, and now I can’t go back. I’ve purged all my files, including node_modules, npm cache, gradle, and android build folder.
Here are the relevant libraries that make any difference: “@shopify/react-native-skia”: “^0.1.202”, “react”: “18.2.0”, “react-native”: “0.72.4”, “react-native-reanimated”: “3.4.2”, “react-native-vision-camera”: “3.0.0-rc.5”, “react-native-worklets-core”: “^0.2.0”,
Reproduceable Code
npx react-native start
What happened instead?
FAILURE: Build failed with an exception.
- What went wrong: Execution failed for task ‘:react-native-vision-camera:buildCMakeDebug[arm64-v8a]’.
com.android.ide.common.process.ProcessException: ninja: Entering directory `/home/matthew/dev/stackbayapp/node_modules/react-native-vision-camera/android/.cxx/Debug/j6t3e341/arm64-v8a’
Relevant log output
[12/14] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/java-bindings/JVisionCameraProxy.cpp.o
[13/14] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/VisionCameraProxy.cpp.o
[14/14] Linking CXX shared library ../../../../build/intermediates/cxx/Debug/j6t3e341/obj/arm64-v8a/libVisionCamera.so
FAILED: ../../../../build/intermediates/cxx/Debug/j6t3e341/obj/arm64-v8a/libVisionCamera.so
: && /home/matthew/programs/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=aarch64-none-linux-android21 --sysroot=/home/matthew/programs/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot -fPIC -O2 -frtti -fexceptions -Wall -Wno-unused-variable -fstack-protector-all -DSK_GL -DSK_GANESH -DSK_BUILD_FOR_ANDROID -g -fno-limit-debug-info -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Qunused-arguments -Wl,--no-undefined -shared -Wl,-soname,libVisionCamera.so -o ../../../../build/intermediates/cxx/Debug/j6t3e341/obj/arm64-v8a/libVisionCamera.so CMakeFiles/VisionCamera.dir/home/matthew/dev/stackbayapp/node_modules/react-native-vision-camera/cpp/JSITypedArray.cpp.o CMakeFiles/VisionCamera.dir/src/main/cpp/FrameHostObject.cpp.o CMakeFiles/VisionCamera.dir/src/main/cpp/FrameProcessorPluginHostObject.cpp.o CMakeFiles/VisionCamera.dir/src/main/cpp/JSIJNIConversion.cpp.o CMakeFiles/VisionCamera.dir/src/main/cpp/VisionCamera.cpp.o CMakeFiles/VisionCamera.dir/src/main/cpp/VisionCameraProxy.cpp.o CMakeFiles/VisionCamera.dir/src/main/cpp/skia/SkiaRenderer.cpp.o CMakeFiles/VisionCamera.dir/src/main/cpp/java-bindings/JFrame.cpp.o CMakeFiles/VisionCamera.dir/src/main/cpp/java-bindings/JFrameProcessor.cpp.o CMakeFiles/VisionCamera.dir/src/main/cpp/java-bindings/JFrameProcessorPlugin.cpp.o CMakeFiles/VisionCamera.dir/src/main/cpp/java-bindings/JHashMap.cpp.o CMakeFiles/VisionCamera.dir/src/main/cpp/java-bindings/JVisionCameraProxy.cpp.o CMakeFiles/VisionCamera.dir/src/main/cpp/java-bindings/JVisionCameraScheduler.cpp.o /home/matthew/programs/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/21/liblog.so -landroid /home/matthew/.gradle/caches/transforms-3/ed5971bff14b029db9d61e0025901397/transformed/jetified-react-android-0.72.4-debug/prefab/modules/jsi/libs/android.arm64-v8a/libjsi.so /home/matthew/.gradle/caches/transforms-3/ed5971bff14b029db9d61e0025901397/transformed/jetified-react-android-0.72.4-debug/prefab/modules/reactnativejni/libs/android.arm64-v8a/libreactnativejni.so /home/matthew/.gradle/caches/transforms-3/ed5971bff14b029db9d61e0025901397/transformed/jetified-react-android-0.72.4-debug/prefab/modules/folly_runtime/libs/android.arm64-v8a/libfolly_runtime.so /home/matthew/.gradle/caches/transforms-3/d2945effe2c76af5abf2618fac389cac/transformed/jetified-fbjni-0.3.0/prefab/modules/fbjni/libs/android.arm64-v8a/libfbjni.so -lGLESv2 -lEGL -ljnigraphics /home/matthew/dev/stackbayapp/node_modules/@shopify/react-native-skia/libs/android/arm64-v8a/libskia.a /home/matthew/dev/stackbayapp/node_modules/@shopify/react-native-skia/libs/android/arm64-v8a/libsvg.a /home/matthew/dev/stackbayapp/node_modules/@shopify/react-native-skia/libs/android/arm64-v8a/libskshaper.a -latomic -lm && :
ld: error: undefined symbol: RNWorklet::JsiWorkletContext::getWorkletRuntime()
>>> referenced by VisionCameraProxy.cpp:35 (/home/matthew/dev/stackbayapp/node_modules/react-native-vision-camera/android/src/main/cpp/VisionCameraProxy.cpp:35)
>>> CMakeFiles/VisionCamera.dir/src/main/cpp/VisionCameraProxy.cpp.o:(vision::VisionCameraProxy::~VisionCameraProxy())
>>> referenced by JFrameProcessor.cpp:39 (/home/matthew/dev/stackbayapp/node_modules/react-native-vision-camera/android/src/main/cpp/java-bindings/JFrameProcessor.cpp:39)
>>> CMakeFiles/VisionCamera.dir/src/main/cpp/java-bindings/JFrameProcessor.cpp.o:(vision::JFrameProcessor::callWithFrameHostObject(std::__ndk1::shared_ptr<vision::FrameHostObject> const&) const)
ld: error: undefined symbol: RNWorklet::JsiHostObject::JsiHostObject()
>>> referenced by WKTJsiWorklet.h:77 (/home/matthew/dev/stackbayapp/node_modules/react-native-worklets-core/android/build/headers/rnworklets/react-native-worklets-core/WKTJsiWorklet.h:77)
>>> CMakeFiles/VisionCamera.dir/src/main/cpp/VisionCameraProxy.cpp.o:(RNWorklet::JsiWorklet::JsiWorklet(facebook::jsi::Runtime&, facebook::jsi::Value const&))
>>> referenced by WKTJsiWorkletContext.h:31 (/home/matthew/dev/stackbayapp/node_modules/react-native-worklets-core/android/build/headers/rnworklets/react-native-worklets-core/WKTJsiWorkletContext.h:31)
>>> CMakeFiles/VisionCamera.dir/src/main/cpp/java-bindings/JFrameProcessor.cpp.o:(RNWorklet::JsiWorkletContext::getDefaultInstance())
ld: error: undefined symbol: RNWorklet::JsiHostObject::~JsiHostObject()
>>> referenced by WKTJsiWorklet.h:79 (/home/matthew/dev/stackbayapp/node_modules/react-native-worklets-core/android/build/headers/rnworklets/react-native-worklets-core/WKTJsiWorklet.h:79)
>>> CMakeFiles/VisionCamera.dir/src/main/cpp/VisionCameraProxy.cpp.o:(RNWorklet::JsiWorklet::JsiWorklet(facebook::jsi::Runtime&, facebook::jsi::Value const&))
>>> referenced by WKTJsiWorklet.h:74 (/home/matthew/dev/stackbayapp/node_modules/react-native-worklets-core/android/build/headers/rnworklets/react-native-worklets-core/WKTJsiWorklet.h:74)
>>> CMakeFiles/VisionCamera.dir/src/main/cpp/VisionCameraProxy.cpp.o:(RNWorklet::JsiWorklet::~JsiWorklet())
ld: error: undefined symbol: RNWorklet::JsiWrapper::wrap(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWrapper*)
>>> referenced by WKTJsiWrapper.h:62 (/home/matthew/dev/stackbayapp/node_modules/react-native-worklets-core/android/build/headers/rnworklets/react-native-worklets-core/WKTJsiWrapper.h:62)
>>> CMakeFiles/VisionCamera.dir/src/main/cpp/VisionCameraProxy.cpp.o:(RNWorklet::JsiWorklet::createWorklet(facebook::jsi::Runtime&, std::__ndk1::shared_ptr<facebook::jsi::Function>))
ld: error: undefined symbol: RNWorklet::JsiHostObject::get(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&)
>>> referenced by VisionCameraProxy.cpp
>>> CMakeFiles/VisionCamera.dir/src/main/cpp/VisionCameraProxy.cpp.o:(vtable for RNWorklet::JsiWorklet)
ld: error: undefined symbol: RNWorklet::JsiHostObject::set(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&, facebook::jsi::Value const&)
>>> referenced by VisionCameraProxy.cpp
>>> CMakeFiles/VisionCamera.dir/src/main/cpp/VisionCameraProxy.cpp.o:(vtable for RNWorklet::JsiWorklet)
ld: error: undefined symbol: RNWorklet::JsiHostObject::getPropertyNames(facebook::jsi::Runtime&)
>>> referenced by VisionCameraProxy.cpp
>>> CMakeFiles/VisionCamera.dir/src/main/cpp/VisionCameraProxy.cpp.o:(vtable for RNWorklet::JsiWorklet)
ld: error: undefined symbol: typeinfo for RNWorklet::JsiHostObject
>>> referenced by VisionCameraProxy.cpp
>>> CMakeFiles/VisionCamera.dir/src/main/cpp/VisionCameraProxy.cpp.o:(typeinfo for RNWorklet::JsiWorklet)
ld: error: undefined symbol: RNWorklet::JsiWorkletContext::invokeOnJsThread(std::__ndk1::function<void (facebook::jsi::Runtime&)>&&)
>>> referenced by JFrameProcessor.cpp:52 (/home/matthew/dev/stackbayapp/node_modules/react-native-vision-camera/android/src/main/cpp/java-bindings/JFrameProcessor.cpp:52)
>>> CMakeFiles/VisionCamera.dir/src/main/cpp/java-bindings/JFrameProcessor.cpp.o:(vision::JFrameProcessor::callWithFrameHostObject(std::__ndk1::shared_ptr<vision::FrameHostObject> const&) const)
>>> referenced by WKTJsiWorklet.h:358 (/home/matthew/dev/stackbayapp/node_modules/react-native-worklets-core/android/build/headers/rnworklets/react-native-worklets-core/WKTJsiWorklet.h:358)
>>> CMakeFiles/VisionCamera.dir/src/main/cpp/java-bindings/JFrameProcessor.cpp.o:(RNWorklet::WorkletInvoker::~WorkletInvoker())
ld: error: undefined symbol: RNWorklet::JsiWorkletContext::runtimeMappings
>>> referenced by __tree:0 (/home/matthew/programs/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/__tree:0)
>>> CMakeFiles/VisionCamera.dir/src/main/cpp/java-bindings/JFrameProcessor.cpp.o:(RNWorklet::WorkletInvoker::call(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long))
>>> referenced by __tree:0 (/home/matthew/programs/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/__tree:0)
>>> CMakeFiles/VisionCamera.dir/src/main/cpp/java-bindings/JFrameProcessor.cpp.o:(RNWorklet::WorkletInvoker::call(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long))
ld: error: undefined symbol: RNWorklet::JsiWorkletContext::invokeOnWorkletThread(std::__ndk1::function<void (RNWorklet::JsiWorkletContext*, facebook::jsi::Runtime&)>&&)
>>> referenced by WKTJsiWorklet.h:361 (/home/matthew/dev/stackbayapp/node_modules/react-native-worklets-core/android/build/headers/rnworklets/react-native-worklets-core/WKTJsiWorklet.h:361)
>>> CMakeFiles/VisionCamera.dir/src/main/cpp/java-bindings/JFrameProcessor.cpp.o:(RNWorklet::WorkletInvoker::~WorkletInvoker())
ld: error: undefined symbol: RNWorklet::JsiWorkletContext::defaultInstance
>>> referenced by memory:3887 (/home/matthew/programs/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/memory:3887)
>>> CMakeFiles/VisionCamera.dir/src/main/cpp/java-bindings/JFrameProcessor.cpp.o:(RNWorklet::JsiWorkletContext::getDefaultInstance())
>>> referenced by memory:3887 (/home/matthew/programs/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/memory:3887)
>>> CMakeFiles/VisionCamera.dir/src/main/cpp/java-bindings/JFrameProcessor.cpp.o:(RNWorklet::JsiWorkletContext::getDefaultInstance())
ld: error: undefined symbol: vtable for RNWorklet::JsiWorkletContext
>>> referenced by WKTJsiWorkletContext.h:31 (/home/matthew/dev/stackbayapp/node_modules/react-native-worklets-core/android/build/headers/rnworklets/react-native-worklets-core/WKTJsiWorkletContext.h:31)
>>> CMakeFiles/VisionCamera.dir/src/main/cpp/java-bindings/JFrameProcessor.cpp.o:(RNWorklet::JsiWorkletContext::getDefaultInstance())
>>> referenced by WKTJsiWorkletContext.h:31 (/home/matthew/dev/stackbayapp/node_modules/react-native-worklets-core/android/build/headers/rnworklets/react-native-worklets-core/WKTJsiWorkletContext.h:31)
>>> CMakeFiles/VisionCamera.dir/src/main/cpp/java-bindings/JFrameProcessor.cpp.o:(RNWorklet::JsiWorkletContext::getDefaultInstance())
>>> the vtable symbol may be undefined because the class is missing its key function (see https://lld.llvm.org/missingkeyfunction)
ld: error: undefined symbol: RNWorklet::JsiWorkletContext::~JsiWorkletContext()
>>> referenced by memory:2252 (/home/matthew/programs/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/memory:2252)
>>> CMakeFiles/VisionCamera.dir/src/main/cpp/java-bindings/JFrameProcessor.cpp.o:(std::__ndk1::__shared_ptr_emplace<RNWorklet::JsiWorkletContext, std::__ndk1::allocator<RNWorklet::JsiWorkletContext> >::~__shared_ptr_emplace())
>>> referenced by memory:2252 (/home/matthew/programs/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/memory:2252)
>>> CMakeFiles/VisionCamera.dir/src/main/cpp/java-bindings/JFrameProcessor.cpp.o:(std::__ndk1::__shared_ptr_emplace<RNWorklet::JsiWorkletContext, std::__ndk1::allocator<RNWorklet::JsiWorkletContext> >::~__shared_ptr_emplace())
ld: error: undefined symbol: RNWorklet::JsiWorkletContext::JsiWorkletContext(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, facebook::jsi::Runtime*, std::__ndk1::function<void (std::__ndk1::function<void ()>&&)>, std::__ndk1::function<void (std::__ndk1::function<void ()>&&)>)
>>> referenced by memory:2278 (/home/matthew/programs/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/memory:2278)
>>> CMakeFiles/VisionCamera.dir/src/main/cpp/java-bindings/JVisionCameraProxy.cpp.o:(vision::JVisionCameraProxy::JVisionCameraProxy(facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::HybridClass<vision::JVisionCameraProxy, facebook::jni::detail::BaseHybridClass>::JavaPart, facebook::jni::JObject, void>::_javaobject*> const&, facebook::jsi::Runtime*, std::__ndk1::shared_ptr<facebook::react::CallInvoker> const&, facebook::jni::basic_strong_ref<facebook::jni::detail::JTypeFor<facebook::jni::HybridClass<vision::JVisionCameraScheduler, facebook::jni::detail::BaseHybridClass>::JavaPart, facebook::jni::JObject, void>::_javaobject*, facebook::jni::GlobalReferenceAllocator> const&))
clang-12: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
C++ build system [build] failed while executing:
/home/matthew/programs/sdk/cmake/3.22.1/bin/ninja \
-C \
/home/matthew/dev/stackbayapp/node_modules/react-native-vision-camera/android/.cxx/Debug/j6t3e341/arm64-v8a \
VisionCamera
from /home/matthew/dev/stackbayapp/node_modules/react-native-vision-camera/android
Device
Android 12
VisionCamera Version
3.0.0-rc5
Additional information
- I am using Expo
- I have read the Troubleshooting Guide
- I agree to follow this project’s Code of Conduct
- I searched for similar issues in this repository and found none.
About this issue
- Original URL
- State: closed
- Created 10 months ago
- Comments: 42 (28 by maintainers)
I found the problem! Frame Processors are never being enabled, they can’t be, so they’re not being linked in.
In /android/CMakeLists.txt:
set(CMAKE_VERBOSE_MAKEFILE ON) set(PACKAGE_NAME “VisionCamera”) set(BUILD_DIR ${CMAKE_SOURCE_DIR}/build) set(CMAKE_VERBOSE_MAKEFILE ON) set(ENABLE_FRAME_PROCESSORS ON) <-------------------Need to add this line set(CMAKE_CXX_STANDARD 17)
Between that, and using the LATEST, BLEEDING EDGE VERSION of v3, I got my app to successfully build just now!
You need to use this version of Vision Camera: “react-native-vision-camera”: “github:mrousavy/react-native-vision-camera#4b009a0”,
I also updated my Babel config: module.exports = { presets: [‘module:metro-react-native-babel-preset’], plugins: [ [ ‘react-native-reanimated/plugin’, { globals: [‘__scanCodes’], }, ], [‘react-native-worklets-core/plugin’], ], };
I also REMOVED the Skia plugin, and disabled it using the new feature Mr. Rousavy put in:
/android/gradle.properties: VisionCamera_disableSkia=true VisionCamera_buildToolsVersion=33.0.0 VisionCamera_compileSdkVersion=33 VisionCamera_kotlinVersion=1.7.00 VisionCamera_targetSdkVersion=33 VisionCamera_ndkVersion=23.1.7779620 android.enableJetifier=true android.useAndroidX=true
I hope this helps others!
@DeveloperMCD Yes maybe I believe you but you still did not explain anything. I am not assuming that anybody is perfect here, you are misunderstanding me also. I am assuming that it should not be always ON because then why anyone would introduce it in the first place? However I tried your suggestion and I am able to build (however I was able to do it last time even without this change…) but now I got a runtime error, that Frame Processors are not enabled! Even if in the build logs it still says that they are enabled… How can you explain that?
I’m going to be “that guy” who says I fixed it, and hopefully not too many people reading this will say “I TRIED THAT – AND I’M STILL HAVING THE PROBLEM!” haha Here is the fix: Go in to node_modules/react-native-vision-camera/android/CMakeLists.txt and add a line at the top, so it looks like this:
set(CMAKE_VERBOSE_MAKEFILE ON) set(PACKAGE_NAME “VisionCamera”) set(BUILD_DIR ${CMAKE_SOURCE_DIR}/build) set(CMAKE_VERBOSE_MAKEFILE ON) set(ENABLE_FRAME_PROCESSORS ON) <----------- THIS LINE IS ADDED set(CMAKE_CXX_STANDARD 17)
You should then be able to build. Those errors above are clearly showing a failure to link Worklets Core in particular. This actually makes sense as a solution.
The problem for me was the minSdkVersion. I set it to 26 as in the example app and it seems to be working now.
“…someone is assuming based on rational things. How do you explain the reason of this variable existing if it always needs to have the value “ON” to make it build?”
It’s simple. MRousavy might have made a mistake somewhere upstream. A careless error. I consider it possible that he wrote 99 lines of perfect code but forgot the first line of code to set the whole ball rolling. It’s happened before to me. We all make mistakes.
BTW, I’m not saying that switch should always be set to on. I’m saying A) it fixes the issue and B) a real fix needs to be implemented, that properly sets it to ON as appropriate. But right now it is never being set, ever. Hence all the build errors everyone is experiencing.
Which is why I don’t assume anything going in to a troubleshooting adventure. You have to start with zero assumptions, verifying everything as you go. Eventually you find the problem.
Assuming MRousavy never makes a mistake is NOT “rational things” 😉 I’m sure Mr. Rousavy himself would agree. No one is exempt from making errors. We should never assume the author is perfect in his coding.
It might not be Windows only issue. I’m building my project on a Mac, but I’m encountering the same error.
@mrousavy What the heck. Today I reproduces the issue in the example app too.
I did not change anything I just hit “build/clean project” in Android Studio before a new build, otherwise it would just start the app instantly again.
@bglgwyng As I said before I scaffolded a brand new RN 0.72 project installed the needed packages and I instantly faced the error. As Marc suggested I tried running the Example app also with the exact same configuration I had before and it worked like a charm. Every dependency was updated and was still not working. So node was on latest 18.x version Androis Studio is latest possible everything. My project was still not working and the example app worked. So I tried to find what the heck is the difference between the two, and this was the only thing I found. I changed it after that it instantly worked in my project also.
If someone continues to have this problem with version 3.0.0, I recommend the following: Clone the original project from the main branch go to the package folder and do npm i -> npm run build copy the lib folder and paste it into the folder node_modules/react-native-vision-camera/ run again
This will update the version that is in main that is not yet as a release candidate, nor as a release version.
(To keep these changes I use patch package) npx patch-package react-native-vision-camera and follow the steps in the patch-package package
FAST STEP: If you want only the changes of patch-package copy this on your patches folder. (See the patch-package docs) react-native-vision-camera+3.0.0.patch