mrousavy / react-native-vision-camera

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

🐛 Flash not waiting for auto-exposure to settle on Android #2464

Closed marksadc closed 9 months ago

marksadc commented 9 months ago

What's happening?

I'm using my to take photos of documents, however using flash to take a photo in dark environment results in really blurred quality. The first picture is taken using flash with regular phone camera, the second one is taken in app using react-native-vision-camera.

PXL_20240131_090521539 Screenshot_20240131-110543

Reproduceable Code

export const Scanner = (props: ScannerProps) => {
  const device = useCameraDevice('back');

  if (device == null) return null;

  return (
    <>
      <Camera
        style={StyleSheet.absoluteFill}
        device={device}
        isActive={true}
        enableHighQualityPhotos={true}
        photo={true}
        ref={props.camera}
      />
    </>
  );
};

export const ScanScreen= () => {
  const camera = useRef<Camera>(null);
  const [photo, setPhoto] = useState<PhotoFile>();

  const takePhoto = async () => {
    try {
      const photo = await camera.current.takePhoto({
        flash: 'on',
        qualityPrioritization: 'quality',
        enableAutoStabilization: true,
        enableAutoDistortionCorrection: Platform.OS !== 'ios',
      });

      setPhoto(photo);
    } catch (err) {
      console.log(err);
    }
  };

  const cameraButton = () => {
    return (
      <Pressable onPress={takePhoto}>
        <CameraButtonActiveSVG />
      </Pressable>
    );
  };

  if (photo) {
    return (
      <Image
        source={{ uri: `file://${photo.path}` }}
        style={{ resizeMode: 'contain', flex: 1 }}
      />
    );
  }

  return (
    <View
      style={{
        height: '100%',
      }}
    >
      <Scanner camera={camera} />
      {cameraButton()}
    </View>
  );
};

Relevant log output

