mrousavy / react-native-vision-camera

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

🐛 Camera has been disconnected #2257

Closed gsagergithub closed 8 months ago

gsagergithub commented 9 months ago

What's happening?

Hi everyone. I find myself surrounded by the darkest darkness trying to use the rear camera of my Motorola Moto g6 plus, since I'm getting multiple errors. When I navigate to the screen containing the Camera component this one shows up: Camera.onError(session/camera-has-been-disconnected): [session/camera-has-been-disconnected] The given Camera device (id: 0) has been disconnected! Error: UNKNOWN_CAMERA_DEVICE_ERROR [session/camera-has-been-disconnected: [session/camera-has-been-disconnected] The given Camera device (id: 0) has been disconnected! Error: UNKNOWN_CAMERA_DEVICE_ERROR] And then, navigating back and forth again I'm getting these other two Camera.onError(unknown/unknown): [unknown/unknown] CameraDevice was already closed [unknown/unknown: [unknown/unknown] CameraDevice was already closed]

Camera.onError(session/camera-not-ready): [session/camera-not-ready] The Camera is not ready yet! Wait for the onInitialized() callback! [session/camera-not-ready: [session/camera-not-ready] The Camera is not ready yet! Wait for the onInitialized() callback!]

I don't want to leave without telling you that I've tested the native camera application of the phone and it's working properly, and that I have at least three other devices where the application that integrates react native vision camera, runs well. One of them is a Motorola Moto e6 Plus.

I would appreciate any kind of help/guidance to solve this issue. Thank you!

Reproduceable Code

const device = useCameraDevice('back');

<View>
  {
    isActive &&
    <Camera
      style={styles.container}
      device={device}
      isActive={isActive}
      codeScanner={codeScanner}
      enableZoomGesture={true}
    />
  }
</View>

Relevant log output

