From f1e42f3bac3ffb5482be150b7cd42043a9426d27 Mon Sep 17 00:00:00 2001 From: Henry Heino <46334387+personalizedrefrigerator@users.noreply.github.com> Date: Mon, 8 Sep 2025 02:55:48 -0700 Subject: [PATCH] iOS: Fixes #13111: Fix "scan notebook" tool on iOS (#13114) --- .../components/CameraView/Camera/index.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/app-mobile/components/CameraView/Camera/index.tsx b/packages/app-mobile/components/CameraView/Camera/index.tsx index 2cd0d6b3f1..f3ef426349 100644 --- a/packages/app-mobile/components/CameraView/Camera/index.tsx +++ b/packages/app-mobile/components/CameraView/Camera/index.tsx @@ -54,6 +54,14 @@ const Camera = (props: Props, ref: ForwardedRef) => { logger.error(message); }, []); + const isReadyRef = useRef(false); + const onCameraReady = useCallback(() => { + if (isReadyRef.current) return; // Already emitted + + isReadyRef.current = true; + props.onCameraReady(); + }, [props.onCameraReady]); + useAsyncEffect(async (event) => { // iOS issue workaround: Since upgrading to Expo SDK 52, closing and reopening the camera on iOS // never emits onCameraReady. As a workaround, call .resumePreview and wait for it to resolve, @@ -63,16 +71,16 @@ const Camera = (props: Props, ref: ForwardedRef) => { // Instead, wait for the preview to start using resumePreview: await camera.resumePreview(); if (event.cancelled) return; - props.onCameraReady(); + onCameraReady(); } - }, [camera, props.onCameraReady]); + }, [camera, onCameraReady]); return hasPermission?.granted ?