mrousavy / react-native-vision-camera

📸 A powerful, high-performance React Native Camera library.
https://react-native-vision-camera.com
MIT License
7.57k stars 1.1k forks source link

🐛 Black screen when opening the camera using CodeScanner. #3283

Closed anderpaz closed 1 week ago

anderpaz commented 1 week ago

What's happening?

At times, when the device turns on with low battery, for example, 5-10%, I only get a black screen. In my error log, I get MlKitContext.

Reproduceable Code

const CameraManager: React.FC<typ.CameraManagerProps> = ({
  photo,
  codeTypes,
  hiddenButtonClose,
  hiddenCardButton,
  isActive,
  isPreviewPhoto,
  isFull,
  isMaskCode,
  onClose,
  onReturnTakePhoto,
  onBarCodeScanned,
  onSavePhoto,
}) => {
  const cameraRef = React.useRef<Camera>(null);

  const [isFlash, setFlash] = React.useState(false);
  const [isLoading, setLoading] = React.useState(false);
  const [isFront, setFront] = React.useState(false);
  const [photoFile, setPhotoFile] = React.useState<typ.photoFile>();

  const { updateStatusBar } = useAppActions();
  const device = useCameraDevice(!isFront ? 'back' : 'front');

  React.useEffect(() => {
    console.log(JSON.stringify(device, (k, v) => (k === 'formats' ? [] : v), 2));
  }, [device, isPreviewPhoto, updateStatusBar]);

  React.useEffect(() => {
    updateStatusBar({
      active: true,
      screen: 'camera',
    });
    return () => {
      updateStatusBar({
        active: false,
        screen: 'camera',
      });
    };
  }, [isPreviewPhoto, updateStatusBar]);

  const onCodeScanned = React.useCallback(
    (codes: typ.code[]) => {
      try {
        console.log('-----------------', codes);
        if (!onBarCodeScanned) return;
        onBarCodeScanned(codes);
      } catch (e) {
        log('CameraManager').error('e from onCodeScanned', e);
      }
    },
    [onBarCodeScanned],
  );

  const codeScanner = useCodeScanner({
    codeTypes: codeTypes || [],
    onCodeScanned,
  });

  const styled = React.useMemo<typ.styled>(() => {
    if (isFull)
      return {
        camera: { bottom: 0, left: 0, position: 'absolute', right: 0, top: 0 },
        imagePreview: {
          bottom: 0,
        },
      };
    const { height, width } = Dimensions.get('window');
    const newHeight = width * (4 / 3);
    const padding = (height - newHeight) / 2;
    return {
      camera: {
        position: 'absolute',
        left: 0,
        right: 0,
        top: padding - 30,
        bottom: padding + 30,
        width,
        height: newHeight,
      },
      imagePreview: {
        bottom: 30,
      },
    };
  }, [isFull]);

  const handleTakePhoto = React.useCallback(async () => {
    /* istanbul ignore if */ if (isLoading) return;
    try {
      setLoading(true);
      const result = await cameraRef.current?.takePhoto({
        flash: !isFlash ? 'off' : 'on',
      });

      if (isPreviewPhoto && result?.path) setPhotoFile(result);
      if (result?.path && onReturnTakePhoto) onReturnTakePhoto(result);
    } catch (e) {
      log('CameraManager').error('e from handleTakePhoto', e);
    } finally {
      setLoading(false);
    }
  }, [isFlash, isLoading, isPreviewPhoto, onReturnTakePhoto]);

  const handleBackButtonPress = React.useCallback(() => {
    if (isLoading) return;
    if (isPreviewPhoto && photoFile) {
      setPhotoFile(undefined);
    } else {
      onClose();
    }
  }, [isLoading, isPreviewPhoto, onClose, photoFile]);

  const handleSavePhoto = React.useCallback(async () => {
    /* istanbul ignore if */ if (isLoading) return;
    try {
      /* istanbul ignore if */ if (!photoFile) throw new Error('photoFile is null');
      setLoading(true);
      if (onSavePhoto) await onSavePhoto(photoFile);
    } catch (e) {
      log('CameraManager').error('e from handleSavePhoto', e);
    } finally {
      setLoading(false);
    }
  }, [isLoading, onSavePhoto, photoFile]);

  const handleError = React.useCallback<typ.handleError>((e) => {
    log('CameraManager').error(e?.message, { code: e?.code, cause: e?.cause, stack: e?.stack });
  }, []);

  return (
    <Modal testID="cameraModal-modal" isVisible avoidKeyboard onBackButtonPress={handleBackButtonPress}>
      <Container>
        {!photoFile ? (
          <>
            {!hiddenButtonClose && (
              <ButtonClose testID="cameraModal-close" onPress={handleBackButtonPress} loading={isLoading}>
                <IconClose />
              </ButtonClose>
            )}
            {device && styled.camera && (
              <Camera
                testID="cameraModal-camera"
                ref={cameraRef}
                style={styled.camera}
                isActive={!photoFile && isActive}
                enableZoomGesture
                focusable
                preview={isPreviewPhoto}
                photo={photo}
                photoQualityBalance="speed"
                device={device}
                codeScanner={!codeTypes?.length ? undefined : codeScanner}
                onError={handleError}
              />
            )}
            {isMaskCode && <Mask testID="cameraModal-mask" />}
            {!hiddenCardButton && (
              <CardButton testID="cameraModal-cardButton">
                <ButtonSetting testID="cameraModal-flash" onPress={() => setFlash(!isFlash)} loading={isLoading}>
                  <IconFlash active={isFlash} />
                </ButtonSetting>
                {photo && (
                  <ButtonTake testID="cameraModal-take" onPress={handleTakePhoto} loading={isLoading}>
                    <IconTake />
                  </ButtonTake>
                )}
                <ButtonSetting testID="cameraModal-position-camera" onPress={() => setFront(!isFront)} loading={isLoading}>
                  <IconCameraType />
                </ButtonSetting>
              </CardButton>
            )}
          </>
        ) : (
          <>
            {photoFile.path && (
              <ImageViewer
                imageUrls={[
                  {
                    url: `file://${photoFile.path}`,
                  },
                ]}
                renderHeader={() => <View />}
                renderFooter={() => <View />}
                renderIndicator={() => <View />}
                style={styled.imagePreview}
              />
            )}
            <ButtonClose
              testID="cameraModal-image-close"
              disabled={isLoading}
              onPress={() => {
                setPhotoFile(undefined);
              }}
            >
              <IconClose />
            </ButtonClose>
            <ButtonSend iconRight={<IconSend />} onPress={handleSavePhoto} loading={isLoading}>
              Enviar
            </ButtonSend>
          </>
        )}
      </Container>
    </Modal>
  );
};