2023-12-06 15:16:08.545 10591-10591 CameraView              pid-10591                            I  Updating CameraSession...
2023-12-06 15:16:08.547 10591-11047 CameraSession           pid-10591                            I  Updating CameraSession Configuration...
2023-12-06 15:16:08.548 10591-11047 CameraSession           pid-10591                            I  Successfully updated CameraSession Configuration! isActive: false
2023-12-06 15:16:08.559 10591-10591 CameraSession           pid-10591                            I  PreviewView Surface destroyed! Surface(name=null)/@0xff010d1
2023-12-06 15:16:08.559 10591-10591 CameraSession           pid-10591                            I  Destroying Preview Output...
2023-12-06 15:16:08.561 10591-10591 CameraSession           pid-10591                            I  Updating CameraSession Configuration...
2023-12-06 15:16:08.562 10591-10591 CameraSession           pid-10591                            I  Configuring Session for Camera #0...
2023-12-06 15:16:08.567 10591-10591 CameraSession           pid-10591                            I  Adding 1280 x 720 CodeScanner Output in Format #35...
2023-12-06 15:16:08.569   543-11051 ULog                    camerahalserver                      I  R AppRequest:2929 M[CameraDevice:187001] -  :mtkcam-AppStreamMgr #23595
2023-12-06 15:16:08.572   526-672   Camera3-OutputStream    cameraserver                         E  returnBufferCheckedLocked: Stream 2: Error queueing buffer to native window: No such device (-19)
2023-12-06 15:16:08.572   526-672   Camera3-Device          cameraserver                         E  Can't return buffer to its stream: No such device (-19)
2023-12-06 15:16:08.575 10591-10591 CreateCaptureSession    pid-10591                            I  Camera 0: Creating Capture Session #1002... Hardware Level: 1} | Outputs: [android.hardware.camera2.params.OutputConfiguration@28061169]
2023-12-06 15:16:08.637   543-11051 ULog                    camerahalserver                      I  R AppRequest:2930 M[CameraDevice:187001] -  :mtkcam-AppStreamMgr #23596
2023-12-06 15:16:08.639   526-672   Camera3-OutputStream    cameraserver                         E  returnBufferCheckedLocked: Stream 2: Error queueing buffer to native window: No such device (-19)
2023-12-06 15:16:08.639   526-672   Camera3-Device          cameraserver                         E  Can't return buffer to its stream: No such device (-19)
2023-12-06 15:16:08.721   543-11051 ULog                    camerahalserver                      I  R AppRequest:2931 M[CameraDevice:187001] -  :mtkcam-AppStreamMgr #23597
2023-12-06 15:16:08.724   526-672   Camera3-OutputStream    cameraserver                         E  returnBufferCheckedLocked: Stream 2: Error queueing buffer to native window: No such device (-19)
2023-12-06 15:16:08.724   526-672   Camera3-Device          cameraserver                         E  Can't return buffer to its stream: No such device (-19)
2023-12-06 15:16:08.794   543-11051 ULog                    camerahalserver                      I  R AppRequest:2932 M[CameraDevice:187001] -  :mtkcam-AppStreamMgr #23598
2023-12-06 15:16:08.797   526-672   Camera3-OutputStream    cameraserver                         E  returnBufferCheckedLocked: Stream 2: Error queueing buffer to native window: No such device (-19)
2023-12-06 15:16:08.797   526-672   Camera3-Device          cameraserver                         E  Can't return buffer to its stream: No such device (-19)
2023-12-06 15:16:08.862   543-11051 ULog                    camerahalserver                      I  R AppRequest:2933 M[CameraDevice:187001] -  :mtkcam-AppStreamMgr #23599
2023-12-06 15:16:08.865   526-672   Camera3-OutputStream    cameraserver                         E  returnBufferCheckedLocked: Stream 2: Error queueing buffer to native window: No such device (-19)
2023-12-06 15:16:08.865   526-672   Camera3-Device          cameraserver                         E  Can't return buffer to its stream: No such device (-19)
2023-12-06 15:16:08.865 10591-10591 Binder                  pid-10591                            D  <<<<< Spending more than 290 ms on Binder:android.hardware.camera2.ICameraDeviceUser#13
2023-12-06 15:16:08.867   526-999   CameraLatencyHistogram  cameraserver                         I  Stream 1 dequeueBuffer latency histogram (2934) samples:
2023-12-06 15:16:08.867   526-999   CameraLatencyHistogram  cameraserver                         I          5     10     15     20     25     30     35     40     45    inf (max ms)
2023-12-06 15:16:08.867   526-999   CameraLatencyHistogram  cameraserver                         I       100.00   0.00   0.00   0.00   0.00   0.00   0.00   0.00   0.00   0.00 (%)
2023-12-06 15:16:08.869   526-999   CameraLatencyHistogram  cameraserver                         I  Stream 2 dequeueBuffer latency histogram (2934) samples:
2023-12-06 15:16:08.869   526-999   CameraLatencyHistogram  cameraserver                         I          5     10     15     20     25     30     35     40     45    inf (max ms)
2023-12-06 15:16:08.869   526-999   CameraLatencyHistogram  cameraserver                         I       99.97   0.03   0.00   0.00   0.00   0.00   0.00   0.00   0.00   0.00 (%)
2023-12-06 15:16:08.887   543-543   mtkcam-AppStreamMgr     camerahalserver                      W  [0-ConfigHandler::checkStream] framework stream dataspace:0x08c20000(V0_JFIF|STANDARD_BT601_625|TRANSFER_SMPTE_170M|RANGE_FULL) {.v3_2 = {.id = 3, .streamType = OUTPUT, .width = 1280, .height = 720, .format = YCBCR_420_888, .usage = CPU_READ_NEVER | CPU_READ_RARELY | CPU_READ_OFTEN | CPU_WRITE_NEVER (0x3), .dataSpace = UNKNOWN | STANDARD_UNSPECIFIED | STANDARD_BT601_625 | TRANSFER_UNSPECIFIED | TRANSFER_LINEAR | TRANSFER_SRGB | TRANSFER_SMPTE_170M | RANGE_UNSPECIFIED | RANGE_FULL | V0_JFIF (0x8c20000), .rotation = ROTATION_0}, .physicalCameraId = "", .bufferSize = 0}
2023-12-06 15:16:08.889   543-543   BWC                     camerahalserver                      I  Profile_Change:[BWCPT_CAMERA_CAPTURE]:OFF,current concurrency is 0x0,DDR=,EMI scenario=BWL_SCN_ICFP OFF
2023-12-06 15:16:08.919   543-543   BWC                     camerahalserver                      I  Profile_Change:[BWCPT_CAMERA_CAPTURE]:ON,current concurrency is 0x10,DDR=,EMI scenario=BWL_SCN_ICFP ON
2023-12-06 15:16:08.922   543-543   MtkCam/ppl_context      camerahalserver                      I  [dump]     [APP     ] 03 1280x720  OUT t:0/r:0 maxBuffers:11 d/s:0x08c20000(V0_JFIF|STANDARD_BT601_625|TRANSFER_SMPTE_170M|RANGE_FULL) Hal-Client-usage:0x3(0|SW_READ_OFTEN) Real:0x32315659(YV12) Request:0x23(YCbCr_420_888) Override:0x23(YCbCr_420_888) Hal-usage:0x20033(0|SW_READ_OFTEN|SW_WRITE_OFTEN|HW_CAMERA_WRITE) HalStream::(consumer/producer)Usage:0/0x20033 bufOffset:  0 rowStrideInBytes/sizeInBytes: 1280/921600 640/230400 640/263040 s3:d0:App:YV12:0|SW_READ_OFTEN 0x9f76cf00
2023-12-06 15:16:08.959   543-543   chatty                  camerahalserver                      I  uid=1047(cameraserver) /vendor/bin/hw/camerahalserver identical 1 line
2023-12-06 15:16:08.965   543-543   CcuDrv                  camerahalserver                      E  CcuDrv[vendor/mediatek/proprietary/hardware/libcamera_ext/ccu/mt6765/ver1/drv/src/drv/ccu_udrv.cpp, OpenCcuKdrv, line0229] ERROR: CCU kernel 1st open fail, errno(2):No such file or directory.
2023-12-06 15:16:08.965   543-543   CcuDrv                  camerahalserver                      E  CcuDrv[vendor/mediatek/proprietary/hardware/libcamera_ext/ccu/mt6765/ver1/drv/src/drv/ccu_udrv.cpp, OpenCcuKdrv, line0234] ERROR: CCU kernel 2nd open fail, errno(2):No such file or directory.
2023-12-06 15:16:08.965   543-543   CcuMgr                  camerahalserver                      E  [vendor/mediatek/proprietary/hardware/libcamera_ext/ccu/mt6765/ver1/drv/src/ccuif/src/ccu_mgr.cpp, ccuBoot, line0327] ERROR: m_pDrvCcu->init(), failed: 0
2023-12-06 15:16:08.968   543-11816 CcuDrv                  camerahalserver                      E  CcuDrv[vendor/mediatek/proprietary/hardware/libcamera_ext/ccu/mt6765/ver1/drv/src/drv/ccu_udrv.cpp, GetSensorName, line1302] ERROR: ERROR: CCU_IOCTL_GET_SENSOR_NAME
2023-12-06 15:16:08.968   543-11816 CcuDrv                  camerahalserver                      E  CcuDrv[vendor/mediatek/proprietary/hardware/libcamera_ext/ccu/mt6765/ver1/drv/src/drv/ccu_udrv.cpp, tryOpenFile, line1067] ERROR: open file fail: 0
2023-12-06 15:16:08.968   543-11816 CcuDrv                  camerahalserver                      E  CcuDrv[vendor/mediatek/proprietary/hardware/libcamera_ext/ccu/mt6765/ver1/drv/src/drv/ccu_udrv.cpp, tryOpenFile, line1068] ERROR: open file path: /system/vendor/bin/libccu_.pm
2023-12-06 15:16:08.968   543-11816 CcuDrv                  camerahalserver                      E  CcuDrv[vendor/mediatek/proprietary/hardware/libcamera_ext/ccu/mt6765/ver1/drv/src/drv/ccu_udrv.cpp, loadBin, line1157] ERROR: Open Bin file fail
2023-12-06 15:16:09.000   543-543   mtkcam-AppStreamMgr     camerahalserver                      D  [endConfigureStreams]  03 1280x720  OUT t:0/r:0 maxBuffers:11 d/s:0x08c20000(V0_JFIF|STANDARD_BT601_625|TRANSFER_SMPTE_170M|RANGE_FULL) Hal-Client-usage:0x3(0|SW_READ_OFTEN) Real:0x32315659(YV12) Request:0x23(YCbCr_420_888) Override:0x23(YCbCr_420_888) Hal-usage:0x20033(0|SW_READ_OFTEN|SW_WRITE_OFTEN|HW_CAMERA_WRITE) HalStream::(consumer/producer)Usage:0/0x20033 bufOffset:  0 rowStrideInBytes/sizeInBytes: 1280/921600 640/230400 640/263040 s3:d0:App:YV12:0|SW_READ_OFTEN 0x9f76cf00
2023-12-06 15:16:09.005   526-1115  Camera3-Device          cameraserver                         D  Set real time priority for request queue thread (tid 11055)
2023-12-06 15:16:09.006 10591-10591 Binder                  pid-10591                            D  <<<<< Spending more than 136 ms on Binder:android.hardware.camera2.ICameraDeviceUser#6
2023-12-06 15:16:09.007 10591-11047 CreateCaptureSession    pid-10591                            I  Camera 0: Capture Session #1002 configured!
2023-12-06 15:16:09.008 10591-10591 CameraSession           pid-10591                            I  Successfully configured Session with 1 outputs for Camera #0!
2023-12-06 15:16:09.008 10591-10591 CameraSession           pid-10591                            I  Successfully updated CameraSession Configuration! isActive: false
2023-12-06 15:16:09.011 10591-10591 CameraView              pid-10591                            I  Updating CameraSession...
2023-12-06 15:16:09.011 10591-11047 CameraSession           pid-10591                            I  Updating CameraSession Configuration...
2023-12-06 15:16:09.012 10591-11047 CameraSession           pid-10591                            W  Called configure(...) but nothing changed...
2023-12-06 15:16:09.012 10591-11047 CreateCaptureSession    pid-10591                            I  Camera 0: Capture Session #1001 closed!
2023-12-06 15:16:10.082   543-11822 chatty                  camerahalserver                      I  uid=1047(cameraserver) /vendor/bin/hw/camerahalserver identical 7 lines
2023-12-06 15:16:45.061   526-999   Camera3-Device          cameraserver                         I  disconnect: E
2023-12-06 15:16:45.061   526-999   CameraLatencyHistogram  cameraserver                         I  ProcessCaptureRequest latency histogram (2934) samples:
2023-12-06 15:16:45.061   526-999   CameraLatencyHistogram  cameraserver                         I         40     80    120    160    200    240    280    320    360    inf (max ms)
2023-12-06 15:16:45.061   526-999   CameraLatencyHistogram  cameraserver                         I       2.35   97.61   0.00   0.03   0.00   0.00   0.00   0.00   0.00   0.00 (%)
2023-12-06 15:16:45.119   543-543   BWC                     camerahalserver                      I  Profile_Change:[BWCPT_CAMERA_CAPTURE]:OFF,current concurrency is 0x0,DDR=,EMI scenario=BWL_SCN_ICFP OFF
2023-12-06 15:16:45.326   526-999   CameraProviderManager   cameraserver                         I  Camera device device@3.4/internal/0 torch status is now AVAILABLE_OFF
2023-12-06 15:16:45.326   526-999   CameraService           cameraserver                         I  onTorchStatusChangedLocked: Torch status changed for cameraId=0, newStatus=1
2023-12-06 15:16:45.327  1101-7623  CameraManagerGlobal     com.android.systemui                 E  package_name:getCameraIdList beforecom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit
2023-12-06 15:16:45.327  1101-7623  CameraManagerGlobal     com.android.systemui                 E  package_name:getCameraIdList aftercom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit,android.app.stubs,com.android.phone,com.ape.calibrationforsale
2023-12-06 15:16:45.327  1565-1577  CameraManagerGlobal     com.mediatek.ims                     E  package_name:getCameraIdList beforecom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit
2023-12-06 15:16:45.327  1565-1577  CameraManagerGlobal     com.mediatek.ims                     E  package_name:getCameraIdList aftercom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit,android.app.stubs,com.android.phone,com.ape.calibrationforsale
2023-12-06 15:16:45.327   526-999   CameraProviderManager   cameraserver                         I  Camera device device@3.4/internal/2 torch status is now AVAILABLE_OFF
2023-12-06 15:16:45.327   526-999   CameraService           cameraserver                         I  onTorchStatusChangedLocked: Torch status changed for cameraId=2, newStatus=1
2023-12-06 15:16:45.327  4924-5847  CameraManagerGlobal     com.motorola.ccc                     E  package_name:getCameraIdList beforecom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit
2023-12-06 15:16:45.327  1101-7623  CameraManagerGlobal     com.android.systemui                 E  package_name:getCameraIdList beforecom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit
2023-12-06 15:16:45.327  4924-5847  CameraManagerGlobal     com.motorola.ccc                     E  package_name:getCameraIdList aftercom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit,android.app.stubs,com.android.phone,com.ape.calibrationforsale
2023-12-06 15:16:45.327  1101-7623  CameraManagerGlobal     com.android.systemui                 E  package_name:getCameraIdList aftercom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit,android.app.stubs,com.android.phone,com.ape.calibrationforsale
2023-12-06 15:16:45.327  1101-7623  CameraManagerGlobal     com.android.systemui                 W  ignore the torch status update of camera: 2
2023-12-06 15:16:45.327  1565-1577  CameraManagerGlobal     com.mediatek.ims                     E  package_name:getCameraIdList beforecom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit
2023-12-06 15:16:45.327  1565-1577  CameraManagerGlobal     com.mediatek.ims                     E  package_name:getCameraIdList aftercom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit,android.app.stubs,com.android.phone,com.ape.calibrationforsale
2023-12-06 15:16:45.327  4924-5847  CameraManagerGlobal     com.motorola.ccc                     E  package_name:getCameraIdList beforecom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit
2023-12-06 15:16:45.327  4924-5847  CameraManagerGlobal     com.motorola.ccc                     E  package_name:getCameraIdList aftercom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit,android.app.stubs,com.android.phone,com.ape.calibrationforsale
2023-12-06 15:16:45.327  1565-1577  CameraManagerGlobal     com.mediatek.ims                     W  ignore the torch status update of camera: 2
2023-12-06 15:16:45.327   526-999   CameraProviderManager   cameraserver                         I  Camera device device@3.4/internal/3 torch status is now AVAILABLE_OFF
2023-12-06 15:16:45.327  4924-5847  CameraManagerGlobal     com.motorola.ccc                     W  ignore the torch status update of camera: 2
2023-12-06 15:16:45.328   526-999   CameraService           cameraserver                         I  onTorchStatusChangedLocked: Torch status changed for cameraId=3, newStatus=1
2023-12-06 15:16:45.328  1565-1577  CameraManagerGlobal     com.mediatek.ims                     E  package_name:getCameraIdList beforecom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit
2023-12-06 15:16:45.328  1101-7623  CameraManagerGlobal     com.android.systemui                 E  package_name:getCameraIdList beforecom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit
2023-12-06 15:16:45.328  4924-5847  CameraManagerGlobal     com.motorola.ccc                     E  package_name:getCameraIdList beforecom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit
2023-12-06 15:16:45.328  1101-7623  CameraManagerGlobal     com.android.systemui                 E  package_name:getCameraIdList aftercom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit,android.app.stubs,com.android.phone,com.ape.calibrationforsale
2023-12-06 15:16:45.328  4924-5847  CameraManagerGlobal     com.motorola.ccc                     E  package_name:getCameraIdList aftercom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit,android.app.stubs,com.android.phone,com.ape.calibrationforsale
2023-12-06 15:16:45.328  1101-7623  CameraManagerGlobal     com.android.systemui                 W  ignore the torch status update of camera: 3
2023-12-06 15:16:45.328  4924-5847  CameraManagerGlobal     com.motorola.ccc                     W  ignore the torch status update of camera: 3
2023-12-06 15:16:45.328  1565-1577  CameraManagerGlobal     com.mediatek.ims                     E  package_name:getCameraIdList aftercom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit,android.app.stubs,com.android.phone,com.ape.calibrationforsale
2023-12-06 15:16:45.328  1565-1577  CameraManagerGlobal     com.mediatek.ims                     W  ignore the torch status update of camera: 3
2023-12-06 15:16:45.334   526-999   Camera3-OutputStream    cameraserver                         W  disconnectLocked: While disconnecting stream 3 from native window, the native window died from under us
2023-12-06 15:16:45.334   526-999   Camera3-Device          cameraserver                         I  disconnect: X
2023-12-06 15:16:45.334   526-999   Camera3-Device          cameraserver                         I  disconnect: E
2023-12-06 15:16:45.336  1565-1577  CameraManagerGlobal     com.mediatek.ims                     E  package_name:getCameraIdList beforecom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit
2023-12-06 15:16:45.336  1101-7623  CameraManagerGlobal     com.android.systemui                 E  package_name:getCameraIdList beforecom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit
2023-12-06 15:16:45.336  4924-5847  CameraManagerGlobal     com.motorola.ccc                     E  package_name:getCameraIdList beforecom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit
2023-12-06 15:16:45.336  1101-7623  CameraManagerGlobal     com.android.systemui                 E  package_name:getCameraIdList aftercom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit,android.app.stubs,com.android.phone,com.ape.calibrationforsale
2023-12-06 15:16:45.336  1565-1577  CameraManagerGlobal     com.mediatek.ims                     E  package_name:getCameraIdList aftercom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit,android.app.stubs,com.android.phone,com.ape.calibrationforsale
2023-12-06 15:16:45.336  4924-5847  CameraManagerGlobal     com.motorola.ccc                     E  package_name:getCameraIdList aftercom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit,android.app.stubs,com.android.phone,com.ape.calibrationforsale
2023-12-06 15:16:45.336   526-999   CameraService           cameraserver                         I  disconnect: Disconnected client for camera 0 for PID 10591
2023-12-06 15:16:45.339   526-999   Camera2ClientBase       cameraserver                         I  Closed Camera 0. Client was: com.xxxx (PID 10591, UID 10464)
2023-12-06 15:16:45.340   526-999   CameraService           cameraserver                         E  binderDied: Java client's binder died, removing it from the list of active clients
2023-12-06 15:17:14.954 12037-12209 CameraManagerGlobal     pid-12037                            I  Connecting to camera service
2023-12-06 15:17:14.966 12037-12209 CameraManagerGlobal     pid-12037                            E  package_name:getCameraIdList beforecom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit
2023-12-06 15:17:14.966 12037-12209 CameraManagerGlobal     pid-12037                            E  package_name:getCameraIdList aftercom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit,android.app.stubs,com.android.phone,com.ape.calibrationforsale
2023-12-06 15:17:14.967 12037-12209 CameraManagerGlobal     pid-12037                            E  package_name:getCameraIdList beforecom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit
2023-12-06 15:17:14.967 12037-12209 CameraManagerGlobal     pid-12037                            E  package_name:getCameraIdList aftercom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit,android.app.stubs,com.android.phone,com.ape.calibrationforsale
2023-12-06 15:17:14.967 12037-12209 CameraManagerGlobal     pid-12037                            E  package_name:getCameraIdList beforecom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit
2023-12-06 15:17:14.967 12037-12209 CameraManagerGlobal     pid-12037                            E  package_name:getCameraIdList aftercom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit,android.app.stubs,com.android.phone,com.ape.calibrationforsale
2023-12-06 15:17:14.967 12037-12209 CameraManagerGlobal     pid-12037                            W  [soar.cts] ignore the status update of camera: 2
2023-12-06 15:17:14.968 12037-12209 CameraManagerGlobal     pid-12037                            E  package_name:getCameraIdList beforecom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit
2023-12-06 15:17:14.968 12037-12209 CameraManagerGlobal     pid-12037                            E  package_name:getCameraIdList aftercom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit,android.app.stubs,com.android.phone,com.ape.calibrationforsale
2023-12-06 15:17:14.968 12037-12209 CameraManagerGlobal     pid-12037                            W  [soar.cts] ignore the status update of camera: 3
2023-12-06 15:17:14.968 12037-12209 CameraManagerGlobal     pid-12037                            E  package_name:getCameraIdList beforecom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit
2023-12-06 15:17:14.968 12037-12209 CameraManagerGlobal     pid-12037                            E  package_name:getCameraIdList aftercom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit,android.app.stubs,com.android.phone,com.ape.calibrationforsale
2023-12-06 15:17:14.969 12037-12051 CameraManagerGlobal     pid-12037                            E  package_name:getCameraIdList beforecom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit
2023-12-06 15:17:14.969 12037-12051 CameraManagerGlobal     pid-12037                            E  package_name:getCameraIdList aftercom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit,android.app.stubs,com.android.phone,com.ape.calibrationforsale
2023-12-06 15:17:14.970 12037-12051 CameraManagerGlobal     pid-12037                            E  package_name:getCameraIdList beforecom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit
2023-12-06 15:17:14.970 12037-12051 CameraManagerGlobal     pid-12037                            E  package_name:getCameraIdList aftercom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit,android.app.stubs,com.android.phone,com.ape.calibrationforsale
2023-12-06 15:17:14.970 12037-12051 CameraManagerGlobal     pid-12037                            W  ignore the torch status update of camera: 2
2023-12-06 15:17:14.971 12037-12051 CameraManagerGlobal     pid-12037                            E  package_name:getCameraIdList beforecom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit
2023-12-06 15:17:14.971 12037-12051 CameraManagerGlobal     pid-12037                            E  package_name:getCameraIdList aftercom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit,android.app.stubs,com.android.phone,com.ape.calibrationforsale
2023-12-06 15:17:14.971 12037-12051 CameraManagerGlobal     pid-12037                            W  ignore the torch status update of camera: 3
2023-12-06 15:17:15.874 12037-12230 unknown:Vi...rtyUpdater pid-12037                            W  Could not find generated setter for class com.mrousavy.camera.CameraViewManager
2023-12-06 15:17:16.093 12037-12230 CameraDevices           pid-12037                            I  Camera #0: Available!
2023-12-06 15:17:16.093 12037-12230 CameraDevices           pid-12037                            I  Camera #1: Available!
2023-12-06 15:20:42.157 12767-12943 CameraManagerGlobal     pid-12767                            I  Connecting to camera service
2023-12-06 15:20:42.161 12767-12943 CameraManagerGlobal     pid-12767                            E  package_name:getCameraIdList beforecom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit
2023-12-06 15:20:42.162 12767-12943 CameraManagerGlobal     pid-12767                            E  package_name:getCameraIdList aftercom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit,android.app.stubs,com.android.phone,com.ape.calibrationforsale
2023-12-06 15:20:42.162 12767-12943 CameraManagerGlobal     pid-12767                            E  package_name:getCameraIdList beforecom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit
2023-12-06 15:20:42.162 12767-12943 CameraManagerGlobal     pid-12767                            E  package_name:getCameraIdList aftercom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit,android.app.stubs,com.android.phone,com.ape.calibrationforsale
2023-12-06 15:20:42.162 12767-12943 CameraManagerGlobal     pid-12767                            E  package_name:getCameraIdList beforecom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit
2023-12-06 15:20:42.162 12767-12943 CameraManagerGlobal     pid-12767                            E  package_name:getCameraIdList aftercom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit,android.app.stubs,com.android.phone,com.ape.calibrationforsale
2023-12-06 15:20:42.162 12767-12943 CameraManagerGlobal     pid-12767                            W  [soar.cts] ignore the status update of camera: 2
2023-12-06 15:20:42.162 12767-12943 CameraManagerGlobal     pid-12767                            E  package_name:getCameraIdList beforecom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit
2023-12-06 15:20:42.162 12767-12943 CameraManagerGlobal     pid-12767                            E  package_name:getCameraIdList aftercom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit,android.app.stubs,com.android.phone,com.ape.calibrationforsale
2023-12-06 15:20:42.162 12767-12943 CameraManagerGlobal     pid-12767                            W  [soar.cts] ignore the status update of camera: 3
2023-12-06 15:20:42.162 12767-12943 CameraManagerGlobal     pid-12767                            E  package_name:getCameraIdList beforecom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit
2023-12-06 15:20:42.163 12767-12943 CameraManagerGlobal     pid-12767                            E  package_name:getCameraIdList aftercom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit,android.app.stubs,com.android.phone,com.ape.calibrationforsale
2023-12-06 15:20:42.163 12767-12958 CameraManagerGlobal     pid-12767                            E  package_name:getCameraIdList beforecom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit
2023-12-06 15:20:42.163 12767-12958 CameraManagerGlobal     pid-12767                            E  package_name:getCameraIdList aftercom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit,android.app.stubs,com.android.phone,com.ape.calibrationforsale
2023-12-06 15:20:42.164 12767-12958 CameraManagerGlobal     pid-12767                            E  package_name:getCameraIdList beforecom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit
2023-12-06 15:20:42.164 12767-12958 CameraManagerGlobal     pid-12767                            E  package_name:getCameraIdList aftercom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit,android.app.stubs,com.android.phone,com.ape.calibrationforsale
2023-12-06 15:20:42.164 12767-12958 CameraManagerGlobal     pid-12767                            W  ignore the torch status update of camera: 2
2023-12-06 15:20:42.164 12767-12958 CameraManagerGlobal     pid-12767                            E  package_name:getCameraIdList beforecom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit
2023-12-06 15:20:42.164 12767-12958 CameraManagerGlobal     pid-12767                            E  package_name:getCameraIdList aftercom.myos.camera,com.ape.camfaccalibration,com.android.cts.verifier,android.camera.cts,com.motorola.motocit,android.app.stubs,com.android.phone,com.ape.calibrationforsale
2023-12-06 15:20:42.164 12767-12958 CameraManagerGlobal     pid-12767                            W  ignore the torch status update of camera: 3
2023-12-06 15:20:43.048 12767-12963 unknown:Vi...rtyUpdater pid-12767                            W  Could not find generated setter for class com.mrousavy.camera.CameraViewManager
2023-12-06 15:20:43.253 12767-12963 CameraDevices           pid-12767                            I  Camera #0: Available!
2023-12-06 15:20:43.253 12767-12963 CameraDevices           pid-12767                            I  Camera #1: Available!