2024-01-31 11:26:44.117 30689-32485 ReactNativeJS           agentapp                  I  {
  "formats": [],
  "sensorOrientation": "landscape-right",
  "hardwareLevel": "full",
  "maxZoom": 7,
  "minZoom": 0.6009132266044617,
  "maxExposure": 24,
  "supportsLowLightBoost": true,
  "neutralZoom": 1,
  "physicalDevices": [
    "wide-angle-camera",
    "ultra-wide-angle-camera"
  ],
  "supportsFocus": true,
  "supportsRawCapture": true,
  "isMultiCam": true,
  "minFocusDistance": 9.800000093460085,
  "minExposure": -24,
  "name": "BACK (0)",
  "hasFlash": true,
  "hasTorch": true,
  "position": "back",
  "id": "0"
}
2024-01-31 11:26:44.126 30689-30689 PreviewView             agentapp                  I  Creating PreviewView...
2024-01-31 11:26:44.126 30689-30689 PreviewView             agentapp                  I  PreviewView is 0x0, rendering 1080x1920 content. Resizing to: 0x0 (COVER)
2024-01-31 11:26:44.127 30689-30689 CameraView              agentapp                  I  Updating CameraSession...
2024-01-31 11:26:44.127 30689-30884 CameraSession           agentapp                  I  configure { ... }: Waiting for lock...
2024-01-31 11:26:44.127 30689-30884 CameraSession           agentapp                  I  configure { ... }: Updating CameraSession Configuration... Difference(deviceChanged=true, outputsChanged=true, sidePropsChanged=true, isActiveChanged=true)
2024-01-31 11:26:44.127 30689-30884 CameraSession           agentapp                  I  Need to rebuild CameraDevice and CameraCaptureSession...
2024-01-31 11:26:44.127 30689-30884 CameraSession           agentapp                  I  CameraDevice and CameraCaptureSession is torn down but Camera is not active, skipping update...
2024-01-31 11:26:44.128 30689-30884 CameraSession           agentapp                  I  Successfully updated CameraSession Configuration! isActive: false
2024-01-31 11:26:44.128 30689-30884 CameraView              agentapp                  I  invokeOnInitialized()
2024-01-31 11:26:44.150 30689-2952  TrafficStats            agentapp                  D  tagSocket(121) with statsTag=0xffffffff, statsUid=-1
2024-01-31 11:26:44.164 30689-30689 CameraView              agentapp                  I  Updating CameraSession...
2024-01-31 11:26:44.165 30689-30884 CameraSession           agentapp                  I  configure { ... }: Waiting for lock...
2024-01-31 11:26:44.165 30689-30884 CameraSession           agentapp                  I  configure { ... }: Updating CameraSession Configuration... Difference(deviceChanged=true, outputsChanged=true, sidePropsChanged=true, isActiveChanged=true)
2024-01-31 11:26:44.165 30689-30884 CameraSession           agentapp                  I  Need to rebuild CameraDevice and CameraCaptureSession...
2024-01-31 11:26:44.165 30689-30884 CameraSession           agentapp                  I  Need to rebuild CameraDevice and CameraCaptureSession...
2024-01-31 11:26:44.166 30689-30884 CameraSession           agentapp                  I  Configuring Camera #0...
2024-01-31 11:26:44.166 30689-30884 CameraManager           agentapp                  I  Camera #0: Opening...
2024-01-31 11:26:44.168 30689-30689 PreviewView             agentapp                  I  PreviewView is 1080x2205, rendering 1080x1920 content. Resizing to: 1240x2205 (COVER)
2024-01-31 11:26:44.171   923-1696  CameraService           cameraserver                         I  CameraService::connect call (PID 30689 "agentapp", camera ID 0) and Camera API version 2
2024-01-31 11:26:44.171   923-1696  Camera2ClientBase       cameraserver                         I  Camera 0: Opened. Client: agentapp (PID 30689, UID 10296)
2024-01-31 11:26:44.173 30689-32486 CameraDevices           agentapp                  I  Camera #0 is now unavailable.
2024-01-31 11:26:44.175 30689-30689 CameraSession           agentapp                  I  PreviewView Surface created! Surface(name=null)/@0x28ddfc
2024-01-31 11:26:44.175 30689-30689 CameraSession           agentapp                  I  Setting Preview Output...
2024-01-31 11:26:44.175 30689-30689 CameraSession           agentapp                  I  PreviewView Surface updated! Surface(name=null)/@0x28ddfc 1240 x 2205
2024-01-31 11:26:44.184 30689-30884 CameraSession           agentapp                  I  configure { ... }: Waiting for lock...
2024-01-31 11:26:44.184 30689-30884 CameraManager           agentapp                  I  Camera #0: Opened!
2024-01-31 11:26:44.194 30689-30884 CameraSession           agentapp                  I  Successfully configured Camera #0!
2024-01-31 11:26:44.194 30689-30884 CameraSession           agentapp                  I  Destroying previous outputs...
2024-01-31 11:26:44.195 30689-30884 CameraSession           agentapp                  I  Creating outputs for Camera #0...
2024-01-31 11:26:44.197 30689-30884 CameraSession           agentapp                  I  Adding 4032x3024 Photo Output in JPEG...
2024-01-31 11:26:44.198 30689-30884 CreateCaptureSession    agentapp                  I  Camera #0: Creating Capture Session #23... (Hardware Level: 1 | Outputs: [PHOTO (4032x3024 in JPEG)])
2024-01-31 11:26:44.198 30689-30884 SurfaceOutput           agentapp                  I  Using optimized stream use case 2 for PHOTO output.
2024-01-31 11:26:44.198 30689-30884 CreateCaptureSession    agentapp                  I  Using new API (>=28)
2024-01-31 11:26:44.282 30689-30884 CreateCaptureSession    agentapp                  I  Camera #0: Successfully created CameraCaptureSession #23!
2024-01-31 11:26:44.282 30689-30884 CameraSession           agentapp                  I  Successfully configured Session with 1 outputs for Camera #0!
2024-01-31 11:26:44.282 30689-30884 CameraSession           agentapp                  I  CameraSession has no repeating outputs (Preview, Video, CodeScanner), skipping CaptureRequest...
2024-01-31 11:26:44.282 30689-30884 CameraSession           agentapp                  I  Successfully updated CameraSession Configuration! isActive: true
2024-01-31 11:26:44.282 30689-30884 CameraView              agentapp                  I  invokeOnInitialized()
2024-01-31 11:26:44.283 30689-30884 CameraSession           agentapp                  I  configure { ... }: Updating CameraSession Configuration... Difference(deviceChanged=false, outputsChanged=true, sidePropsChanged=true, isActiveChanged=false)
2024-01-31 11:26:44.283 30689-30884 CameraSession           agentapp                  I  Destroying previous outputs...
2024-01-31 11:26:44.283 30689-30884 SurfaceOutput           agentapp                  I  Closing 4032x3024 PHOTO ImageReader..
2024-01-31 11:26:44.284 30689-30884 CameraSession           agentapp                  I  Creating outputs for Camera #0...
2024-01-31 11:26:44.287 30689-30884 CameraSession           agentapp                  I  Adding 4032x3024 Photo Output in JPEG...
2024-01-31 11:26:44.293 30689-30884 CameraSession           agentapp                  I  Adding 1920x1080 Preview Output...
2024-01-31 11:26:44.294 30689-30884 CreateCaptureSession    agentapp                  I  Camera #0: Creating Capture Session #24... (Hardware Level: 1 | Outputs: [PHOTO (4032x3024 in JPEG), PREVIEW (1920 x 1080)])
2024-01-31 11:26:44.295 30689-30884 SurfaceOutput           agentapp                  I  Using optimized stream use case 2 for PHOTO output.
2024-01-31 11:26:44.295 30689-30884 SurfaceOutput           agentapp                  I  Using optimized stream use case 1 for PREVIEW output.
2024-01-31 11:26:44.295 30689-30884 CreateCaptureSession    agentapp                  I  Using new API (>=28)
2024-01-31 11:26:44.308 30689-30689 PreviewView             agentapp                  I  Setting PreviewView Surface Size to 1240 x 2205...
2024-01-31 11:26:44.323 30689-30689 CameraSession           agentapp                  I  PreviewView Surface updated! Surface(name=null)/@0x28ddfc 1920 x 1080
2024-01-31 11:26:44.437 30689-30706 BpBinder                agentapp                  I  onLastStrongRef automatically unlinking death recipients: <uncached descriptor>
2024-01-31 11:26:44.437 30689-30884 CreateCaptureSession    agentapp                  I  Camera #0: Successfully created CameraCaptureSession #24!
2024-01-31 11:26:44.437 30689-30884 CreateCaptureSession    agentapp                  I  Camera #0: CameraCaptureSession #23 has been closed.
2024-01-31 11:26:44.438 30689-30884 CameraSession           agentapp                  I  Camera Session android.hardware.camera2.impl.CameraCaptureSessionImpl@24cf094 has been closed.
2024-01-31 11:26:44.438 30689-30884 CameraSession           agentapp                  I  Successfully configured Session with 2 outputs for Camera #0!
2024-01-31 11:26:44.440 30689-30884 CameraView              agentapp                  I  invokeOnStarted()
2024-01-31 11:26:44.440 30689-30884 CameraSession           agentapp                  I  Successfully updated CameraSession Configuration! isActive: true
2024-01-31 11:26:44.845 30689-30799 ReactNativeJNI          agentapp                  I  Memory warning (pressure level: TRIM_MEMORY_RUNNING_LOW) received by JS VM, ignoring because it's non-severe
2024-01-31 11:26:44.845 30689-30869 ReactNativeJNI          agentapp                  I  Memory warning (pressure level: TRIM_MEMORY_RUNNING_LOW) received by JS VM, ignoring because it's non-severe
2024-01-31 11:26:44.846 30689-32485 ReactNativeJNI          agentapp                  I  Memory warning (pressure level: TRIM_MEMORY_RUNNING_LOW) received by JS VM, ignoring because it's non-severe
2024-01-31 11:26:44.853 30689-30840 TrafficStats            agentapp                  D  tagSocket(195) with statsTag=0xffffffff, statsUid=-1
2024-01-31 11:26:44.860 30689-30838 TrafficStats            agentapp                  D  tagSocket(195) with statsTag=0xffffffff, statsUid=-1
2024-01-31 11:26:45.414 30689-3173  TrafficStats            agentapp                  D  tagSocket(198) with statsTag=0xffffffff, statsUid=-1
2024-01-31 11:26:45.423 30689-3175  TrafficStats            agentapp                  D  tagSocket(198) with statsTag=0xffffffff, statsUid=-1
2024-01-31 11:26:46.114 30689-2949  TrafficStats            agentapp                  D  tagSocket(198) with statsTag=0xffffffff, statsUid=-1
2024-01-31 11:26:46.863 30689-30840 TrafficStats            agentapp                  D  tagSocket(198) with statsTag=0xffffffff, statsUid=-1
2024-01-31 11:26:46.874 30689-30838 TrafficStats            agentapp                  D  tagSocket(198) with statsTag=0xffffffff, statsUid=-1
2024-01-31 11:26:47.431 30689-3181  TrafficStats            agentapp                  D  tagSocket(198) with statsTag=0xffffffff, statsUid=-1
2024-01-31 11:26:47.445 30689-3183  TrafficStats            agentapp                  D  tagSocket(198) with statsTag=0xffffffff, statsUid=-1
2024-01-31 11:26:48.125 30689-2949  TrafficStats            agentapp                  D  tagSocket(198) with statsTag=0xffffffff, statsUid=-1
2024-01-31 11:26:48.879 30689-30840 TrafficStats            agentapp                  D  tagSocket(198) with statsTag=0xffffffff, statsUid=-1
2024-01-31 11:26:48.897 30689-30838 TrafficStats            agentapp                  D  tagSocket(198) with statsTag=0xffffffff, statsUid=-1
2024-01-31 11:26:50.136 30689-2949  TrafficStats            agentapp                  D  tagSocket(198) with statsTag=0xffffffff, statsUid=-1
2024-01-31 11:26:50.900 30689-30840 TrafficStats            agentapp                  D  tagSocket(204) with statsTag=0xffffffff, statsUid=-1
2024-01-31 11:26:50.914 30689-30838 TrafficStats            agentapp                  D  tagSocket(198) with statsTag=0xffffffff, statsUid=-1
2024-01-31 11:26:52.152 30689-2949  TrafficStats            agentapp                  D  tagSocket(198) with statsTag=0xffffffff, statsUid=-1
2024-01-31 11:26:52.916 30689-30840 TrafficStats            agentapp                  D  tagSocket(198) with statsTag=0xffffffff, statsUid=-1
2024-01-31 11:26:52.928 30689-30838 TrafficStats            agentapp                  D  tagSocket(198) with statsTag=0xffffffff, statsUid=-1
2024-01-31 11:26:53.489 30689-3193  TrafficStats            agentapp                  D  tagSocket(198) with statsTag=0xffffffff, statsUid=-1
2024-01-31 11:26:53.500 30689-3195  TrafficStats            agentapp                  D  tagSocket(198) with statsTag=0xffffffff, statsUid=-1
2024-01-31 11:26:54.171 30689-2949  TrafficStats            agentapp                  D  tagSocket(198) with statsTag=0xffffffff, statsUid=-1
2024-01-31 11:26:54.939 30689-30840 TrafficStats            agentapp                  D  tagSocket(198) with statsTag=0xffffffff, statsUid=-1
2024-01-31 11:26:54.946 30689-30838 TrafficStats            agentapp                  D  tagSocket(198) with statsTag=0xffffffff, statsUid=-1
2024-01-31 11:26:55.501 30689-3215  TrafficStats            agentapp                  D  tagSocket(198) with statsTag=0xffffffff, statsUid=-1
2024-01-31 11:26:55.514 30689-3217  TrafficStats            agentapp                  D  tagSocket(198) with statsTag=0xffffffff, statsUid=-1
2024-01-31 11:26:56.185 30689-2949  TrafficStats            agentapp                  D  tagSocket(198) with statsTag=0xffffffff, statsUid=-1
2024-01-31 11:26:56.954 30689-30840 TrafficStats            agentapp                  D  tagSocket(198) with statsTag=0xffffffff, statsUid=-1
2024-01-31 11:26:56.960 30689-30838 TrafficStats            agentapp                  D  tagSocket(198) with statsTag=0xffffffff, statsUid=-1
2024-01-31 11:26:58.197 30689-2949  TrafficStats            agentapp                  D  tagSocket(198) with statsTag=0xffffffff, statsUid=-1
2024-01-31 11:26:58.964 30689-30840 TrafficStats            agentapp                  D  tagSocket(198) with statsTag=0xffffffff, statsUid=-1
2024-01-31 11:26:58.976 30689-30838 TrafficStats            agentapp                  D  tagSocket(198) with statsTag=0xffffffff, statsUid=-1
2024-01-31 11:26:59.354 30689-30689 CameraView              agentapp                  D  Finding view 347...
2024-01-31 11:26:59.355 30689-30689 CameraView              agentapp                  D  Found view 347!
2024-01-31 11:26:59.356 30689-30715 CameraView.takePhoto    agentapp                  I  Taking photo... Options: {qualityPrioritization=quality, enableAutoStabilization=true, flash=on, enableAutoDistortionCorrection=true}
2024-01-31 11:26:59.356 30689-30715 CameraSession           agentapp                  I  Photo capture 0/3 - preparing capture request (4032x3024)...
2024-01-31 11:26:59.421 30689-30715 CameraSession           agentapp                  I  Photo capture 1/3 - starting capture...
2024-01-31 11:26:59.457 30689-3221  MediaCodecList          agentapp                  D  codecHandlesFormat: no format, so no extra checks
2024-01-31 11:26:59.460 30689-3222  CCodec                  agentapp                  D  allocate(c2.android.vorbis.decoder)
2024-01-31 11:26:59.468 30689-3222  CCodec                  agentapp                  I  setting up 'default' as default (vendor) store
2024-01-31 11:26:59.487 30689-3222  CCodec                  agentapp                  I  Created component [c2.android.vorbis.decoder]
2024-01-31 11:26:59.487 30689-3222  CCodecConfig            agentapp                  D  read media type: audio/vorbis
2024-01-31 11:26:59.490 30689-3222  ReflectedParamUpdater   agentapp                  D  extent() != 1 for single value type: algo.buffers.max-count.values
2024-01-31 11:26:59.490 30689-3222  ReflectedParamUpdater   agentapp                  D  extent() != 1 for single value type: output.subscribed-indices.values
2024-01-31 11:26:59.490 30689-3222  ReflectedParamUpdater   agentapp                  D  extent() != 1 for single value type: input.buffers.allocator-ids.values
2024-01-31 11:26:59.490 30689-3222  ReflectedParamUpdater   agentapp                  D  extent() != 1 for single value type: output.buffers.allocator-ids.values
2024-01-31 11:26:59.490 30689-3222  ReflectedParamUpdater   agentapp                  D  extent() != 1 for single value type: algo.buffers.allocator-ids.values
2024-01-31 11:26:59.490 30689-3222  ReflectedParamUpdater   agentapp                  D  extent() != 1 for single value type: output.buffers.pool-ids.values
2024-01-31 11:26:59.491 30689-3222  ReflectedParamUpdater   agentapp                  D  extent() != 1 for single value type: algo.buffers.pool-ids.values
2024-01-31 11:26:59.494 30689-3222  CCodecConfig            agentapp                  I  query failed after returning 7 values (BAD_INDEX)
2024-01-31 11:26:59.494 30689-3222  CCodecConfig            agentapp                  D  c2 config diff is Dict {
  c2::u32 coded.bitrate.value = 64000
  c2::u32 input.buffers.max-size.value = 32768
  c2::u32 input.delay.value = 0
  string input.media-type.value = "audio/vorbis"
  string output.media-type.value = "audio/raw"
  c2::u32 raw.channel-count.value = 1
  c2::u32 raw.sample-rate.value = 48000
}
2024-01-31 11:26:59.494 30689-3222  MediaCodec              agentapp                  D  flushMediametrics
2024-01-31 11:26:59.494 30689-3222  CCodec                  agentapp                  D  [c2.android.vorbis.decoder] buffers are bound to CCodec for this session
2024-01-31 11:26:59.494 30689-3222  CCodecConfig            agentapp                  D  no c2 equivalents for durationUs
2024-01-31 11:26:59.494 30689-3222  CCodecConfig            agentapp                  D  no c2 equivalents for track-id
2024-01-31 11:26:59.494 30689-3222  CCodecConfig            agentapp                  D  no c2 equivalents for csd-1
2024-01-31 11:26:59.494 30689-3222  CCodecConfig            agentapp                  D  no c2 equivalents for flags
2024-01-31 11:26:59.495 30689-3222  CCodecConfig            agentapp                  D  c2 config diff is   c2::u32 coded.bitrate.value = 224000
  c2::u32 raw.channel-count.value = 2
