mrousavy / react-native-vision-camera

πŸ“Έ A powerful, high-performance React Native Camera library.
https://react-native-vision-camera.com
MIT License
6.72k stars 1k forks source link

πŸ› undefined symbol: RNWorklet::JsiWrapper #1708

Closed DeveloperMCD closed 9 months ago

DeveloperMCD commented 9 months ago

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.

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

tyanbiao commented 9 months ago

same error!

marouane-edghoughi commented 9 months ago

Same here πŸ‘πŸ»

DeveloperMCD commented 9 months ago

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!

Fabianurrutia commented 9 months ago

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

stemyke commented 9 months ago

@Fabianurrutia I got errors like this:

ld: error: undefined symbol: RNWorklet::JsiWorkletContext::getWorkletRuntime()

ld: error: undefined symbol: RNWorklet::JsiWorkletContext::invokeOnJsThread(std::__ndk1::function<void (facebook::jsi::Runtime&)>&&)

ld: error: undefined symbol: RNWorklet::JsiWorkletContext::runtimeMappings

ld: error: undefined symbol: RNWorklet::JsiWorkletContext::invokeOnWorkletThread(std::__ndk1::function<void (RNWorklet::JsiWorkletContext*, facebook::jsi::Runtime&)>&&)

ld: error: undefined symbol: RNWorklet::JsiWorkletContext::defaultInstance

ld: error: undefined symbol: RNWorklet::JsiHostObject::JsiHostObject()

ld: error: undefined symbol: vtable for RNWorklet::JsiWorkletContext

ld: error: undefined symbol: RNWorklet::JsiWorkletContext::~JsiWorkletContext()

ld: error: undefined symbol: RNWorklet::JsiWorkletContext::JsiWorkletContext(std::ndk1::basic_string<char, std::__ndk1::char_traits, std::ndk1::allocator > const&, facebook::jsi::Runtime*, std::ndk1::function<void (std::ndk1::function<void ()>&&)>, std::ndk1::function<void (std::ndk1::function<void ()>&&)>)

ld: error: undefined symbol: RNWorklet::JsiHostObject::~JsiHostObject()

ld: error: undefined symbol: RNWorklet::JsiWrapper::wrap(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWrapper*)

ld: error: undefined symbol: RNWorklet::JsiHostObject::get(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&)

ld: error: undefined symbol: RNWorklet::JsiHostObject::set(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&, facebook::jsi::Value const&)

ld: error: undefined symbol: RNWorklet::JsiHostObject::getPropertyNames(facebook::jsi::Runtime&)

ld: error: undefined symbol: typeinfo for RNWorklet::JsiHostObject

Do you have any idea?

This looke like the same as above. I encounter it even after applying your patch.

metrix-hu commented 9 months ago

@mrousavy Do you have any idea of what this could be? It is still a problem with 3.0.0

mrousavy commented 9 months ago

this is not a VisionCamera issue but a worklets issue. Clean yo cache

metrix-hu commented 9 months ago

@mrousavy What cache should I clear exactly? I tried this in a from scratch project also and have the same issue there.

mrousavy commented 9 months ago

hm can you reproduce it in the example app? make sure your environment is up to date with node, android studio, homebrew etc

metrix-hu commented 9 months ago

Can it be a problem with RN 0.72 (I use it in the new projet) or should it be compatible with it also?

metrix-hu commented 9 months ago

I use these versions in my build..gradle

ext { buildToolsVersion = "33.0.0" minSdkVersion = 21 compileSdkVersion = 33 targetSdkVersion = 33

    // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
    ndkVersion = "23.1.7779620"
}

Android studio and node is also up-to-date. I am on Windows 11.

metrix-hu commented 9 months ago

The problem for me was the minSdkVersion. I set it to 26 as in the example app and it seems to be working now.

bglgwyng commented 9 months ago

I've encountered the same issue in the past, but I was unable to determine a reliable way to replicate this build error. It appears that simply clearing the cache and reinstalling everything may have resolved the problem(not 100% certain). Could someone share the repository that triggers this error? I don't have one now.

bglgwyng commented 9 months ago

@metrix-hu Fortunately(?), I just faced this problem again and your solution(set minSdkVersion to 26) fixed my problem. Thanks! However, I'm not sure if it's a truly valid solution so that the same error never happens again under the current configuration. Could you offer some rationale behind your proposed solution?

metrix-hu commented 9 months ago

@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.

mrousavy commented 9 months ago

Ohhh, that's weird. Yea maybe it's because of minSdk, that has to be 26 for VisionCamera at least. Interesting catch guys. It is stated in the troubleshooting docs btw

metrix-hu commented 9 months ago

@mrousavy No way I am struggling with reanimated v3 couldnt make it because of a typescript error. Now I tried theirt latest nightly which needed a new native build, and now I got thies error again..

metrix-hu commented 8 months ago

@mrousavy What the heck. Today I reproduces the issue in the example app too.

image

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.

mrousavy commented 8 months ago

Maybe this is a Windows issue. I don't know. Sorry to ping you here, but @chrfalch - any thoughts?

metrix-hu commented 8 months ago

@mrousavy Maybe worklets core does some copying of files when building C++? I can see in Android Studio that the compilation of worklets-core and vision-camera happens in parallel, maybe that causes the problem?

chrfalch commented 8 months ago

Sounds really strange - would it be possible to test adding only the worklets library in an empty project @metrix-hu and see if you had any issues?

The library is found here: https://github.com/margelo/react-native-worklets-core.