Relevant log output

2024-11-07 15:19:42.532  3153-3153  CameraSession           com.spacecom.mpmobile                I  Camera Lifecycle changed to CREATED!
2024-11-07 15:19:42.534  3153-3153  CameraView              com.spacecom.mpmobile                I  Updating CameraSession...
2024-11-07 15:19:42.539  3153-3153  CameraView              com.spacecom.mpmobile                I  Updating CameraSession...
2024-11-07 15:19:42.540  3153-3153  CameraView              com.spacecom.mpmobile                I  Updating CameraSession...
2024-11-07 15:19:42.541  3153-3153  CameraSession           com.spacecom.mpmobile                I  configure { ... }: Waiting for lock...
2024-11-07 15:19:42.541  3153-3153  CameraView              com.spacecom.mpmobile                I  A new configure { ... } call arrived, aborting this one...
2024-11-07 15:19:42.548  3153-3153  CameraSession           com.spacecom.mpmobile                I  configure { ... }: Waiting for lock...
2024-11-07 15:19:42.548  3153-3153  CameraView              com.spacecom.mpmobile                I  A new configure { ... } call arrived, aborting this one...
2024-11-07 15:19:42.549  3153-3153  CameraSession           com.spacecom.mpmobile                I  configure { ... }: Waiting for lock...
2024-11-07 15:19:42.549  3153-3153  CameraSession           com.spacecom.mpmobile                I  configure { ... }: Updating CameraSession Configuration... Difference(deviceChanged=true, outputsChanged=true, sidePropsChanged=true, isActiveChanged=true, orientationChanged=true, locationChanged=true)
2024-11-07 15:19:42.549  3153-3153  CameraSession           com.spacecom.mpmobile                I  Creating new Outputs for Camera #0...
2024-11-07 15:19:42.549  3153-3153  CameraSession           com.spacecom.mpmobile                I  Using FPS Range: null
2024-11-07 15:19:42.549  3153-3153  CameraSession           com.spacecom.mpmobile                I  Creating Preview output...
2024-11-07 15:19:42.550  3153-3153  CameraSession           com.spacecom.mpmobile                I  Creating CodeScanner output...
2024-11-07 15:19:42.551  3153-3153  CameraSession           com.spacecom.mpmobile                E  Failed to configure CameraSession! Error: MlKitContext has not been initialized, Config-Diff: Difference(deviceChanged=true, outputsChanged=true, sidePropsChanged=true, isActiveChanged=true, orientationChanged=true, locationChanged=true)
                                                                                                    java.lang.IllegalStateException: MlKitContext has not been initialized
                                                                                                        at com.google.android.gms.common.internal.Preconditions.checkState(com.google.android.gms:play-services-basement@@18.3.0:2)
                                                                                                        at com.google.mlkit.common.sdkinternal.MlKitContext.getInstance(com.google.mlkit:common@@18.9.0:1)
                                                                                                        at com.google.mlkit.vision.barcode.BarcodeScanning.getClient(com.google.android.gms:play-services-mlkit-barcode-scanning@@18.3.0:3)
                                                                                                        at com.mrousavy.camera.core.CodeScannerPipeline.<init>(CodeScannerPipeline.kt:27)
                                                                                                        at com.mrousavy.camera.core.CameraSession_ConfigurationKt.configureOutputs(CameraSession+Configuration.kt:219)
                                                                                                        at com.mrousavy.camera.core.CameraSession.configure(CameraSession.kt:135)
                                                                                                        at com.mrousavy.camera.react.CameraView$update$1.invokeSuspend(CameraView.kt:153)
                                                                                                        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
                                                                                                        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
                                                                                                        at android.os.Handler.handleCallback(Handler.java:958)
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                                                        at android.os.Looper.loopOnce(Looper.java:230)
                                                                                                        at android.os.Looper.loop(Looper.java:319)
                                                                                                        at android.app.ActivityThread.main(ActivityThread.java:8913)
                                                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                                                        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:608)
                                                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