Camera Device

{
    "hardwareLevel": "full",
    "hasFlash": true,
    "hasTorch": true,
    "id": "0",
    "isMultiCam": false,
    "maxExposure": 72,
    "maxZoom": 8,
    "minExposure": -72,
    "minZoom": 1,
    "name": "BACK (0)",
    "neutralZoom": 1,
    "physicalDevices": [
        "wide-angle-camera"
    ],
    "position": "back",
    "sensorOrientation": "landscape-right",
    "supportsFocus": true,
    "supportsLowLightBoost": false,
    "supportsRawCapture": true
}

Device

Motorola Moto g6 Plus

VisionCamera Version

3.6.13

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

SayeedAfridi commented 9 months ago

+1 Getting the same error. version 3.6.14

nemmtor commented 9 months ago

+1

raerta commented 9 months ago

I got this error too. If you're getting the error but can use the camera, you can use onError to prevent the error from appearing in the app.

onError={handleCameraError}

<Camera lowLightBoost enableZoomGesture zoom={2} style={StyleSheet.absoluteFill} device={device} isActive={isActive} codeScanner={codeScanner} focusable torch={torchIsOpen ? 'on' : 'off'} onError={handleCameraError} />

const handleCameraError = (e: any) => { console.log('error', e); };

gsagergithub commented 9 months ago