A great test would even be to test its example app in your environment.

The only thing I could come up with in regards to Windows would have to be that referencing paths in CMakeLists.txt might be odd somehow?

metrix-hu commented 8 months ago

@chrfalch I tried the example app from react-native-worklets-core. After yarn installing it I opened the android folder inside the example folder, and here gradle sync failed with the following:

image

chrfalch commented 8 months ago

This looks strange to me - are we doing something wrong when we try to resolve paths to node_modules on windows, @mrousavy?

metrix-hu commented 8 months ago

@chrfalch You know what is also strange?

  1. I tried to scaffold a new project added worklets-core as dependency. Everything is worked like a charm here. Tried cleaning the project to ruin it and build it again it was still working.
  2. I added vision-camera also as a dependency. Tried to build the project but I run into the same error. Now I run the cleaning again and it solved the problem..
  3. After I tried to run the clean commands again in the main project too and strangely it built here again..

I still think that something is conflicting here that the two build processes are running in parallel, and now I just got lucky that worklets-core finished before than vision-camera needed the files..

mrousavy commented 8 months ago

@chrfalch this is how I get node_modules in VisionCamera:

https://github.com/mrousavy/react-native-vision-camera/blob/eddb01fda1cd4214a6159aba93133564c3220c55/package/android/build.gradle#L51-L64

This is how we do it in Worklets Core:

https://github.com/margelo/react-native-worklets-core/blob/94eaf5d828118510eae1ec16876ec384f856ebe2/android/build.gradle#L15-L28

Exactly the same lol. Maybe somewhere there's a /, which would not be working on Windows? Idk, I can take a look at this when I'm back home

bglgwyng commented 8 months ago

It might not be Windows only issue. I'm building my project on a Mac, but I'm encountering the same error.

DeveloperMCD commented 8 months ago

It is not a Windows issue. I only use Linux.

DeveloperMCD commented 8 months ago

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.

metrix-hu commented 8 months ago

@DeveloperMCD It looks like that line is already there after BUILD_DIR. Or I am confused what line exactly you are talking about.

It already looks like this for me:

image

metrix-hu commented 8 months ago

Oh you may talk about the ENABLE_FRAME_PROCESSORS one. I am not sure that is correct because it should be calculated based on if worklets-core is existing or not, right?

DeveloperMCD commented 8 months ago

Oh you may talk about the ENABLE_FRAME_PROCESSORS one. I am not sure that is correct because it should be calculated based on if worklets-core is existing or not, right?

It seems to never be calculated. Please show me where the variable "ENABLE_FRAME_PROCESSORS" is set. I'll wait :)

Engineers must never confuse "the way things should be, the way I assume they should be" with what actually exists in the code. Otherwise you'll never find any bugs. "Never assume."

metrix-hu commented 8 months ago

@DeveloperMCD You dont have to be so rude because 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? But look I searched it for you.

image

It should come from the build.gradle file as an argument. , where the value is based on the hasWorklets variable which is calculated by the worklets library existence. I am not really familiar how CMakeLists or things like this work exactly so lets ask @mrousavy again he is a lot smarter than me. The build script logs a lot than Frame Processors are enabled even without this line, there should be some reason for it. If this constant line is the solution, then why is it so random that it sometimes work and sometimes it doesnt?

DeveloperMCD commented 8 months ago

I wasn't being rude. You're having a misunderstanding based on differing cultures/generations. Words don't always come across as the typer intended them. Three people could read the exact same text, and take it in a completely different way. It's a classic flaw of text-based communication. I'll leave it at that.

DeveloperMCD commented 8 months ago

"...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.

metrix-hu commented 8 months ago

@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?

image

image

DeveloperMCD commented 8 months ago

Just for starters, I would run this code, or something similar to it for your operating system: cd rm -rf node_modules rm -rf android/build rm -f package-lock.json rm -rf ~/.gradle rm -rf ~/.npm

This would allow for a complete reset of the build process.

metrix-hu commented 8 months ago

What if I use yarn? And why would I remove lock files if we are not changing any package version here?

DeveloperMCD commented 8 months ago

Then do a full reset as per your operating system and particular build chain.

Also what does your Babel config look like? Mine is:

module.exports = { presets: ['module:metro-react-native-babel-preset'], plugins: [ [ 'react-native-reanimated/plugin', { globals: ['__scanCodes'], }, ], ['react-native-worklets-core/plugin'], ], };

I can't give you a full reason or explanation for what's going on with the Makefile. That will have to wait for MRousavy. I just know how I fixed it for my own particular case.

DeveloperMCD commented 8 months ago

One problem -- you need to get rid of Skia. MRousavy got rid of it completely when he released 3.0.0 a few days ago. I have it Skia disabled (plus absent) in my own project.

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

metrix-hu commented 8 months ago

@DeveloperMCD Thanks man for the effort and ideas you gave me. Sorry for my odd comments from yesterday I was so stressed out about this.. Now I started everything from scratch tried every combination, but unfortunately I still have the same problem as in my last comment. The build only works for me when I does not change anything and I got lucky in that moment and packages build in the correct order. Its so weird.

But in this case I still have an other runtime error..: https://github.com/mrousavy/react-native-vision-camera/issues/1776

KraljSamo commented 7 months ago

@metrix-hu Did you manage to fix the issue with Exception in HostFunction: system/frame-processor-unavailable: Frame processors are disabled!?

metrix-hu commented 7 months ago

@KraljSamo I tried with the latest version of VisionCamera v3 a few days ago and now everything works well so far with the frameprocessors.