2024-11-07 15:19:42.551  3153-3153  CameraView              com.spacecom.mpmobile                E  invokeOnError(...):
2024-11-07 15:19:42.551  3153-3153  System.err              com.spacecom.mpmobile                W  java.lang.IllegalStateException: MlKitContext has not been initialized
2024-11-07 15:19:42.551  3153-3153  System.err              com.spacecom.mpmobile                W      at com.google.android.gms.common.internal.Preconditions.checkState(com.google.android.gms:play-services-basement@@18.3.0:2)
2024-11-07 15:19:42.551  3153-3153  System.err              com.spacecom.mpmobile                W      at com.google.mlkit.common.sdkinternal.MlKitContext.getInstance(com.google.mlkit:common@@18.9.0:1)
2024-11-07 15:19:42.551  3153-3153  System.err              com.spacecom.mpmobile                W      at com.google.mlkit.vision.barcode.BarcodeScanning.getClient(com.google.android.gms:play-services-mlkit-barcode-scanning@@18.3.0:3)
2024-11-07 15:19:42.551  3153-3153  System.err              com.spacecom.mpmobile                W      at com.mrousavy.camera.core.CodeScannerPipeline.<init>(CodeScannerPipeline.kt:27)
2024-11-07 15:19:42.551  3153-3153  System.err              com.spacecom.mpmobile                W      at com.mrousavy.camera.core.CameraSession_ConfigurationKt.configureOutputs(CameraSession+Configuration.kt:219)
2024-11-07 15:19:42.551  3153-3153  System.err              com.spacecom.mpmobile                W      at com.mrousavy.camera.core.CameraSession.configure(CameraSession.kt:135)
2024-11-07 15:19:42.551  3153-3153  System.err              com.spacecom.mpmobile                W      at com.mrousavy.camera.react.CameraView$update$1.invokeSuspend(CameraView.kt:153)
2024-11-07 15:19:42.551  3153-3153  System.err              com.spacecom.mpmobile                W      at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
2024-11-07 15:19:42.552  3153-3153  System.err              com.spacecom.mpmobile                W      at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
2024-11-07 15:19:42.552  3153-3153  System.err              com.spacecom.mpmobile                W      at android.os.Handler.handleCallback(Handler.java:958)
2024-11-07 15:19:42.552  3153-3153  System.err              com.spacecom.mpmobile                W      at android.os.Handler.dispatchMessage(Handler.java:99)
2024-11-07 15:19:42.552  3153-3153  System.err              com.spacecom.mpmobile                W      at android.os.Looper.loopOnce(Looper.java:230)
2024-11-07 15:19:42.552  3153-3153  System.err              com.spacecom.mpmobile                W      at android.os.Looper.loop(Looper.java:319)
2024-11-07 15:19:42.552  3153-3153  System.err              com.spacecom.mpmobile                W      at android.app.ActivityThread.main(ActivityThread.java:8913)
2024-11-07 15:19:42.552  3153-3153  System.err              com.spacecom.mpmobile                W      at java.lang.reflect.Method.invoke(Native Method)
2024-11-07 15:19:42.552  3153-3153  System.err              com.spacecom.mpmobile                W      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:608)
2024-11-07 15:19:42.552  3153-3153  System.err              com.spacecom.mpmobile                W      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
2024-11-07 15:19:42.556  3153-3153  Dialog                  com.spacecom.mpmobile                I  mIsDeviceDefault = false, mIsSamsungBasicInteraction = false, isMetaDataInActivity = false
2024-11-07 15:19:42.556  3153-3153  unknown:ReactModalHost  com.spacecom.mpmobile                E  Creating new dialog from context: com.spacecom.mpmobile.MainActivity@2ad75@175477
2024-11-07 15:19:42.559  3153-3153  DecorView               com.spacecom.mpmobile                I  setWindowBackground: isPopOver=false color=0 d=android.graphics.drawable.ColorDrawable@7b5e694
2024-11-07 15:19:42.564  3153-4302  NativeCust...ncyManager com.spacecom.mpmobile                D  [NativeCFMS] BpCustomFrequencyManager::BpCustomFrequencyManager()
2024-11-07 15:19:42.570   831-885   BufferQueueDebug        surfaceflinger                       E  [174f147 com.spacecom.mpmobile/com.spacecom.mpmobile.MainActivity#203](this:0xb40000778a3beba0,id:-1,api:0,p:-1,c:-1) id info cannot be read from '174f147 com.spacecom.mpmobile/com.spacecom.mpmobile.MainActivity#203'
2024-11-07 15:19:42.575  3153-3153  InsetsController        com.spacecom.mpmobile                I  onStateChanged: host=com.spacecom.mpmobile/com.spacecom.mpmobile.MainActivity, from=android.view.ViewRootImpl.setView:1744, state=InsetsState: {mDisplayFrame=Rect(0, 0 - 1080, 2340), mDisplayCutout=DisplayCutout{insets=Rect(0, 73 - 0, 0) waterfall=Insets{left=0, top=0, right=0, bottom=0} boundingRect={Bounds=[Rect(0, 0 - 0, 0), Rect(484, 0 - 596, 73), Rect(0, 0 - 0, 0), Rect(0, 0 - 0, 0)]} cutoutPathParserInfo={CutoutPathParserInfo{displayWidth=1080 displayHeight=2340 physicalDisplayWidth=1080 physicalDisplayHeight=2340 density={2.8125} cutoutSpec={M 0,0 H -24.177777778 V 28.4444444444 H 24.177777778 V 0 H 0 Z @dp} rotation={0} scale={1.0} physicalPixelDisplaySizeRatio={1.0}}}}, mRoundedCorners=RoundedCorners{[RoundedCorner{position=TopLeft, radius=0, center=Point(0, 0)}, RoundedCorner{position=TopRight, radius=0, center=Point(0, 0)}, RoundedCorner{position=BottomRight, radius=0, center=Point(0, 0)}, RoundedCorner{position=BottomLeft, radius=0, center=Point(0, 0)}]}  mRoundedCornerFrame=Rect(0, 0 - 1080, 2340), mPrivacyIndicatorBounds=PrivacyIndicatorBounds {static bounds=Rect(956, 0 - 1080, 80) rotation=0}, mDisplayShape=DisplayShape{ spec=-1084927657 displayWidth=1080 displayHeight=2340 physicalPixelDisplaySizeRatio=1.0 rotation=0 offsetX=0 offsetY=0 scale=1.0}, mSources= { InsetsSource: {27 mType=displayCutout mFrame=[0,0][1080,73] mVisible=true mFlags=[]}, InsetsSource: {2ab80000 mType=statusBars mFrame=[0,0][1080,80] mVisible=true mFlags=[]}, InsetsSource: {2ab80005 mType=mandatorySystemGestures mFrame=[0,0][1080,107] mVisible=true mFlags=[]}, InsetsSource: {2ab80006 mType=tappableElement mFrame=[0,0][1080,80] mVisible=true mFlags=[]}, InsetsSource: {2de10001 mType=navigationBars mFrame=[0,2205][1080,2340] mVisible=true mFlags=[]}, InsetsSource: {2de10004 mType=systemGestures mFrame=[0,0][0,0] mVisible=true mFlags=[]}, InsetsSource: {2de10005 mType=mandatorySystemGestures mFrame=[0,2205][1080,2340] mVisible=true mFlags=[]}, InsetsSource: {2de10006 mType=tappableElement mFrame=[0,2205][1080,2340] mVisible=true mFlags=[]}, InsetsSource: {2de10024 mType=systemGestures mFrame=[0,0][0,0] mVisible=true mFlags=[]} }
2024-11-07 15:19:42.576  3153-3153  ViewRootIm...nActivity] com.spacecom.mpmobile                I  synced displayState. AttachInfo displayState=2
2024-11-07 15:19:42.584  3153-3153  ViewRootIm...nActivity] com.spacecom.mpmobile                I  setView = com.android.internal.policy.DecorView@698ae7e TM=true
2024-11-07 15:19:42.593   831-885   BufferQueueDebug        surfaceflinger                       E  [com.spacecom.mpmobile/com.spacecom.mpmobile.MainActivity$_3153#204](this:0xb40000775acb8ba0,id:-1,api:0,p:-1,c:-1) id info cannot be read from 'com.spacecom.mpmobile/com.spacecom.mpmobile.MainActivity$_3153#204'

Camera Device

{
                                                                                                      "formats": [],
                                                                                                      "sensorOrientation": "landscape-left",
                                                                                                      "hardwareLevel": "limited",
                                                                                                      "maxZoom": 4,
                                                                                                      "minZoom": 1,
                                                                                                      "maxExposure": 20,
                                                                                                      "supportsLowLightBoost": false,
                                                                                                      "neutralZoom": 1,
                                                                                                      "physicalDevices": [
                                                                                                        "wide-angle-camera"
                                                                                                      ],
                                                                                                      "supportsFocus": true,
                                                                                                      "supportsRawCapture": false,
                                                                                                      "isMultiCam": false,
                                                                                                      "minFocusDistance": 10,
                                                                                                      "minExposure": -20,
                                                                                                      "name": "0 (BACK) androidx.camera.camera2",
                                                                                                      "hasFlash": true,
                                                                                                      "hasTorch": true,
                                                                                                      "position": "back",
                                                                                                      "id": "0"
                                                                                                    }

Device

Samsung A15

VisionCamera Version

"react-native-vision-camera": "4.3.1",

Can you reproduce this issue in the VisionCamera Example app?

I didn't try (⚠️ your issue might get ignored & closed if you don't try this)