I got this error too. If you're getting the error but can use the camera, you can use onError to prevent the error from appearing in the app.

onError={handleCameraError}

<Camera lowLightBoost enableZoomGesture zoom={2} style={StyleSheet.absoluteFill} device={device} isActive={isActive} codeScanner={codeScanner} focusable torch={torchIsOpen ? 'on' : 'off'} onError={handleCameraError} />

const handleCameraError = (e: any) => { console.log('error', e); };

I can't use the camera at all. It shows as a black screen.

BarbieriMatheus commented 9 months ago

+1

But when I use codeScanner this error doesn't appear.

MicaelaWaigel commented 9 months ago

+1

haouarihk commented 9 months ago

+1

raerta commented 9 months ago

Change your conditional rendering logic like this:

{ device && <Camera style={styles.container} device={device} isActive={isActive} codeScanner={codeScanner} enableZoomGesture={true} /> }

MicaelaWaigel commented 9 months ago

Change your conditional rendering logic like this:

{ device && <Camera style={styles.container} device={device} isActive={isActive} codeScanner={codeScanner} enableZoomGesture={true} /> }

It doesn't work anyway..

DevVibhor commented 9 months ago

Facing the same issue.

haouarihk commented 9 months ago

For me its super unstable and causes crashes everytime i either switch the camera Or navigate to and from another page using the navigation library. And sometimes when i show a overlay on top of the view.

