feat: Make Reanimated optional (disable Frame Processors if REA v2 is not installed) (#412)
* Fix building iOS without Reanimated * Conditionally compile Frame Processors (gradle) * Conditionally use externalNativeBuild * Remove Reanimated import * fix: Conditionally load REA/VisionCamera libraries * fix: Add disable FP to docs * fix: Fix dummy placeholder for Scheduler.mm * fix: Fix dummy `Scheduler` declaration * fix: Only init `CameraView` C++ side if frame processors are enabled * fix: Install JSI Bindings on Frame Processor Manager ctor * fix: Wrong conditional * whoops
This commit is contained in:
@@ -25,7 +25,7 @@ public:
|
||||
|
||||
public:
|
||||
Frame* frame;
|
||||
|
||||
|
||||
private:
|
||||
void assertIsFrameStrong(jsi::Runtime& runtime, const std::string& accessedPropName);
|
||||
};
|
||||
|
@@ -25,6 +25,7 @@
|
||||
#import <RNReanimated/RuntimeManager.h>
|
||||
#import <RNReanimated/RuntimeDecorator.h>
|
||||
#import <RNReanimated/REAIOSErrorHandler.h>
|
||||
#import "VisionCameraScheduler.h"
|
||||
#define ENABLE_FRAME_PROCESSORS
|
||||
#else
|
||||
#warning Your react-native-reanimated version is not compatible with VisionCamera, Frame Processors are disabled. Make sure you're using reanimated 2.2.0 or above!
|
||||
@@ -36,7 +37,6 @@
|
||||
|
||||
#import "FrameProcessorUtils.h"
|
||||
#import "FrameProcessorCallback.h"
|
||||
#import "VisionCameraScheduler.h"
|
||||
#import "../React Utils/MakeJSIRuntime.h"
|
||||
#import "../React Utils/JSIUtils.h"
|
||||
|
||||
@@ -153,7 +153,7 @@ __attribute__((objc_runtime_name("_TtC12VisionCamera10CameraView")))
|
||||
|
||||
dispatch_async(CameraQueues.frameProcessorQueue, [=]() {
|
||||
NSLog(@"FrameProcessorBindings: Converting worklet to Objective-C callback...");
|
||||
|
||||
|
||||
auto& rt = *runtimeManager->runtime;
|
||||
auto function = worklet->getValue(rt).asObject(rt).asFunction(rt);
|
||||
|
||||
|
@@ -8,18 +8,30 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#import <RNReanimated/Scheduler.h>
|
||||
#include <functional>
|
||||
#import <React-callinvoker/ReactCommon/CallInvoker.h>
|
||||
|
||||
#if __has_include(<RNReanimated/RuntimeManager.h>)
|
||||
#import <RNReanimated/Scheduler.h>
|
||||
#else
|
||||
// dummy placeholder
|
||||
namespace reanimated {
|
||||
class Scheduler {
|
||||
public:
|
||||
virtual void scheduleOnUI(std::function<void()> job);
|
||||
protected:
|
||||
std::shared_ptr<facebook::react::CallInvoker> jsCallInvoker_;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace vision {
|
||||
|
||||
using namespace facebook;
|
||||
|
||||
class VisionCameraScheduler : public reanimated::Scheduler {
|
||||
public:
|
||||
VisionCameraScheduler(std::shared_ptr<react::CallInvoker> jsInvoker);
|
||||
VisionCameraScheduler(std::shared_ptr<facebook::react::CallInvoker> jsInvoker);
|
||||
virtual ~VisionCameraScheduler();
|
||||
|
||||
|
||||
void scheduleOnUI(std::function<void()> job) override;
|
||||
};
|
||||
|
||||
|
@@ -18,9 +18,9 @@ __attribute__((objc_runtime_name("_TtC12VisionCamera12CameraQueues")))
|
||||
@end
|
||||
|
||||
namespace vision {
|
||||
|
||||
|
||||
using namespace facebook;
|
||||
|
||||
|
||||
VisionCameraScheduler::VisionCameraScheduler(std::shared_ptr<react::CallInvoker> jsInvoker) {
|
||||
this->jsCallInvoker_ = jsInvoker;
|
||||
}
|
||||
@@ -34,6 +34,6 @@ void VisionCameraScheduler::scheduleOnUI(std::function<void()> job) {
|
||||
|
||||
VisionCameraScheduler::~VisionCameraScheduler(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace vision
|
||||
|
Reference in New Issue
Block a user