From 4baf58429c78bcb004dd85259ed4af343db7a6a0 Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Mon, 28 Jun 2021 20:30:16 +0200 Subject: [PATCH] fix: Run `setFrameProcessor` after interactions have completed --- src/Camera.tsx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Camera.tsx b/src/Camera.tsx index afd1b4a..70cb041 100644 --- a/src/Camera.tsx +++ b/src/Camera.tsx @@ -1,5 +1,13 @@ import React from 'react'; -import { requireNativeComponent, NativeModules, NativeSyntheticEvent, findNodeHandle, NativeMethods, Platform } from 'react-native'; +import { + requireNativeComponent, + NativeModules, + NativeSyntheticEvent, + findNodeHandle, + NativeMethods, + Platform, + InteractionManager, +} from 'react-native'; import type { CameraDevice } from './CameraDevice'; import type { ErrorWithCause } from './CameraError'; import { CameraCaptureError, CameraRuntimeError, tryParseNativeCameraError, isErrorWithCause } from './CameraError'; @@ -363,7 +371,12 @@ export class Camera extends React.PureComponent { * @internal */ componentDidMount(): void { - if (this.props.frameProcessor != null) this.setFrameProcessor(this.props.frameProcessor); + const frameProcessor = this.props.frameProcessor; + if (frameProcessor != null) { + InteractionManager.runAfterInteractions(() => { + this.setFrameProcessor(frameProcessor); + }); + } } /**