It caused me a day of debugging, and it's still happening. I'm on min sdk 26. I use react native without expo bloat

Btw changing from if(device == null) return ; to if(!device) return; helped alot but still not enough

Apparently device can be undefined(i think). Which is contradictory to the docs.

Thanks IHateRNToDontWorry :)

paulovictor237 commented 9 months ago

I'm going through the same problem. Android 12 and below: presents the same error Android 13 and above: works normally

However, 25% of my app's user base are on Android version 12, making the use of the library unfeasible.

engrwaqasali commented 9 months ago

+1 getting the same error code and video is attached on first render the camera shows up correctly but when navigate back and forth its black screen

i noticed one thing when i change the navigator from bottom tab, the camera then works just fine

import React, { ReactNode, useEffect } from 'react';
import { Image, Linking, StyleSheet, View } from 'react-native';
import {
  Camera,
  useCameraDevice,
  useCameraPermission,
  useCodeScanner,
} from 'react-native-vision-camera';
import { Colors } from '../theme';
import { AppText, Button } from './theme';
type Props = {
  isActive: boolean;
  onScan: (codes: string) => void;
  children?: ReactNode | JSX.Element;
};

const QRCodeScanner = ({ isActive, onScan, children }: Props) => {
  const { hasPermission, requestPermission } = useCameraPermission();
  const device = useCameraDevice('back');

  const codeScanner = useCodeScanner({
    codeTypes: ['qr', 'ean-13'],
    onCodeScanned: (codes) => {
      console.log(`Scanned ${codes.length} codes!`);
      if (codes?.length > 0) {
        if (codes[0].value) {
          console.log('Scanned code', codes[0].value);
          onScan(codes[0].value);
        }
      }
    },
  });

  const getPermission = async () => {
    if (!hasPermission) {
      const res = await requestPermission();
      if (!res) {
        Linking.openSettings();
      }
    }
  };

  useEffect(() => {
    getPermission();
  }, [hasPermission]);

  if (!hasPermission || !device)
    return (
      <View
        style={{
          flex: 1,
          alignItems: 'center',
          justifyContent: 'center',
          backgroundColor: Colors.background,
          margin: 32,
          gap: 24,
        }}
      >
        <AppText>Shido needs access to Camera</AppText>
        <Button
          title={'Open Settings'}
          onPress={() => Linking.openSettings()}
        />
      </View>
    );
  return (
    <View style={styles.container}>
      <Camera
        key={device.id}
        isActive={isActive}
        device={device}
        codeScanner={codeScanner}
        style={StyleSheet.absoluteFill}
      />
      <Image
        style={styles.image}
        source={require('../assets/images/Frame.png')}
      />
      {children}
    </View>
  );
};

