From 38199e2461cad53293c6006158b409966fdf8be2 Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Fri, 12 Jul 2024 13:11:40 +0200 Subject: [PATCH] fix: Fix not-found plugins crashing the app (#3076) * fix: Fix not-found plugins crashing the app * fix: Fix Example Plugin wrong name * Update VisionCameraProxy.cpp --- .../android/src/main/cpp/frameprocessors/VisionCameraProxy.cpp | 3 +++ .../main/java/com/mrousavy/camera/example/MainApplication.kt | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/package/android/src/main/cpp/frameprocessors/VisionCameraProxy.cpp b/package/android/src/main/cpp/frameprocessors/VisionCameraProxy.cpp index 6476bd1964..708ae86cd9 100644 --- a/package/android/src/main/cpp/frameprocessors/VisionCameraProxy.cpp +++ b/package/android/src/main/cpp/frameprocessors/VisionCameraProxy.cpp @@ -53,6 +53,9 @@ jsi::Value VisionCameraProxy::initFrameProcessorPlugin(jsi::Runtime& runtime, co auto options = JSIJNIConversion::convertJSIObjectToJNIMap(runtime, jsOptions); auto plugin = _javaProxy->cthis()->initFrameProcessorPlugin(name, options); + if (plugin == nullptr) { + return jsi::Value::undefined(); + } auto pluginHostObject = std::make_shared(plugin); return jsi::Object::createFromHostObject(runtime, pluginHostObject); diff --git a/package/example/android/app/src/main/java/com/mrousavy/camera/example/MainApplication.kt b/package/example/android/app/src/main/java/com/mrousavy/camera/example/MainApplication.kt index 12650b3771..e679623704 100644 --- a/package/example/android/app/src/main/java/com/mrousavy/camera/example/MainApplication.kt +++ b/package/example/android/app/src/main/java/com/mrousavy/camera/example/MainApplication.kt @@ -17,7 +17,7 @@ import com.mrousavy.camera.frameprocessors.FrameProcessorPluginRegistry class MainApplication : Application(), ReactApplication { companion object { init { - FrameProcessorPluginRegistry.addFrameProcessorPlugin("example") { proxy, args -> ExampleFrameProcessorPlugin(proxy, args) } + FrameProcessorPluginRegistry.addFrameProcessorPlugin("example_plugin") { proxy, args -> ExampleFrameProcessorPlugin(proxy, args) } FrameProcessorPluginRegistry.addFrameProcessorPlugin("example_kotlin_swift_plugin") { proxy, args -> ExampleKotlinFrameProcessorPlugin(proxy, args) } } }