Additional information

maintenance-hans[bot] commented 1 week ago

Guten Tag, Hans here. Unfortunately, it seems ze issue is not reproducible because you did not try it in ze VisionCamera Example app. Plus, you did not provide logs relevant to isolating ze problem, such as using adb logcat for your device. Please provide these details next time, it helps mrousavy greatly. If you would like ze project to be improved faster, consider supporting it by sponsoring mrousavy here. Thank you!

Note: If you think I made a mistake by closing this issue, please ping @mrousavy to take a look.

iliapnmrv commented 1 week ago

hey! I think i had the same issue. Can you try this code?

const isFocused = useIsFocused();

// https://github.com/mrousavy/react-native-vision-camera/blob/main/package/example/src/hooks/useIsForeground.ts

const isForeground = useIsForeground();
const isActive = isFocused && isForeground;

<Camera
  isActive={isActive}
/>
anderpaz commented 1 week ago

Normally, the camera works, but if the battery is low and I restart the device and try to scan a QR code, at some point after the 3rd or 5th restart, the screen goes black and I get this error in the log.

Creating CodeScanner output... 2024-11-08 10:28:24.911 3096-3096 CameraSession com.spacecom.mpmobile E Failed to configure CameraSession! Error: MlKitContext has not been initialized, Config-Diff: Difference(deviceChanged=true, outputsChanged=true, sidePropsChanged=true, isActiveChanged=true, orientationChanged=true, locationChanged=true) java.lang.IllegalStateException: MlKitContext has not been initialized at com.google.android.gms.common.internal.Preconditions.checkState(com.google.android.gms:play-services-basement@@18.3.0:2) at com.google.mlkit.common.sdkinternal.MlKitContext.getInstance(com.google.mlkit:common@@18.9.0:1) at com.google.mlkit.vision.barcode.BarcodeScanning.getClient(com.google.android.gms:play-services-mlkit-barcode-scanning@@18.3.0:3) at com.mrousavy.camera.core.CodeScannerPipeline.<init>(CodeScannerPipeline.kt:27) at com.mrousavy.camera.core.CameraSession_ConfigurationKt.configureOutputs(CameraSession+Configuration.kt:219) at com.mrousavy.camera.core.CameraSession.configure(CameraSession.kt:135) at com.mrousavy.camera.react.CameraView$update$1.invokeSuspend(CameraView.kt:153) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108) at android.os.Handler.handleCallback(Handler.java:958) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:230) at android.os.Looper.loop(Looper.java:319) at android.app.ActivityThread.main(ActivityThread.java:8913) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:608) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103) 2024-11-08 10:28:24.911 3096-3096 CameraView com.spacecom.mpmobile E invokeOnError(...): 2024-11-08 10:28:24.911 3096-3096 System.err com.spacecom.mpmobile W java.lang.IllegalStateException: MlKitContext has not been initialized 2024-11-08 10:28:24.911 3096-3096 System.err com.spacecom.mpmobile W at com.google.android.gms.common.internal.Preconditions.checkState(com.google.android.gms:play-services-basement@@18.3.0:2) 2024-11-08 10:28:24.911 3096-3096 System.err com.spacecom.mpmobile W at com.google.mlkit.common.sdkinternal.MlKitContext.getInstance(com.google.mlkit:common@@18.9.0:1) 2024-11-08 10:28:24.911 3096-3096 System.err com.spacecom.mpmobile W at com.google.mlkit.vision.barcode.BarcodeScanning.getClient(com.google.android.gms:play-services-mlkit-barcode-scanning@@18.3.0:3) 2024-11-08 10:28:24.911 3096-3096 System.err com.spacecom.mpmobile W at com.mrousavy.camera.core.CodeScannerPipeline.<init>(CodeScannerPipeline.kt:27) 2024-11-08 10:28:24.911 3096-3096 System.err com.spacecom.mpmobile W at com.mrousavy.camera.core.CameraSession_ConfigurationKt.configureOutputs(CameraSession+Configuration.kt:219) 2024-11-08 10:28:24.911 3096-3096 System.err com.spacecom.mpmobile W at com.mrousavy.camera.core.CameraSession.configure(CameraSession.kt:135) 2024-11-08 10:28:24.911 3096-3096 System.err com.spacecom.mpmobile W at com.mrousavy.camera.react.CameraView$update$1.invokeSuspend(CameraView.kt:153) 2024-11-08 10:28:24.911 3096-3096 System.err com.spacecom.mpmobile W at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) 2024-11-08 10:28:24.911 3096-3096 System.err com.spacecom.mpmobile W at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108) 2024-11-08 10:28:24.911 3096-3096 System.err com.spacecom.mpmobile W at android.os.Handler.handleCallback(Handler.java:958) 2024-11-08 10:28:24.911 3096-3096 System.err com.spacecom.mpmobile W at android.os.Handler.dispatchMessage(Handler.java:99) 2024-11-08 10:28:24.911 3096-3096 System.err com.spacecom.mpmobile W at android.os.Looper.loopOnce(Looper.java:230) 2024-11-08 10:28:24.911 3096-3096 System.err com.spacecom.mpmobile W at android.os.Looper.loop(Looper.java:319) 2024-11-08 10:28:24.912 3096-3096 System.err com.spacecom.mpmobile W at android.app.ActivityThread.main(ActivityThread.java:8913) 2024-11-08 10:28:24.912 3096-3096 System.err com.spacecom.mpmobile W at java.lang.reflect.Method.invoke(Native Method) 2024-11-08 10:28:24.912 3096-3096 System.err com.spacecom.mpmobile W at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:608) 2024-11-08 10:28:24.912 3096-3096 System.err com.spacecom.mpmobile W at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103) 2024-11-08 10:28:24.917 3096-3096 Dialog com.spacecom.mpmobile I mIsDeviceDefault = false, mIsSamsungBasicInteraction = false, isMetaDataInActivity = false

hey! I think i had the same issue. Can you try this code?

const isFocused = useIsFocused();

// https://github.com/mrousavy/react-native-vision-camera/blob/main/package/example/src/hooks/useIsForeground.ts

const isForeground = useIsForeground();
const isActive = isFocused && isForeground;

<Camera
  isActive={isActive}
/>
anderpaz commented 1 week ago

Guten Tag, Hans here. Unfortunately, it seems ze issue is not reproducible because you did not try it in ze VisionCamera Example app. Plus, you did not provide logs relevant to isolating ze problem, such as using adb logcat for your device. Please provide these details next time, it helps mrousavy greatly. If you would like ze project to be improved faster, consider supporting it by sponsoring mrousavy here. Thank you!

Note: If you think I made a mistake by closing this issue, please ping @mrousavy to take a look.

I can't test with the example, but the error is very specific to react-native-vision-camera.

maintenance-hans[bot] commented 1 week ago
it ain't much, but it's honest work