export default QRCodeScanner;

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 24,
    alignItems: 'center',
    justifyContent: 'center',
  },
  closeButton: {
    position: 'absolute',
    top: 24,
    left: 24,
  },
  image: {
    width: 240,
    height: 240,
    alignSelf: 'center',
    alignItems: 'center',
    justifyContent: 'center',
  },
});

https://github.com/mrousavy/react-native-vision-camera/assets/67859620/9155ac93-019c-465a-8984-f247df6f3391

engrwaqasali commented 9 months ago

+1 getting the same error code and video is attached on first render the camera shows up correctly but when navigate back and forth its black screen

i noticed one thing when i change the navigator from bottom tab, the camera then works just fine

import React, { ReactNode, useEffect } from 'react';
import { Image, Linking, StyleSheet, View } from 'react-native';
import {
  Camera,
  useCameraDevice,
  useCameraPermission,
  useCodeScanner,
} from 'react-native-vision-camera';
import { Colors } from '../theme';
import { AppText, Button } from './theme';
type Props = {
  isActive: boolean;
  onScan: (codes: string) => void;
  children?: ReactNode | JSX.Element;
};

const QRCodeScanner = ({ isActive, onScan, children }: Props) => {
  const { hasPermission, requestPermission } = useCameraPermission();
  const device = useCameraDevice('back');

  const codeScanner = useCodeScanner({
    codeTypes: ['qr', 'ean-13'],
    onCodeScanned: (codes) => {
      console.log(`Scanned ${codes.length} codes!`);
      if (codes?.length > 0) {
        if (codes[0].value) {
          console.log('Scanned code', codes[0].value);
          onScan(codes[0].value);
        }
      }
    },
  });

  const getPermission = async () => {
    if (!hasPermission) {
      const res = await requestPermission();
      if (!res) {
        Linking.openSettings();
      }
    }
  };

  useEffect(() => {
    getPermission();
  }, [hasPermission]);

  if (!hasPermission || !device)
    return (
      <View
        style={{
          flex: 1,
          alignItems: 'center',
          justifyContent: 'center',
          backgroundColor: Colors.background,
          margin: 32,
          gap: 24,
        }}
      >
        <AppText>Shido needs access to Camera</AppText>
        <Button
          title={'Open Settings'}
          onPress={() => Linking.openSettings()}
        />
      </View>
    );
  return (
    <View style={styles.container}>
      <Camera
        key={device.id}
        isActive={isActive}
        device={device}
        codeScanner={codeScanner}
        style={StyleSheet.absoluteFill}
      />
      <Image
        style={styles.image}
        source={require('../assets/images/Frame.png')}
      />
      {children}
    </View>
  );
};

