fix: Fix UI Thread race condition in setFrameProcessor(...)
(#265)
* fix: Fix UI Thread race condition in `setFrameProcessor(...)` * Revert "fix: Fix UI Thread race condition in `setFrameProcessor(...)`" This reverts commit 9c524e123cff6843d7d11db602a5027d1bb06b4b. * Use `setImmediate` to call `setFrameProcessor(...)` * Fix frame processor order of applying * Add `enableFrameProcessor` prop that defines if a FP is added * rename constant * Implement `enableFrameProcessor` prop for Android and make `frameProcessorFps` faster * link to troubleshooting guide * Update TROUBLESHOOTING.mdx * Add logs for use-cases * fix log * set initial frame processor in `onLayout` instead of `componentDidMount`
This commit is contained in:
@@ -20,9 +20,9 @@
|
||||
#import "JSConsoleHelper.h"
|
||||
|
||||
#ifdef VISION_CAMERA_DISABLE_FRAME_PROCESSORS
|
||||
static bool enableFrameProcessors = false;
|
||||
static bool VISION_CAMERA_ENABLE_FRAME_PROCESSORS = false;
|
||||
#else
|
||||
static bool enableFrameProcessors = true;
|
||||
static bool VISION_CAMERA_ENABLE_FRAME_PROCESSORS = true;
|
||||
#endif
|
||||
|
||||
@interface CameraBridge: RCTViewManager
|
||||
|
@@ -125,7 +125,7 @@ extension CameraView {
|
||||
captureSession.removeOutput(videoOutput)
|
||||
self.videoOutput = nil
|
||||
}
|
||||
if video?.boolValue == true {
|
||||
if video?.boolValue == true || enableFrameProcessor {
|
||||
ReactLogger.log(level: .info, message: "Adding Video Data output...")
|
||||
videoOutput = AVCaptureVideoDataOutput()
|
||||
guard captureSession.canAddOutput(videoOutput!) else {
|
||||
|
@@ -25,7 +25,8 @@ private let propsThatRequireReconfiguration = ["cameraId",
|
||||
"enablePortraitEffectsMatteDelivery",
|
||||
"preset",
|
||||
"photo",
|
||||
"video"]
|
||||
"video",
|
||||
"enableFrameProcessor"]
|
||||
private let propsThatRequireDeviceReconfiguration = ["fps",
|
||||
"hdr",
|
||||
"lowLightBoost",
|
||||
@@ -47,6 +48,7 @@ public final class CameraView: UIView {
|
||||
@objc var photo: NSNumber? // nullable bool
|
||||
@objc var video: NSNumber? // nullable bool
|
||||
@objc var audio: NSNumber? // nullable bool
|
||||
@objc var enableFrameProcessor = false
|
||||
// props that require format reconfiguring
|
||||
@objc var format: NSDictionary?
|
||||
@objc var fps: NSNumber?
|
||||
|
@@ -31,6 +31,7 @@ RCT_EXPORT_VIEW_PROPERTY(enablePortraitEffectsMatteDelivery, BOOL);
|
||||
RCT_EXPORT_VIEW_PROPERTY(photo, NSNumber); // nullable bool
|
||||
RCT_EXPORT_VIEW_PROPERTY(video, NSNumber); // nullable bool
|
||||
RCT_EXPORT_VIEW_PROPERTY(audio, NSNumber); // nullable bool
|
||||
RCT_EXPORT_VIEW_PROPERTY(enableFrameProcessor, BOOL);
|
||||
// device format
|
||||
RCT_EXPORT_VIEW_PROPERTY(format, NSDictionary);
|
||||
RCT_EXPORT_VIEW_PROPERTY(fps, NSNumber);
|
||||
|
@@ -23,7 +23,7 @@ final class CameraViewManager: RCTViewManager {
|
||||
#endif
|
||||
|
||||
// Install Frame Processor bindings and setup Runtime
|
||||
if enableFrameProcessors {
|
||||
if VISION_CAMERA_ENABLE_FRAME_PROCESSORS {
|
||||
CameraQueues.frameProcessorQueue.async {
|
||||
self.runtimeManager = FrameProcessorRuntimeManager(bridge: self.bridge)
|
||||
self.bridge.runOnJS {
|
||||
|
Reference in New Issue
Block a user