2024-01-31 11:26:59.495 30689-3222  Codec2Client            agentapp                  W  query -- param skipped: index = 1107298332.
2024-01-31 11:26:59.495 30689-3222  CCodec                  agentapp                  D  encoding statistics level = 0
2024-01-31 11:26:59.495 30689-3222  CCodec                  agentapp                  D  setup formats input: AMessage(what = 0x00000000) = {
  int32_t bitrate = 224000
  int32_t channel-count = 2
  int32_t max-input-size = 32768
  string mime = "audio/vorbis"
  int32_t sample-rate = 48000
}
2024-01-31 11:26:59.495 30689-3222  CCodec                  agentapp                  D  setup formats output: AMessage(what = 0x00000000) = {
  int32_t channel-count = 2
  string mime = "audio/raw"
  int32_t sample-rate = 48000
  int32_t channel-mask = 3
  int32_t android._config-pcm-encoding = 2
}
2024-01-31 11:26:59.495 30689-3222  CCodecConfig            agentapp                  I  query failed after returning 7 values (BAD_INDEX)
2024-01-31 11:26:59.495 30689-3222  Codec2Client            agentapp                  W  query -- param skipped: index = 1342179345.
2024-01-31 11:26:59.495 30689-3222  Codec2Client            agentapp                  W  query -- param skipped: index = 2415921170.
2024-01-31 11:26:59.497 30689-3222  CCodecBufferChannel     agentapp                  D  [c2.android.vorbis.decoder#52] Created input block pool with allocatorID 16 => poolID 23 - OK (0)
2024-01-31 11:26:59.500 30689-31067 BufferPoolAccessor2.0   agentapp                  D  bufferpool2 0xb400007d736a82b8 : 0(0 size) total buffers - 0(0 size) used buffers - 2/7 (recycle/alloc) - 5/86 (fetch/transfer)
2024-01-31 11:26:59.500 30689-31067 BufferPoolAccessor2.0   agentapp                  D  Destruction - bufferpool2 0xb400007d736a82b8 cached: 0/0M, 0/0% in use; allocs: 7, 29% recycled; transfers: 86, 94% unfetched
2024-01-31 11:26:59.500 30689-3222  CCodecBufferChannel     agentapp                  I  [c2.android.vorbis.decoder#52] Created output block pool with allocatorID 16 => poolID 1268 - OK
2024-01-31 11:26:59.500 30689-3222  CCodecBufferChannel     agentapp                  D  [c2.android.vorbis.decoder#52] Configured output block pool ids 1268 => OK
2024-01-31 11:26:59.542 30689-3222  hw-BpHwBinder           agentapp                  I  onLastStrongRef automatically unlinking death recipients
2024-01-31 11:26:59.543 30689-3222  AMessage                agentapp                  W  failed to deliver message as target handler 21 is gone.
2024-01-31 11:26:59.543 30689-3221  MediaCodec              agentapp                  D  flushMediametrics
2024-01-31 11:26:59.543 30689-3222  AMessage                agentapp                  W  failed to deliver message as target handler 21 is gone.
2024-01-31 11:26:59.731 30689-30884 AudioTrack              agentapp                  I  createTrack_l(127): AUDIO_OUTPUT_FLAG_FAST successful; frameCount 0 -> 19657
2024-01-31 11:26:59.828 30689-30715 CameraSession           agentapp                  I  Photo capture 2/3 complete - received metadata with timestamp 575746194689283
2024-01-31 11:26:59.926 30689-30884 CameraSession           agentapp                  I  Photo Captured!
2024-01-31 11:26:59.926 30689-30884 CameraSession           agentapp                  I  Photo captured! 4032 x 3024
2024-01-31 11:26:59.927 30689-30715 CameraSession           agentapp                  I  Photo capture 3/3 complete - received 4032 x 3024 image.
2024-01-31 11:26:59.927 30689-30715 CameraView.takePhoto    agentapp                  I  Successfully captured 4032 x 3024 photo!
2024-01-31 11:26:59.934 30689-30715 CameraView.takePhoto    agentapp                  I  Successfully saved photo to file! /data/user/0/agentapp/cache/mrousavy4945925749532418145.jpg
2024-01-31 11:26:59.958 30689-30689 CameraSession           agentapp                  I  PreviewView Surface destroyed! Surface(name=null)/@0x28ddfc
2024-01-31 11:26:59.958 30689-30689 CameraSession           agentapp                  I  Destroying Preview Output...
2024-01-31 11:26:59.958 30689-30689 CameraSession           agentapp                  I  configure { ... }: Waiting for lock...
2024-01-31 11:26:59.958 30689-30689 CameraSession           agentapp                  I  configure { ... }: Updating CameraSession Configuration... Difference(deviceChanged=false, outputsChanged=true, sidePropsChanged=true, isActiveChanged=false)
2024-01-31 11:26:59.958 30689-30689 CameraSession           agentapp                  I  Destroying previous outputs...
2024-01-31 11:26:59.958 30689-30689 SurfaceOutput           agentapp                  I  Closing 4032x3024 PHOTO ImageReader..
2024-01-31 11:26:59.959 30689-30689 CameraView              agentapp                  I  invokeOnStopped()
2024-01-31 11:26:59.960 30689-30689 CameraSession           agentapp                  I  Creating outputs for Camera #0...
2024-01-31 11:26:59.964 30689-30689 CameraSession           agentapp                  I  Adding 4032x3024 Photo Output in JPEG...
2024-01-31 11:26:59.966 30689-30689 CreateCaptureSession    agentapp                  I  Camera #0: Creating Capture Session #25... (Hardware Level: 1 | Outputs: [PHOTO (4032x3024 in JPEG)])
2024-01-31 11:26:59.966 30689-30689 SurfaceOutput           agentapp                  I  Using optimized stream use case 2 for PHOTO output.
2024-01-31 11:26:59.967 30689-30689 CreateCaptureSession    agentapp                  I  Using new API (>=28)
2024-01-31 11:27:00.284 30689-30740 BufferQueueProducer     agentapp                  E  [ImageReader-4032x3024f21m10-30689-23](id:77e100000028,api:4,p:923,c:30689) cancelBuffer: BufferQueue has been abandoned
2024-01-31 11:27:00.490 30689-30740 BpBinder                agentapp                  I  onLastStrongRef automatically unlinking death recipients: <uncached descriptor>
2024-01-31 11:27:00.491 30689-30884 CreateCaptureSession    agentapp                  I  Camera #0: Successfully created CameraCaptureSession #25!
2024-01-31 11:27:00.491 30689-30689 CameraSession           agentapp                  I  Successfully configured Session with 1 outputs for Camera #0!
2024-01-31 11:27:00.491 30689-30689 CameraSession           agentapp                  I  CameraSession has no repeating outputs (Preview, Video, CodeScanner), skipping CaptureRequest...
2024-01-31 11:27:00.491 30689-30689 CameraSession           agentapp                  I  Successfully updated CameraSession Configuration! isActive: true
2024-01-31 11:27:00.491 30689-30689 CameraSession           agentapp                  I  Preview Output destroyed!
2024-01-31 11:27:00.492 30689-30689 CameraView              agentapp                  I  Updating CameraSession...
2024-01-31 11:27:00.492 30689-30884 CameraSession           agentapp                  I  configure { ... }: Waiting for lock...
2024-01-31 11:27:00.492 30689-30689 CameraSession           agentapp                  I  Closing CameraSession...
2024-01-31 11:27:00.492 30689-30884 CameraSession           agentapp                  I  CameraSession is already destroyed. Skipping configure { ... }
2024-01-31 11:27:00.492 30689-30689 CameraSession           agentapp                  I  Destroying session..
2024-01-31 11:27:00.545 30689-32486 CameraDevices           agentapp                  I  Camera #0 is now available.
2024-01-31 11:27:00.545 30689-30689 SurfaceOutput           agentapp                  I  Closing 4032x3024 PHOTO ImageReader..
2024-01-31 11:27:00.546 30689-30689 CameraSession           agentapp                  I  CameraSession closed!
2024-01-31 11:27:00.550 30689-30689 Choreographer           agentapp                  I  Skipped 34 frames!  The application may be doing too much work on its main thread.
2024-01-31 11:27:00.557 30689-2949  TrafficStats            agentapp                  D  tagSocket(113) with statsTag=0xffffffff, statsUid=-1

Camera Device

{
  "formats": [],
  "sensorOrientation": "landscape-right",
  "hardwareLevel": "full",
  "maxZoom": 7,
  "minZoom": 0.6009132266044617,
  "maxExposure": 24,
  "supportsLowLightBoost": true,
  "neutralZoom": 1,
  "physicalDevices": [
    "wide-angle-camera",
    "ultra-wide-angle-camera"
  ],
  "supportsFocus": true,
  "supportsRawCapture": true,
  "isMultiCam": true,
  "minFocusDistance": 9.800000093460085,
  "minExposure": -24,
  "name": "BACK (0)",
  "hasFlash": true,
  "hasTorch": true,
  "position": "back",
  "id": "0"
}

Device

Pixel 6A

VisionCamera Version

3.8.2

Can you reproduce this issue in the VisionCamera Example app?

Yes, I can reproduce the same issue in the Example app here

Additional information

mrousavy commented 9 months ago

Thanks for the issue report, and thanks for sharing the logs. People always simply ignore that so I'm glad for every issue that is filled out properly.

This is probably due to Flash not being implemented properly on Android - right now I just set a "FLASH" trigger on the capture, but in reality I would need to issue a pre-capture sequence, trigger a re-exposure, then hit a photo, then trigger a precapture again that stop flash. See this issue for more details: https://github.com/mrousavy/react-native-vision-camera/issues/1890

So I'm closing this issue for now as #1890 will be used to track Flash progress, if you want to get that fixed faster consider sponsoring/adding funds to that moneypool in that issue :)