export default QRCodeScanner;

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 24,
    alignItems: 'center',
    justifyContent: 'center',
  },
  closeButton: {
    position: 'absolute',
    top: 24,
    left: 24,
  },
  image: {
    width: 240,
    height: 240,
    alignSelf: 'center',
    alignItems: 'center',
    justifyContent: 'center',
  },
});

WhatsApp.Video.2023-12-20.at.2.10.52.PM.mp4

https://github.com/mrousavy/react-native-vision-camera/issues/2291#issuecomment-1862274019 this solution worked for me for now

FirmanDiazSukmawan commented 9 months ago

Same problem when my camera app on from Instagram or other apk i cannot open camera in my app always disconect but when other apk camera close i Can open the camera in my apk

paulovictor237 commented 8 months ago

I managed to solve this bug by activating the video option. It's not a bug-fix, but it worked for me. Try doing the same as me and see if it works for you too.

function App() {
  const device = useCameraDevice('back')
  if (!device) return null
  return (
    <Camera
      style={StyleSheet.absoluteFill}
      device={device}
      isActive={true}
      photo={true}
      video={true}
    />
  )
}
mrousavy commented 8 months ago

I think this has been fixed in the latest version (here on main)

Please try the example app and let me know if the problem is gone!

bglgwyng commented 8 months ago

