fix: Delay frame processor setting on Android by 300ms

This commit is contained in:
Marc Rousavy 2021-06-28 20:39:16 +02:00
parent 4baf58429c
commit 2f95ecc67f

View File

@ -18,6 +18,9 @@ import type { Point } from './Point';
import type { TakeSnapshotOptions } from './Snapshot'; import type { TakeSnapshotOptions } from './Snapshot';
import type { RecordVideoOptions, VideoFile } from './VideoFile'; import type { RecordVideoOptions, VideoFile } from './VideoFile';
// a custom delay to wait for after `componentDidMount` because view initialization takes longer on Android.
const NATIVE_VIEW_INIT_DELAY = Platform.OS === 'android' ? 300 : 0;
//#region Types //#region Types
export type CameraPermissionStatus = 'authorized' | 'not-determined' | 'denied' | 'restricted'; export type CameraPermissionStatus = 'authorized' | 'not-determined' | 'denied' | 'restricted';
export type CameraPermissionRequestResult = 'authorized' | 'denied'; export type CameraPermissionRequestResult = 'authorized' | 'denied';
@ -373,9 +376,9 @@ export class Camera extends React.PureComponent<CameraProps> {
componentDidMount(): void { componentDidMount(): void {
const frameProcessor = this.props.frameProcessor; const frameProcessor = this.props.frameProcessor;
if (frameProcessor != null) { if (frameProcessor != null) {
InteractionManager.runAfterInteractions(() => { setTimeout(() => {
this.setFrameProcessor(frameProcessor); this.setFrameProcessor(frameProcessor);
}); }, NATIVE_VIEW_INIT_DELAY);
} }
} }