I'm still facing the same issue. I opened the example app and repeated flipping the direction. My device is a Galaxy S10, Android 12.

logs: https://gist.github.com/bglgwyng/cfe64520b4fbd56a5c74fb153e892f4d

mrousavy commented 7 months ago

Is this fixed in 3.9.x @bglgwyng ?

abakers commented 7 months ago

Is this fixed in 3.9.x @bglgwyng ?

Nope, we're still experiencing this issue. Version 3.9.0

Henriquehlr commented 7 months ago

I'm facing the same issue on Android 12 when navigating between screens

version: 3.9.0

t0x1c123 commented 6 months ago

Same here

erenkulaksiz commented 6 months ago

same here!

perseon commented 6 months ago

Samsung S20FE / Android 13. Same error running the example app.

juicydevka commented 5 months ago

The same in 3.9.2 but only crash on navigate to the other screen from the screen with camera. ERROR Camera.onError(session/camera-has-been-disconnected): [session/camera-has-been-disconnected] The given Camera device (id: 0) has been disconnected! Error: CAMERA_IS_DISABLED_BY_ANDROID [session/camera-has-been-disconnected: [session/camera-has-been-disconnected] The given Camera device (id: 0) has been disconnected! Error: CAMERA_IS_DISABLED_BY_ANDROID]

Any android emulator and physical device Samsung S23 - Android 14

Temporary fix - disable camera and then navigate with timeout 200-300 ms

matheuscaet commented 5 months ago

I'm getting this issue at 3.7.0 version, It's closed but I didn't get the resolution. Should I upgrade to which version?

ADaRShsiNgh456 commented 2 months ago

Okk