Skip to content
This repository has been archived by the owner on Jun 16, 2023. It is now read-only.

Front camera is not working in android 10 #2521

Closed
ajitesh-itobuz opened this issue Oct 4, 2019 · 27 comments
Closed

Front camera is not working in android 10 #2521

ajitesh-itobuz opened this issue Oct 4, 2019 · 27 comments
Labels
Android Bug Help Wanted stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@ajitesh-itobuz
Copy link

The rear and front camera is working properly on below android 10 devices but the front camera is not opening in android 10(Google Pixel 3).
The rear camera works fine.

I use it like below
<RNCamera ref={ref => { this.camera = ref; }} style={styles.preview} type={ this.state.cameraFacing === 'back' ? RNCamera.Constants.Type.back : RNCamera.Constants.Type.front } mirrorImage={this.state.mirrorMode} flashMode={ this.state.flash ? RNCamera.Constants.FlashMode.on : RNCamera.Constants.FlashMode.off } androidCameraPermissionOptions={{ title: 'Permission to use camera', message: 'We need your permission to use your camera', buttonPositive: 'Ok', buttonNegative: 'Cancel', }} captureAudio={false} />

@cristianoccazinsp
Copy link
Contributor

Have you tried without setting the mirrorImage prop?

I haven't had issues on Android 10 with a Pixel 2, but I guess Pixel 3 might be different.

For debugging only, have you tried using getCameraIdsAsync and setting the cameraId property to select the front camera instead of using the type prop?

You can easily use the above method and prop to loop through all cameras of the devices.

Lastly, have you tried with useCamera2Api={true} ?

Please provide some android/logcat logs to see if there's something being rejected internally since it is very hard to return errors on props changes.

@stale
Copy link

stale bot commented Dec 5, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and i will leave this open.

@stale stale bot added the stale There has been a lack of activity on this issue and it may be closed soon. label Dec 5, 2019
@stale
Copy link

stale bot commented Dec 12, 2019

Closing this issue after a prolonged period of inactivity. Fell free to reopen this issue, if this still affecting you.

@stale stale bot closed this as completed Dec 12, 2019
@noambonnie
Copy link

I'm observing the problem on Android 10, Samsung Galaxy S10, it only happens with useCamera2API={true}. Works fine with default camera API.

Calling getCameraIdsAsync returns:
[{"id": "0", "type": 0}, {"id": "1", "type": 1}, {"id": "2", "type": 0}, {"id": "3", "type": 1}]

I tried passing '0'-'3' as cameraId, only '0' works and shows the rear camera. Other IDs show a black preview.

Any thoughts? I'm happy with using the old camera API but I need to mute shutter sound using playSoundOnCapture but that prop is only available with camera2 (as far as I can tell).

@sibelius sibelius reopened this Mar 11, 2020
@stale stale bot removed the stale There has been a lack of activity on this issue and it may be closed soon. label Mar 11, 2020
@cristianoccazinsp
Copy link
Contributor

Interesting. You are getting ids from 1 to 3 using the camera 2 API? I believe the Camera 2 API returns strings (more like uuids). Can you verify that you're calling getCameraIdsAsync with a Camera2 instance? Can you try calling that method with a short timeout/delay to see if you get the same results? The reason I ask this, is because I know Camera2 is initialized in an odd way (it first tries with Camera1 and "upgrades" to Camera2), so you might be having a race condition.

However, if not using cameraId also fails, it might be something else. I will try to debug once I get some free time.

In the meantime, you could try adding some breakpoints and debug in here https://github.com/react-native-community/react-native-camera/blob/master/android/src/main/java/com/google/android/cameraview/Camera2.java#L725 and https://github.com/react-native-community/react-native-camera/blob/master/android/src/main/java/com/google/android/cameraview/Camera2.java#L404

@noambonnie
Copy link

noambonnie commented Mar 12, 2020

I double checked that I am using camera2 api when getting camera IDs.

I set a breakpoint as you suggested. I noticed that chooseCameraIdByFacing is being called twice - first time it's setting mCameraId to 0, and preview of the rear camera appears in the app while I'm on the breakpoint (I also hear a physical sound from the rear lens - the device does that when switching to rear cam).

The second time the selected camera is id=1, which I guess is the front facing, and maybe it fails because the other camera is already initialized and there's some race condition where the rear cam has not been released first?

Here are some logcats (filtered for "cam") from launch of the app to trying to access the front camera:

2020-03-12 08:36:27.102 1028-2099/? I/CameraService: onUidStateChanged: uid=10031, procState=16
2020-03-12 08:36:27.940 1028-2099/? I/CameraService: onUidStateChanged: uid=10112, procState=12
2020-03-12 08:36:27.940 1028-2099/? I/CameraService: onUidStateChanged: uid=10031, procState=9
2020-03-12 08:36:27.946 1028-27112/? I/CameraService: onUidStateChanged: uid=10112, procState=20
2020-03-12 08:36:29.393 894-17682/? V/APM_AudioPolicyManager: computeVolume : camera shutter sound volume 1.000000
2020-03-12 08:36:29.431 1028-27112/? I/CameraService: UidPolicy: onUidIdle, uid = 10344
2020-03-12 08:36:29.431 1028-27112/? I/CameraService: onUidStateChanged: uid=10344, procState=20
2020-03-12 08:36:29.544 1028-2099/? I/CameraService: UidPolicy: onUidActive, uid = 10344
2020-03-12 08:36:29.544 1028-2099/? I/CameraService: onUidStateChanged: uid=10344, procState=2
2020-03-12 08:36:29.920 1028-27112/? I/CameraService: onUidStateChanged: uid=99753, procState=6
2020-03-12 08:36:29.920 1028-27112/? I/CameraService: onUidStateChanged: uid=99749, procState=6
2020-03-12 08:36:29.920 1028-27112/? I/CameraService: onUidStateChanged: uid=10216, procState=6
2020-03-12 08:36:29.920 1028-27112/? I/CameraService: notifyMonitoredUids
2020-03-12 08:36:29.920 1028-27112/? I/CameraService: onUidStateChanged: uid=10045, procState=6
2020-03-12 08:36:30.031 7899-7976/com.rncaissonsdk W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.lwansbrough.RCTCamera.RCTCameraViewManager
2020-03-12 08:36:30.032 7899-7976/com.rncaissonsdk W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class org.reactnative.camera.CameraViewManager
2020-03-12 08:36:30.312 1028-2099/? I/CameraService: onUidStateChanged: uid=10031, procState=16
2020-03-12 08:36:32.501 894-9976/? V/APM_AudioPolicyManager: computeVolume : camera shutter sound volume 1.000000
2020-03-12 08:36:33.997 894-9976/? V/APM_AudioPolicyManager: computeVolume : camera shutter sound volume 1.000000
2020-03-12 08:36:34.518 7899-7899/com.rncaissonsdk I/CameraManagerGlobal: Connecting to camera service
2020-03-12 08:36:34.522 1028-2099/? D/CameraService: addListenerHelper: Add listener 0xecfe9940
2020-03-12 08:36:34.522 1028-2099/? D/CameraService: CameraDeviceState for CameraManager
2020-03-12 08:36:34.522 7899-7899/com.rncaissonsdk I/CameraManagerGlobal: postSingleUpdate device: camera id 0 status STATUS_PRESENT
2020-03-12 08:36:34.523 7899-7899/com.rncaissonsdk I/CameraManagerGlobal: postSingleUpdate device: camera id 1 status STATUS_PRESENT
2020-03-12 08:36:34.523 7899-7899/com.rncaissonsdk I/CameraManagerGlobal: postSingleUpdate device: camera id 2 status STATUS_PRESENT
2020-03-12 08:36:34.523 7899-7899/com.rncaissonsdk I/CameraManagerGlobal: postSingleUpdate device: camera id 3 status STATUS_PRESENT
2020-03-12 08:36:34.523 7899-7899/com.rncaissonsdk E/CAMERA_2::: Adjusting exposure is not currently supported for Camera2
2020-03-12 08:36:34.523 7899-7929/com.rncaissonsdk I/CameraManagerGlobal: Camera 0 facing CAMERA_FACING_BACK state now CAMERA_STATE_CLOSED for client com.rncaissonsdk API Level 2
2020-03-12 08:36:34.524 7899-7929/com.rncaissonsdk I/CameraManagerGlobal: Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_CLOSED for client com.samsung.android.smartface API Level 2
2020-03-12 08:36:34.524 7899-7929/com.rncaissonsdk I/CameraManagerGlobal: Camera 2 facing CAMERA_FACING_BACK state now CAMERA_STATE_CLOSED for client com.sec.android.app.sbrowser API Level 2
2020-03-12 08:36:34.524 7899-7929/com.rncaissonsdk I/CameraManagerGlobal: Camera 20 facing CAMERA_FACING_BACK state now CAMERA_STATE_CLOSED for client com.sec.android.app.camera API Level 2
2020-03-12 08:36:34.524 7899-7929/com.rncaissonsdk I/CameraManagerGlobal: Camera 21 facing CAMERA_FACING_BACK state now CAMERA_STATE_CLOSED for client android.system API Level 2
2020-03-12 08:36:34.524 7899-7929/com.rncaissonsdk I/CameraManagerGlobal: Camera 23 facing CAMERA_FACING_BACK state now CAMERA_STATE_CLOSED for client android.system API Level 2
2020-03-12 08:36:34.524 7899-7929/com.rncaissonsdk I/CameraManagerGlobal: Camera 3 facing CAMERA_FACING_FRONT state now CAMERA_STATE_CLOSED for client android.system API Level 2
2020-03-12 08:36:34.524 7899-7929/com.rncaissonsdk I/CameraManagerGlobal: Camera 40 facing CAMERA_FACING_BACK state now CAMERA_STATE_CLOSED for client android.system API Level 2
2020-03-12 08:36:34.525 7899-7929/com.rncaissonsdk I/CameraManagerGlobal: Camera 41 facing CAMERA_FACING_FRONT state now CAMERA_STATE_CLOSED for client android.system API Level 2
2020-03-12 08:36:34.525 7899-7929/com.rncaissonsdk I/CameraManagerGlobal: Camera 50 facing CAMERA_FACING_BACK state now CAMERA_STATE_CLOSED for client android.system API Level 2
2020-03-12 08:36:34.525 7899-7929/com.rncaissonsdk I/CameraManagerGlobal: Camera 52 facing CAMERA_FACING_BACK state now CAMERA_STATE_CLOSED for client android.system API Level 2
2020-03-12 08:36:34.525 7899-7929/com.rncaissonsdk I/CameraManagerGlobal: Camera 91 facing CAMERA_FACING_FRONT state now CAMERA_STATE_CLOSED for client android.system API Level 2
2020-03-12 08:36:34.532 1028-2099/? I/CameraService: CameraService::connect call (PID -1 "com.rncaissonsdk", camera ID 0) for HAL version default and Camera API version 2
2020-03-12 08:36:34.532 1028-2099/? I/CameraService: UidPolicy: isUidActive, uid = 10344
2020-03-12 08:36:34.534 1295-3434/? I/EDMNativeHelperService: isCameraEnabled
2020-03-12 08:36:34.535 1295-3434/? D/RestrictionPolicy: isCameraEnabled ret(true) userId(0) cxtInfo.mCallerUid(10344) cxtInfo.mContainerId(0)
2020-03-12 08:36:34.535 1028-2099/? E/CameraService: checkTemperature (0)
2020-03-12 08:36:34.535 1028-2099/? I/CameraService: CameraService::validateClientPermissionsLocked is ok : calling pid 7899, calling uid 10344, client com.rncaissonsdk , cameraservice pid=1028, device user 0, currently allowed device users: 0
2020-03-12 08:36:34.535 1028-2099/? I/CameraService: CameraService::handleEvictionsLocked
2020-03-12 08:36:34.535 1028-2099/? I/CameraService: wouldEvictLocked:getCurrentCostLocked()=0, cost=100, totalCost=100, MaxCost=100
2020-03-12 08:36:34.535 1028-2099/? I/CameraService: wouldEvictLocked: owner=7899, priority-score=0, highestPriorityOwner=7899, highestPriority-score=0
2020-03-12 08:36:34.535 1028-2099/? I/CameraFlashlight: prepareDeviceOpen: prepare for device open(cameraId=0, needSkip = 0)
2020-03-12 08:36:34.535 1028-2099/? I/CameraService: onTorchStatusChangedLocked: Torch status changed for cameraId=0, newStatus=0
2020-03-12 08:36:34.535 1028-2099/? E/CameraService: setCompanionDisableSysFs : cc.disable property set to 0
2020-03-12 08:36:34.535 13634-13652/? I/CameraManagerGlobal: postSingleTorchUpdate device: camera id 0 status 0
2020-03-12 08:36:34.536 2181-2229/? I/CameraManagerGlobal: postSingleTorchUpdate device: camera id 0 status 0
2020-03-12 08:36:34.536 13634-13634/? I/CameraManagerGlobal: onTorchModeUnavailable
2020-03-12 08:36:34.536 2181-2804/? I/CameraManagerGlobal: onTorchModeUnavailable
2020-03-12 08:36:34.536 1028-2099/? I/Camera2ClientBase: Camera 0: Opened. Client: com.rncaissonsdk (PID 7899, UID 10344)
2020-03-12 08:36:34.536 1028-2099/? I/CameraDeviceClient: CameraDeviceClient 0: Opened
2020-03-12 08:36:34.536 1028-2099/? I/CameraService: startCameraOps: Start camera ops, package name = com.rncaissonsdk, client UID = 10344
2020-03-12 08:36:34.538 1028-2099/? I/CameraService: service.camera.running set to 1
2020-03-12 08:36:34.539 1028-2099/? D/Camera3-Device: initialize: mInterfaceLock.lock()
2020-03-12 08:36:34.539 835-24270/? I/SehCamDev@4.0-impl: [CAMKPI] camera3->open : E
2020-03-12 08:36:34.539 835-24270/? I/CamComm1.0-CamModule: [CAMKPI] camera_module->open : E
2020-03-12 08:36:34.539 1295-3434/? I/AudioManager: setParameters keyValuePairs = cameraFacing=back
2020-03-12 08:36:34.539 7899-8025/com.rncaissonsdk I/CameraManagerGlobal: postSingleUpdate device: camera id 0 status STATUS_NOT_AVAILABLE
2020-03-12 08:36:34.539 1028-2099/? I/CameraProviderManager: Camera device device@3.5/legacy/0 torch status is now NOT_AVAILABLE
2020-03-12 08:36:34.539 1028-2099/? I/CameraService: onTorchStatusChangedLocked: Torch status changed for cameraId=0, newStatus=0
2020-03-12 08:36:34.539 28447-31124/? I/CameraManagerGlobal: Camera 0 facing CAMERA_FACING_BACK state now CAMERA_STATE_OPEN for client com.rncaissonsdk API Level 2
2020-03-12 08:36:34.539 7899-7927/com.rncaissonsdk I/CameraManagerGlobal: Camera 0 facing CAMERA_FACING_BACK state now CAMERA_STATE_OPEN for client com.rncaissonsdk API Level 2
2020-03-12 08:36:34.540 805-1613/? D/audio_hw_primary: adev_set_parameters: enter: cameraFacing=back
2020-03-12 08:36:34.540 805-1613/? V/voice: voice_set_parameters: enter: cameraFacing=back
2020-03-12 08:36:34.540 805-1613/? V/msm8974_platform: platform_set_parameters: enter: cameraFacing=back
2020-03-12 08:36:34.540 805-1613/? V/audio_hw_sec: factory_set_parameters: enter: cameraFacing=back
2020-03-12 08:36:34.540 4169-4384/? I/CameraManagerGlobal: postSingleUpdate device: camera id 0 status STATUS_NOT_AVAILABLE
2020-03-12 08:36:34.540 13634-15687/? I/CameraManagerGlobal: Camera 0 facing CAMERA_FACING_BACK state now CAMERA_STATE_OPEN for client com.rncaissonsdk API Level 2
2020-03-12 08:36:34.540 4169-4608/? I/CameraManagerGlobal: Camera 0 facing CAMERA_FACING_BACK state now CAMERA_STATE_OPEN for client com.rncaissonsdk API Level 2
2020-03-12 08:36:34.540 2181-2229/? I/CameraManagerGlobal: Camera 0 facing CAMERA_FACING_BACK state now CAMERA_STATE_OPEN for client com.rncaissonsdk API Level 2
2020-03-12 08:36:34.541 835-24270/? I/CamComm1.0-CamModule: [CAMKPI] camera_module->open : X
2020-03-12 08:36:34.541 835-24270/? I/SehCamDev@4.0-impl: [CAMKPI] camera3->open : X
2020-03-12 08:36:34.542 8726-9012/? I/CameraManagerGlobal: postSingleUpdate device: camera id 0 status STATUS_NOT_AVAILABLE
2020-03-12 08:36:34.542 8726-9012/? I/CameraManagerGlobal: postSingleUpdate device: camera id 0 status STATUS_NOT_AVAILABLE
2020-03-12 08:36:34.543 1028-2099/? I/Camera3-Status: addComponent: Adding new component 0 - InFlightStatus
2020-03-12 08:36:34.543 1028-2099/? I/Camera3-Status: addComponent: Adding new component 1 - RequestThread
2020-03-12 08:36:34.543 8726-9012/? I/CameraManagerGlobal: Camera 0 facing CAMERA_FACING_BACK state now CAMERA_STATE_OPEN for client com.rncaissonsdk API Level 2
2020-03-12 08:36:34.543 1028-2099/? E/Camera2-FrameProcessorBase: FrameProcessorBase: created
2020-03-12 08:36:34.543 1028-2099/? E/Camera2-FrameProcessorBase: registerListener: Registering listener for frame id range 0 - 2147483647
2020-03-12 08:36:34.543 1028-2099/? I/CameraService: CameraService::finishConnectLocked E
2020-03-12 08:36:34.543 1028-2099/? I/CameraService: wouldEvictLocked:getCurrentCostLocked()=0, cost=100, totalCost=100, MaxCost=100
2020-03-12 08:36:34.543 1028-2099/? I/CameraService: wouldEvictLocked: owner=7899, priority-score=0, highestPriorityOwner=7899, highestPriority-score=0
2020-03-12 08:36:34.543 24605-21632/? I/CameraManagerGlobal: Camera 0 facing CAMERA_FACING_BACK state now CAMERA_STATE_OPEN for client com.rncaissonsdk API Level 2
2020-03-12 08:36:34.545 1028-2099/? I/CameraService: addAndEvict: push the client(owner 7899, priorityScore 0, state 2) to mClients
2020-03-12 08:36:34.545 1028-2099/? I/CameraService: CameraService::finishConnectLocked X
2020-03-12 08:36:34.547 1028-2099/? I/CameraService: onUidStateChanged: uid=10031, procState=9
2020-03-12 08:36:34.556 7899-7899/com.rncaissonsdk E/CAMERA_2::: Adjusting exposure is not currently supported for Camera2
2020-03-12 08:36:34.568 1028-5843/? D/Camera3-Device: waitUntilDrained: mInterfaceLock.unlock()
2020-03-12 08:36:34.568 1028-5843/? D/CameraDeviceClient: createStream E
2020-03-12 08:36:34.568 1028-5843/? D/CameraDeviceClient: createSurfaceFromGbp E: isStreamInfoValid=0, option=0
2020-03-12 08:36:34.568 1028-5843/? W/CameraDeviceClient: createSurfaceFromGbp: Camera 0 with consumer usage flag: 256: Forcing asynchronous mode for stream
2020-03-12 08:36:34.568 1028-5843/? D/CameraDeviceClient: createSurfaceFromGbp: consumer usage flag: 256, useAsync: 1
2020-03-12 08:36:34.570 1028-5843/? D/CameraDeviceClient: createSurfaceFromGbp: width=1440, height=1080, format=1, dataSpace=0
2020-03-12 08:36:34.570 1028-5843/? W/CameraDeviceClient: createSurfaceFromGbp: Camera 0: Overriding format 0x1 to IMPLEMENTATION_DEFINED
2020-03-12 08:36:34.570 1028-5843/? D/CameraDeviceClient: roundBufferDimensionNearest  inWidth=1440 inHeight=1080, outWidth=1440 outHeight=1080 X
2020-03-12 08:36:34.570 1028-5843/? D/CameraDeviceClient: createSurfaceFromGbp X
2020-03-12 08:36:34.570 1028-5843/? D/Camera3-Device: createStream: mInterfaceLock.lock()
2020-03-12 08:36:34.570 1028-5843/? D/Camera3-Device: Camera 0: Creating new stream 0: 1440 x 1080, format 34, dataspace 0 rotation 0 consumer usage 0, isShared 0, physicalCameraId 
2020-03-12 08:36:34.570 1028-5843/? D/Camera3-Device: createStream: mInterfaceLock.unlock()
2020-03-12 08:36:34.570 1028-5843/? D/CameraDeviceClient: createStream: Camera 0: Successfully created a new stream ID 0 for output surface (1440 x 1080) with format 0x22.
2020-03-12 08:36:34.570 1028-5843/? D/Camera3-Device: setStreamTransform: mInterfaceLock.lock()
2020-03-12 08:36:34.570 1028-5843/? D/Camera3-OutputStream: setTransformLocked: option(0) ,transform(12)
2020-03-12 08:36:34.570 1028-5843/? D/CameraDeviceClient: createStream X
2020-03-12 08:36:34.571 1028-5843/? D/CameraDeviceClient: createStream E
2020-03-12 08:36:34.571 1028-5843/? D/CameraDeviceClient: createSurfaceFromGbp E: isStreamInfoValid=0, option=0
2020-03-12 08:36:34.571 1028-5843/? D/CameraDeviceClient: createSurfaceFromGbp: consumer usage flag: 3, useAsync: 0
2020-03-12 08:36:34.571 1028-5843/? D/CameraDeviceClient: createSurfaceFromGbp: width=4032, height=3024, format=33, dataSpace=146931712
2020-03-12 08:36:34.571 1028-5843/? D/CameraDeviceClient: roundBufferDimensionNearest  inWidth=4032 inHeight=3024, outWidth=4032 outHeight=3024 X
2020-03-12 08:36:34.571 1028-5843/? D/CameraDeviceClient: createSurfaceFromGbp X
2020-03-12 08:36:34.572 1028-5843/? D/Camera3-Device: createStream: mInterfaceLock.lock()
2020-03-12 08:36:34.572 1028-5843/? D/Camera3-Device: Camera 0: Creating new stream 1: 4032 x 3024, format 33, dataspace 146931712 rotation 0 consumer usage 0, isShared 0, physicalCameraId 
2020-03-12 08:36:34.572 1028-5843/? D/Camera3-Device: createStream: mInterfaceLock.unlock()
2020-03-12 08:36:34.572 1028-5843/? D/CameraDeviceClient: createStream: Camera 0: Successfully created a new stream ID 1 for output surface (4032 x 3024) with format 0x21.
2020-03-12 08:36:34.572 1028-5843/? D/Camera3-Device: setStreamTransform: mInterfaceLock.lock()
2020-03-12 08:36:34.572 1028-5843/? D/Camera3-OutputStream: setTransformLocked: option(0) ,transform(12)
2020-03-12 08:36:34.572 1028-5843/? D/CameraDeviceClient: createStream X
2020-03-12 08:36:34.572 1028-5843/? D/CameraDeviceClient: createStream E
2020-03-12 08:36:34.572 1028-5843/? D/CameraDeviceClient: createSurfaceFromGbp E: isStreamInfoValid=0, option=0
2020-03-12 08:36:34.572 1028-5843/? D/CameraDeviceClient: createSurfaceFromGbp: consumer usage flag: 3, useAsync: 0
2020-03-12 08:36:34.573 1028-5843/? E/CameraDeviceClient: createSurfaceFromGbp: Camera 0: Failed to query Surface format: No such device (-19)
2020-03-12 08:36:34.573 7899-7899/com.rncaissonsdk E/CameraCaptureSession: Session 0: Failed to create capture session; configuration failed
2020-03-12 08:36:34.575 1028-5843/? I/CameraService: CameraService::connect call (PID -1 "com.rncaissonsdk", camera ID 1) for HAL version default and Camera API version 2
2020-03-12 08:36:34.575 1028-5843/? I/CameraService: UidPolicy: isUidActive, uid = 10344
2020-03-12 08:36:34.575 7899-7899/com.rncaissonsdk E/Camera2: Failed to configure capture session.
2020-03-12 08:36:34.576 1295-2716/? I/EDMNativeHelperService: isCameraEnabled
2020-03-12 08:36:34.576 1295-2716/? D/RestrictionPolicy: isCameraEnabled ret(true) userId(0) cxtInfo.mCallerUid(10344) cxtInfo.mContainerId(0)
2020-03-12 08:36:34.576 1028-5843/? E/CameraService: checkTemperature (0)
2020-03-12 08:36:34.576 1028-5843/? I/CameraService: CameraService::validateClientPermissionsLocked is ok : calling pid 7899, calling uid 10344, client com.rncaissonsdk , cameraservice pid=1028, device user 0, currently allowed device users: 0
2020-03-12 08:36:34.576 1028-5843/? I/CameraService: CameraService::handleEvictionsLocked
2020-03-12 08:36:34.576 1028-5843/? I/CameraService: handleEvictionsLocked: priorityMap[0] : pid=7899, priorityScore=0, state=2
2020-03-12 08:36:34.576 1028-5843/? I/CameraService: wouldEvictLocked:getCurrentCostLocked()=100, cost=100, totalCost=200, MaxCost=100
2020-03-12 08:36:34.576 1028-5843/? I/CameraService: wouldEvictLocked: owner=7899, priority-score=0, highestPriorityOwner=7899, highestPriority-score=0
2020-03-12 08:36:34.576 1028-5843/? E/CameraService: CameraService::connect X (PID 7899) rejected (existing client(s) with higher priority).
2020-03-12 08:36:34.576 1028-5843/? I/CameraService: wouldEvictLocked:getCurrentCostLocked()=100, cost=100, totalCost=200, MaxCost=100
2020-03-12 08:36:34.576 1028-5843/? I/CameraService: wouldEvictLocked: owner=7899, priority-score=0, highestPriorityOwner=7899, highestPriority-score=0
2020-03-12 08:36:34.576 1028-5843/? E/CameraService:    Conflicts with: Device 0, client package com.rncaissonsdk (PID 7899, score 0, state 2)
2020-03-12 08:36:34.577 7899-8024/com.rncaissonsdk E/Camera2: onError: 1 (2)
2020-03-12 08:36:35.057 1028-5843/? I/CameraService: onUidStateChanged: uid=10031, procState=16

@noambonnie
Copy link

FWIW, it does work on the Pixel 3a, which only has a single rear camera.

@cristianoccazinsp
Copy link
Contributor

So this is only an issue of the Pixel 3? Just to confirm, the same issue happens regardless of using the cameraId prop or just setting the facing prop right? If that's the case, then you are most likely right, the issue is related by the camera switching process. I have tested on a Pixel 2 and I definitely don't see the issue so I can't really test it.

Would it be possible for you to test adding some delay to the camera switch step (in Java) to confirm that's the issue? Perhaps test some synchronized calls? I'm sorry I can't be of much help!

Lastly, this is NOT an issue with Camera1? Both implementations are very similar... so that's odd.

@noambonnie
Copy link

noambonnie commented Mar 12, 2020

No, Pixel 3a is fine. Only an issue with Samsung Galaxy S10 which has an array of 3 rear cameras.

I'm unsure what 'facing' prop is. I'm using type={RNCamera.Constants.Type.front}

It is not an issue with camera1 indeed.

Any way you can guide me as to where to set the delay?

@cristianoccazinsp
Copy link
Contributor

Sorry, by facing I meant the type prop.

You could try delaying the start/stop calls to see if that's the problem. For example:

https://github.com/react-native-community/react-native-camera/blob/master/android/src/main/java/com/google/android/cameraview/Camera2.java#L383

and https://github.com/react-native-community/react-native-camera/blob/master/android/src/main/java/com/google/android/cameraview/Camera2.java#L362

Those two places stop and start the camera when either the ID or Type is changed.

To add a delay, you may try delaying the start call with something like what Camera1 does: https://github.com/react-native-community/react-native-camera/blob/master/android/src/main/java/com/google/android/cameraview/Camera1.java#L1208

Note that the above is just to confirm the issue, adding such delay on the stop/start step would actually be quite bad!

@noambonnie
Copy link

For all I could tell that code is not being called. I will try to dig deeper into that tomorrow. I'm pretty sure it has to do with the destruction/construction order. Maybe something about this phone's camera array is different.

@noambonnie
Copy link

I was able to track down the problem, not yet the solution (and any guidance/help would be welcomed!)

The flow as it happens is:

  • setUsingCamera2Api is being called and in turn calling onRestoreInstanceState() which then calls setFacing() with the default (0 / Rear camera)
  • start() is called.
  • setFacing is called to set the camera to front / 1. But, onOpened() has not yet been called as a result of the previous step. setFacing() checks isCameraOpened() in order to switch camera, but since the camera has not yet been opened it does nothing except setting mFacing to 1.

Below are some logs with prints I sprinkled around the code. In onOpened I added the following code to print the what the actual camera that was opened is using - front or back:

try {
    CameraCharacteristics characteristics = mCameraManager.getCameraCharacteristics(mCamera.getId());
    Integer internal = characteristics.get(CameraCharacteristics.LENS_FACING);
    Log.d(TAG, "onOpened: current camera facing: " + (internal == CameraCharacteristics.LENS_FACING_FRONT ? Constants.FACING_FRONT : Constants.FACING_BACK));
} catch(CameraAccessException e) {
    Log.d(TAG, "onOpened: CameraAccessException");
}
CameraView: setUsingCamera2Api calling onRestoreInstanceState():
CameraView: onHostResume calling start():
Camera2: start: Camera opening. mFacing = 0
Camera2: startOpeningCamera: mFacing = 0
Camera2: setFacing: setting mFacing from 0 to 1
Camera2: setFacing: Camera not yet opened, setFacing Nan.
RNCameraView: onHostResume calling start():
Camera2: start: Camera opening. mFacing = 1
Camera2: onOpened: camera opened. mFacing = 1
Camera2: onOpened: current camera facing: 0 <<< this is the actual facing of mCamera, even though mFacing is 1. See note above
Camera2: startOpeningCamera: mFacing 1

Possible solutions as I see them

  1. Force setFacing() to be called after camera was opened.
  2. Somehow make onRestoreInstanceState() default to the camera that was set in the props.
  3. in onOpened(), set the actual facing value to mFacing

I've never developed a native RN component and am very rusty on Java. I'd be happy to hear thoughts/guidance.

@cristianoccazinsp
Copy link
Contributor

That looks like a bug, onRestoreInstanceState should set everything exactly as it was originally given.

@noambonnie
Copy link

noambonnie commented Mar 13, 2020

I may have a wrong phrasing but the facts are correct: onRestoreInstanceState has 0 (back camera) when launching the app. Not sure what state is being restored here as I'm testing this on a fresh launch of the app.

So even though in React Native the camera is set to 1/front, when it first initializes it starts with 0, then calls setFacing with 1.

@cristianoccazinsp
Copy link
Contributor

I believe you are correct. Although the state is properly saved, it is saving react's default values (0). This is how react works, your component is initialized with default values and then the setters are called. This would probably discard your option number 2.

@noambonnie
Copy link

noambonnie commented Mar 13, 2020 via email

@noambonnie
Copy link

noambonnie commented Mar 13, 2020 via email

@cristianoccazinsp
Copy link
Contributor

Not that I'm aware of. Is it possible to look at Camera1's implementation to see what's different? I would bet there's a lock/synchronized block missing there. Camera2 is still quite bad and I wouldn't be surprised. Most of the improvements I did myself were all Camera1 (faster loading and capturing, not blocking the UI, race conditions, crashes, etc.) so Camera2 is still quite broken.

@noambonnie
Copy link

Yes, there's a lot of synchronized(this) in Camera1... I don't know that I have the ability to understand which points in Camera2 need to be sync'ed. I might take a stab at this.

While we're here though, maybe you would know a solution to the problem that got me into this in the first place... Is there a way to mute the shutter sound using Camera1?

@cristianoccazinsp
Copy link
Contributor

Not that I'm aware of. Since iOS forces you to have a shutter sound I just left it as a default behaviour.

What prop are you using exactly to mute the shutter sound? I can't even see that feature in the JS side.

However, looks like Camera1 might be able to mute the shutter sound as well, but it is not implemented: https://developer.android.com/reference/android/hardware/Camera#enableShutterSound(boolean)

@noambonnie
Copy link

There's an undocumented prop: https://github.com/react-native-community/react-native-camera/pull/1441/files

In any event, I think I found a solution and I don't think there's a problem with it. I simply removed the call to start() from setUsingCamera2Api(). So remove this line and everything works: https://github.com/react-native-community/react-native-camera/blob/fb2105c7ccb456e721058bf09f0347eeb492e98c/android/src/main/java/com/google/android/cameraview/CameraView.java#L314

Now start() is being called from onHostResume() after all props have been set, including setFacing.

I think this is fine and is actually the right thing to do. I don't think that setting this prop should directly start the camera. And this prop in particular is not something that I think should be modified after initial creation of RNCamera.

Are you part of the project? Do you think this fix would be accepted if I create a pull request?

@cristianoccazinsp
Copy link
Contributor

Interesting, I don't see how playSoundOnCapture works only in Camera2 and not in Camera1, neither implementations have specific code for that prop. Are you 100% sure that prop is actually doing anything? I think what you're seeing is the default behaviour of Android 10 to always have a shutter sound by default (which for some reason is different with Camera2)

Also, the change you propose seems reasonable. However, I would make sure to test it thoroughly first since it could break Camera2 implementation for some devices that do not support it and then fallback to Camera1 again ( I believe that's the reason for the start call there).

Lastly, while you are at it, it could be good to include a fix to the Camera1 implementation so shutter sound is honored in Android 10 :)

@noambonnie
Copy link

I see your point that the prop should work in either camera. I'm pretty sure I read it somewhere but I can't track it down right now. I tested and it doesn't work with Camera1 - maybe Camera1 always plays a sound. I'm trying to mute it and the prop won't do with Camera1. I tested it on Camera2 and it works.

I would see about testing on older API levels for fallback. Best I can do probably is emulator. Looking at the code though I don't think there will be impacted because the top of the function tests for API level and returns if Camera2 is not supported.

I may or may not get to the Camera1 sound, and if I do it would be a separate PR.

Thanks for your help. If you have any further thoughts/ideas I'd be happy to hear.

@cristianoccazinsp
Copy link
Contributor

cristianoccazinsp commented Mar 13, 2020

maybe Camera1 always plays a sound. This is exactly my point, I think this is true for Android 10. If you test Camera1 on multiple devices, you will see some Android phones will play a sound, and some won't, regardless of the prop value.

I think the best "fix" would be to move the prop down the Camera1/2 implementation and have each class play (or mute) the sound. Like I said above, for Camera1 the change should be rather easy https://developer.android.com/reference/android/hardware/Camera#enableShutterSound(boolean) and for Camera2 I guess you are forced to play the sound by yourself like it currently happens. However, you are right about this change probably belonging to another separate PR.

If I have some free time during the weekend, I can take a look at the shutter sound issue and perhaps provide a PR so it is consistent across Camera1 and 2.

cristianoccazinsp pushed a commit to cristianoccazinsp/react-native-camera that referenced this issue Mar 14, 2020
susanapons89 added a commit to creativehothouse/react-native-camera that referenced this issue Apr 8, 2020
commit bfe04aa
Author: semantic-release-bot <semantic-release-bot@martynus.net>
Date:   Sun Apr 5 14:57:56 2020 +0000

    chore(release): 3.22.0 [skip ci]

    # [3.22.0](react-native-camera/react-native-camera@v3.21.0...v3.22.0) (2020-04-05)

    ### Features

    * **android:** Accept path while taking picture in android ([react-native-camera#2769](react-native-camera#2769)) ([3ee43d4](react-native-camera@3ee43d4))
    * **example:** Fix basic example bugs ([react-native-camera#2751](react-native-camera#2751)) ([9c18c25](react-native-camera@9c18c25))

commit 9c18c25
Author: fabriziobertoglio1987 <fabrizio.bertoglio@gmail.com>
Date:   Sun Apr 5 16:53:51 2020 +0200

    feat(example): Fix basic example bugs (react-native-camera#2751)

    * feat(example): adding sound permissions to android example

    * feat(example): fix basic example runtime error

commit 3ee43d4
Author: AsminBudha <sminmgr@gmail.com>
Date:   Sun Apr 5 20:38:03 2020 +0545

    feat(android): Accept path while taking picture in android (react-native-camera#2769)

    * Accept path while taking picture in android

    * docs(context): change readme to add path option while taking picture

commit e7ed948
Merge: d1e3d66 0111237
Author: Mateus Andrade <mateus.andrade47@outlook.com>
Date:   Thu Mar 26 15:14:27 2020 -0300

    Merge pull request react-native-camera#2768 from cristianoccazinsp/android-crash-camerainfo

    Crash fix when getCameraInfo fails

commit 0111237
Author: Cristiano Coelho <cristianocca@hotmail.com>
Date:   Thu Mar 26 14:43:14 2020 -0300

    Crash fix when getCameraInfo fails

commit d1e3d66
Merge: e9af04a 86e8053
Author: Mateus Andrade <mateus.andrade47@outlook.com>
Date:   Thu Mar 26 08:52:43 2020 -0300

    Merge pull request react-native-camera#2765 from tribou/tracked-text-feature-type

    Fix TrackedTextFeature TS type

commit 86e8053
Author: Aaron Tribou <tribou@users.noreply.github.com>
Date:   Tue Mar 24 21:13:23 2020 -0500

    Fix TrackedTextFeature TS type

commit e9af04a
Author: semantic-release-bot <semantic-release-bot@martynus.net>
Date:   Fri Mar 20 19:58:22 2020 +0000

    chore(release): 3.21.0 [skip ci]

    # [3.21.0](react-native-camera/react-native-camera@v3.20.0...v3.21.0) (2020-03-20)

    ### Features

    * **example:** fix circleci error ([1f29ffb](react-native-camera@1f29ffb))

commit 353eece
Merge: 4c54bd5 1f29ffb
Author: Mateus Andrade <mateus.andrade47@outlook.com>
Date:   Fri Mar 20 16:52:53 2020 -0300

    Merge pull request react-native-camera#2757 from fabriziobertoglio1987/fix/circle-ci-node-crash

    node process crushing circleci

commit 1f29ffb
Author: fabriziobertoglio1987 <fabrizio.bertoglio@gmail.com>
Date:   Fri Mar 20 19:29:52 2020 +0100

    feat(example): fix circleci error

commit 4c54bd5
Author: semantic-release-bot <semantic-release-bot@martynus.net>
Date:   Thu Mar 19 18:49:01 2020 +0000

    chore(release): 3.20.0 [skip ci]

    # [3.20.0](react-native-camera/react-native-camera@v3.19.2...v3.20.0) (2020-03-19)

    ### Features

    * **example:** remove rectOfInterest example ([8e4d36a](react-native-camera@8e4d36a))

commit f11136a
Merge: d477f4c 8e4d36a
Author: Mateus Andrade <mateus.andrade47@outlook.com>
Date:   Thu Mar 19 15:44:08 2020 -0300

    Merge pull request react-native-camera#2755 from fabriziobertoglio1987/fix/delete-additional-examples

    remove rectOfInterest example

commit 8e4d36a
Author: fabriziobertoglio1987 <fabrizio.bertoglio@gmail.com>
Date:   Thu Mar 19 19:05:58 2020 +0100

    feat(example): remove rectOfInterest example

commit d477f4c
Author: semantic-release-bot <semantic-release-bot@martynus.net>
Date:   Mon Mar 16 16:43:54 2020 +0000

    chore(release): 3.19.2 [skip ci]

    ## [3.19.2](react-native-camera/react-native-camera@v3.19.1...v3.19.2) (2020-03-16)

    ### Bug Fixes

    * **android:** fix empty popup ([407295b](react-native-camera@407295b))

commit 0afc608
Merge: fb2105c 18d9347
Author: Mateus Andrade <mateus.andrade47@outlook.com>
Date:   Mon Mar 16 13:39:11 2020 -0300

    Merge pull request react-native-camera#2748 from cristianoccazinsp/fix-android-shutter-sound

    Fix android shutter sound

commit 18d9347
Author: Cristiano Coelho <cristianocca@hotmail.com>
Date:   Sat Mar 14 15:46:58 2020 -0300

    improve camera2 to camera1 fallback on legacy devices.

commit 0911852
Author: Cristiano Coelho <cristianocca@hotmail.com>
Date:   Sat Mar 14 13:43:11 2020 -0300

    Use same method to play sounds for consistency and so it works across multiple devices.

commit 1f89548
Author: Cristiano Coelho <cristianocca@hotmail.com>
Date:   Sat Mar 14 12:46:24 2020 -0300

    move shutter sound to right location

commit 4c75744
Author: Cristiano Coelho <cristianocca@hotmail.com>
Date:   Sat Mar 14 12:35:38 2020 -0300

    prevent duplicated start calls (react-native-camera#2521)

commit 886a3bb
Author: Cristiano Coelho <cristianocca@hotmail.com>
Date:   Sat Mar 14 12:16:22 2020 -0300

    Fixes for Camera1 and Camera2 shutter sound.

    Shutter sound should now be consistent with the `playSoundOnCapture` prop. Additionally, it should happen on successful capture as opposed to camera capture start (consistent with iOS and any camera app)

    Lastly, added missing props to the docs.

commit fb2105c
Merge: 43a7323 407295b
Author: Mateus Andrade <mateus.andrade47@outlook.com>
Date:   Fri Mar 13 10:07:10 2020 -0300

    Merge pull request react-native-camera#2740 from lihroff/master

    fix(android): fix empty popup

commit 43a7323
Merge: 944c304 583507f
Author: Mateus Andrade <mateus.andrade47@outlook.com>
Date:   Fri Mar 13 09:39:55 2020 -0300

    Merge pull request react-native-camera#2719 from bqwang91/master

    Android - Limiting Scanning Area using rectOfInterest

commit 407295b
Author: TommY Lee <lihroff@icloud.com>
Date:   Fri Mar 13 18:21:56 2020 +0800

    fix(android): fix empty popup

    fix empty popup when not set android*PermissionOptions props.

commit 944c304
Merge: 38c5197 745e8de
Author: Mateus Andrade <mateus.andrade47@outlook.com>
Date:   Thu Mar 12 12:40:28 2020 -0300

    Merge pull request react-native-camera#2737 from stvdrsch/master

    Typo

commit 745e8de
Author: Steven Vanderschaeve <steven@ontoforce.com>
Date:   Thu Mar 12 14:44:27 2020 +0100

    Typo

    coordiate instead of coordinate

commit 38c5197
Author: semantic-release-bot <semantic-release-bot@martynus.net>
Date:   Wed Mar 11 16:40:29 2020 +0000

    chore(release): 3.19.1 [skip ci]

    ## [3.19.1](react-native-camera/react-native-camera@v3.19.0...v3.19.1) (2020-03-11)

    ### Bug Fixes

    * **android:** fix bug Duplicate module rn ([4522841](react-native-camera@4522841))

commit 4a1cfa5
Merge: e76faae 7c7124d
Author: Di Da <dida@microsoft.com>
Date:   Wed Mar 11 09:36:26 2020 -0700

    Merge pull request react-native-camera#2723 from ddalp/master

    Add Cpp/WinRT camera module support for React Native Windows

commit e76faae
Merge: ea0e9e6 4522841
Author: Mateus Andrade <mateus.andrade47@outlook.com>
Date:   Tue Mar 10 19:38:17 2020 -0300

    Merge pull request react-native-camera#2735 from fabriziobertoglio1987/fix/basic-example-rn-cli-config

    Fix Duplicate module rn

commit 7c7124d
Author: Di Da <dida@ntdev.microsoft.com>
Date:   Tue Mar 10 09:44:42 2020 -0700

    Move ReactCameraConstants under a class and fix typo

commit 4522841
Author: fabriziobertoglio1987 <fabrizio.bertoglio@gmail.com>
Date:   Tue Mar 10 10:12:11 2020 +0100

    fix(android): fix bug Duplicate module rn

    fixing bug Duplicate module react-native
    when running the mlkit and basic examples

    1) adding metro.config.js to examples/basic and
    examples/mlkit

    2) adding new RegExp in blacklist to ignore the
    advanced/node_modules/react-native/.* files

commit 51a4927
Author: Di Da <dida@ntdev.microsoft.com>
Date:   Mon Mar 9 10:53:26 2020 -0700

    Address PR comments

commit 72f2dc9
Author: Di Da <dida@ntdev.microsoft.com>
Date:   Tue Mar 3 10:41:00 2020 -0800

    Add Cpp/WinRT camera module support for React Native Windows

commit 583507f
Author: James Wang <james.wang.3@team.telstra.com>
Date:   Sat Feb 29 20:33:17 2020 +1100

    update cam view height

commit 3f801ee
Author: James Wang <james.wang.3@team.telstra.com>
Date:   Sat Feb 29 17:42:35 2020 +1100

    add example

commit ea0e9e6
Author: semantic-release-bot <semantic-release-bot@martynus.net>
Date:   Thu Feb 27 17:52:07 2020 +0000

    chore(release): 3.19.0 [skip ci]

    # [3.19.0](react-native-camera/react-native-camera@v3.18.0...v3.19.0) (2020-02-27)

    ### Features

    * **ios:** Expose an ability to change the frames per second via an fps option in record. ([react-native-camera#2711](react-native-camera#2711)) ([d60d201](react-native-camera@d60d201))

commit d60d201
Author: cinjon <cinjon.resnick@gmail.com>
Date:   Thu Feb 27 12:47:45 2020 -0500

    feat(ios): Expose an ability to change the frames per second via an fps option in record. (react-native-camera#2711)

commit 398ac12
Author: James Wang <james.wang.3@team.telstra.com>
Date:   Thu Feb 27 14:01:53 2020 +1100

    fix typo

commit 3f66aa5
Author: James Wang <james.wang.3@team.telstra.com>
Date:   Thu Feb 27 13:59:19 2020 +1100

    update RNcamera readme

commit 802ce47
Author: James Wang <james.wang.3@team.telstra.com>
Date:   Thu Feb 27 13:52:57 2020 +1100

    add types

commit 6cc8fef
Author: James Wang <james.wang.3@team.telstra.com>
Date:   Thu Feb 27 13:50:32 2020 +1100

    add aupport for limiting scan area for Android

commit adae4a2
Author: semantic-release-bot <semantic-release-bot@martynus.net>
Date:   Fri Feb 14 02:26:08 2020 +0000

    chore(release): 3.18.0 [skip ci]

    # [3.18.0](react-native-camera/react-native-camera@v3.17.0...v3.18.0) (2020-02-14)

    ### Features

    * **android:** stop/release camera in non-UI thread ([react-native-camera#2685](react-native-camera#2685)) ([ba0e427](react-native-camera@ba0e427))

commit c7e92b2
Author: cristianoccazinsp <48869228+cristianoccazinsp@users.noreply.github.com>
Date:   Thu Feb 13 23:21:59 2020 -0300

    feature(record): On recording start and end events (react-native-camera#2702)

    * This update tries to improve audio recording interruptions on iOS due to phone calls or background music.

    - Use a more generic event to handle session interruptions. This removes the need to listen to foreground/background events, and stopping the session this way was actually redundant/wrong (see https://forums.developer.apple.com/thread/61406). This also makes session stopping detection more reliable (calls, suspension due to a call or notification, etc., which would previously not set the recording interrupted flag on every case)

    From the above docs: "No, incorrect. You _never_ need to stop your capture session. The capture session automatically stops itself when your app goes to the background and resumes itself when you come back to the foreground."

    - Allow for `captureAudio` updates to also update the audio connections internally so the prop can be correctly updated on the fly without remounting.

    - add onAudioInterrupted and onAudioConnected events so the UI can handle scenarios where audio is wanted but not available. This should also help in keeping the preview active even if audio is interrupted and we have captureAudio={true}. Lastly, it can be used to detect if we can record audio or not due to the dummy implementation of the audio permission on iOS always returning true.

    - check, activate, and release audio sessions (if captureAudio) so we can detect early if audio is available before attempting to connect the input. This will also allow us to detect if we can record even if there was already a call before opening the camera.

    - use proper observer for session error instead of of the strong self block. No benefit, but makes code more readable and allows access to instance variables

    - getDeviceOrientationWithBlock might fire more than once under some circumstances, ending up taking a picture or video twice. Add a lock and additional check to prevent this.

    * no need for change check,

    * do not resume audio if we were hinted not to (e.g., music playback happening)

    * Move heavy work to a dedicated background thread. Improves camera initial loading and resumes from background.

    Details:

    - Use a HandlerThread to delegate heavy tasks to background. The thread is managed by the view, and passed down to the implementation in case it also needs to use it. The view will fire start calls and other possibly heavy operations in this thread to avoid ANRs. Some code sent to this thread:
        - start calls: start is extremely heavy and will cause ANRs on some devices, especially when coming back from background
        - Camera1: some preset changes fire a stop/start sequence. These will now happen in the background thread
        - take picture and start recording (from view class) will also start in this thread

    - Add some extra null checks

    - View was not properly cleaning up itself on destroy (host destroy event was never fired)

    * Fix for a possible crash when changing devices and changing focus. If the new device resets the focus, "defocusing" might not be possible if the new device does not support auto focus. For this reason, we need to do a different cleanup on the focus and exposed flags and events.

    * start session here also on session queue.

    * check for session running before trying to record or capture.
    This should fix a possible race condition where both the session start call happens at the same time as the record call

    * set preview orientation also in session queue

    * no need to set orientation on constructor, and set it on session queue to prevent race conditions

    * move device init and checks also to session queue. This prevents possible double initializations.

    * catch possible errors when starting camera preview. This might still randomly fail on some devices for some reason.

    * delay capture in progress until we have resumed/paused preview.

    * do not crash the app if set texture setup failed

    * more synchronized checks to prevent crashes due to concurrent camera updates

    * remove unused imports

    * Handle audio interruption in session queue. This prevents the session isRunning flag from getting corrupted due to concurrent updates to the session.

    * Fix possible crash when attempting to retrieve camera parameters.

    * Preserve exif/metadata on photo capture. Add a few comments to each step of the capture process

    * orientation must be fixed before mirroring

    * x/y dimensions are redundantly updated (storing the image sets them automatically). However, orientation must be reset on any image change since the final stored image is automatically rotated when it is modified in place.

    * revert mirrorImage order, has to be first since forceUpOrientation adjusts the image afterwards.

    * Minor change: also implement `onPictureTaken` for iOS in case anyone needs the early event.

    * - Improve Android code so skipProcessing is not needed, the code is more in line with iOS, and is "fast" by default. This means that skipProcessing is no longer needed (nor used), and adding additional options will "slow down" the capture as expected, rather than having always a lot of processing. This shouldn't be a breaking change.

    - document the writeExif option, and implement it for iOS as well.

    * This is a fix for events possibly being fired not on the main thread, which could cause the whole app to freeze.

    * Fire events on the right thread. No need to use UI thread, and fix the still works

    * Release CF object which could cause a memleak

    * Fix Objects.equals that is only available after API 19

    * allow for audio session to be kept even after unmounts

    * readme typo

    * readme typo

    * Make camera ready events to fire also on camera/device change to be consistent with Android. Fire unmount error when session or device fails to start.

    * update example app to properly use camera ready event

    * Make camera ready events to fire also on camera/device change to be consistent with Android. Fire unmount error when session or device fails to start. Update advanced example app to use camera ready event instead.

    * Android crash fixes. Make sure no unsupported aspect ratio is used, and do not crash when there are no cameras available.

    * stop/release camera in non-UI thread so we prevent ANRs and UI freezing.

    Some phones may take up to a second to release the camera and preview.

    * move codec, max duration, and max file size settings to the session queue.

    This might prevent a race condition when changing presets/quality.

    * android crash fix

    * Add onRecordingStart and onRecordingEnd events

    * fix for surface destroy and resume events.

    * add missing types

    * fix for surface destroy and resume events.

    * add missing types

    Co-authored-by: Cristiano Coelho <cristianocca@hotmail.com>

commit ba0e427
Author: cristianoccazinsp <48869228+cristianoccazinsp@users.noreply.github.com>
Date:   Thu Feb 13 18:02:39 2020 -0300

    feat(android): stop/release camera in non-UI thread (react-native-camera#2685)

    * stop/release camera in non-UI thread so we prevent ANRs and UI freezing.

    Some phones may take up to a second to release the camera and preview.

    * fix for surface destroy and resume events.

    Co-authored-by: Cristiano Coelho <cristianocca@hotmail.com>

commit c683076
Author: semantic-release-bot <semantic-release-bot@martynus.net>
Date:   Wed Feb 5 15:53:24 2020 +0000

    chore(release): 3.17.0 [skip ci]

    # [3.17.0](react-native-camera/react-native-camera@v3.16.0...v3.17.0) (2020-02-05)

    ### Bug Fixes

    * **record:** android crash fix ([react-native-camera#2697](react-native-camera#2697)) ([7c2572d](react-native-camera@7c2572d))

    ### Features

    * **codec:** move codec, max duration, and max file size settings to the session queue. ([react-native-camera#2694](react-native-camera#2694)) ([9b4af8e](react-native-camera@9b4af8e))

commit 7c2572d
Author: cristianoccazinsp <48869228+cristianoccazinsp@users.noreply.github.com>
Date:   Wed Feb 5 12:46:02 2020 -0300

    fix(record): android crash fix (react-native-camera#2697)

    Co-authored-by: Cristiano Coelho <cristianocca@hotmail.com>

commit 9b4af8e
Author: cristianoccazinsp <48869228+cristianoccazinsp@users.noreply.github.com>
Date:   Wed Feb 5 12:45:42 2020 -0300

    feat(codec): move codec, max duration, and max file size settings to the session queue. (react-native-camera#2694)

    This might prevent a race condition when changing presets/quality.

    Co-authored-by: Cristiano Coelho <cristianocca@hotmail.com>

commit 7806f84
Author: semantic-release-bot <semantic-release-bot@martynus.net>
Date:   Mon Jan 27 20:18:11 2020 +0000

    chore(release): 3.16.0 [skip ci]

    # [3.16.0](react-native-camera/react-native-camera@v3.15.1...v3.16.0) (2020-01-27)

    ### Bug Fixes

    * **android:** crash fix for android sdk < 18 ([react-native-camera#2674](react-native-camera#2674)) ([dea3371](react-native-camera@dea3371))

    ### Features

    * **RNCameraManager:** expose videoStabilizationMode from native ([react-native-camera#2681](react-native-camera#2681)) ([cd4c8f2](react-native-camera@cd4c8f2))

commit 8761fe0
Merge: cd4c8f2 ea05b14
Author: Simon Stern <simon160@gmail.com>
Date:   Mon Jan 27 15:12:05 2020 -0500

    Merge pull request react-native-camera#2684 from jackiewung/patch-1

    add pictureSize type to RNCameraProps

commit ea05b14
Author: Jackie Wung <34897095+jackiewung@users.noreply.github.com>
Date:   Thu Jan 23 14:38:49 2020 -0800

    add pictureSize type

commit cd4c8f2
Author: mauriciopf <mauricio.perezflores@gmail.com>
Date:   Wed Jan 22 12:42:20 2020 -0500

    feat(RNCameraManager): expose videoStabilizationMode from native (react-native-camera#2681)

    * fix(RNCameraManager) expose videoStabilizationMode from native

    * refactor(types): add videoStabilization to the module declaration

commit dea3371
Author: cristianoccazinsp <48869228+cristianoccazinsp@users.noreply.github.com>
Date:   Mon Jan 13 14:41:29 2020 -0300

    fix(android): crash fix for android sdk < 18 (react-native-camera#2674)

    Co-authored-by: Cristiano Coelho <cristianocca@hotmail.com>

commit b575388
Author: semantic-release-bot <semantic-release-bot@martynus.net>
Date:   Tue Dec 31 15:35:49 2019 +0000

    chore(release): 3.15.1 [skip ci]

    ## [3.15.1](react-native-camera/react-native-camera@v3.15.0...v3.15.1) (2019-12-31)

    ### Bug Fixes

    * **android:** android  crash fixes. Make sure no unsupported aspect ratio is used, and do not crash when there are no cameras available. ([react-native-camera#2662](react-native-camera#2662)) ([db7b9e4](react-native-camera@db7b9e4))

commit db7b9e4
Author: cristianoccazinsp <48869228+cristianoccazinsp@users.noreply.github.com>
Date:   Tue Dec 31 12:30:01 2019 -0300

    fix(android): android  crash fixes. Make sure no unsupported aspect ratio is used, and do not crash when there are no cameras available. (react-native-camera#2662)

commit d84127f
Merge: acfa7bd e7aa6a3
Author: Simon Stern <simon160@gmail.com>
Date:   Sat Dec 28 14:44:16 2019 -0500

    Merge pull request react-native-camera#2650 from kant/patch-1

    Semantic issue on line 50

commit acfa7bd
Merge: 5de4bc5 2cde2e7
Author: Simon Stern <simon160@gmail.com>
Date:   Sat Dec 28 14:43:36 2019 -0500

    Merge pull request react-native-camera#2657 from react-native-community/docs/api

    Docs: Added several properties to docs and organized the reference with an index

commit 5de4bc5
Merge: 2788b9d 1fa0441
Author: Simon Stern <simon160@gmail.com>
Date:   Sat Dec 28 14:04:38 2019 -0500

    Merge pull request react-native-camera#2659 from react-native-community/dependabot/npm_and_yarn/handlebars-4.5.3

    chore(deps): bump handlebars from 4.1.2 to 4.5.3

commit 1fa0441
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Sat Dec 28 17:54:22 2019 +0000

    chore(deps): bump handlebars from 4.1.2 to 4.5.3

    Bumps [handlebars](https://github.com/wycats/handlebars.js) from 4.1.2 to 4.5.3.
    - [Release notes](https://github.com/wycats/handlebars.js/releases)
    - [Changelog](https://github.com/wycats/handlebars.js/blob/master/release-notes.md)
    - [Commits](handlebars-lang/handlebars.js@v4.1.2...v4.5.3)

    Signed-off-by: dependabot[bot] <support@github.com>

commit 2788b9d
Merge: e274842 fc387c2
Author: Mateus Andrade <mateus.andrade47@outlook.com>
Date:   Sat Dec 28 14:53:39 2019 -0300

    Merge pull request react-native-camera#2658 from react-native-community/dependabot/npm_and_yarn/examples/basic/handlebars-4.5.3

    chore(deps): bump handlebars from 4.1.2 to 4.5.3 in /examples/basic

commit fc387c2
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Sat Dec 28 01:38:45 2019 +0000

    chore(deps): bump handlebars from 4.1.2 to 4.5.3 in /examples/basic

    Bumps [handlebars](https://github.com/wycats/handlebars.js) from 4.1.2 to 4.5.3.
    - [Release notes](https://github.com/wycats/handlebars.js/releases)
    - [Changelog](https://github.com/wycats/handlebars.js/blob/master/release-notes.md)
    - [Commits](handlebars-lang/handlebars.js@v4.1.2...v4.5.3)

    Signed-off-by: dependabot[bot] <support@github.com>

commit e274842
Merge: 84cf1df 2bb2540
Author: Mateus Andrade <mateus.andrade47@outlook.com>
Date:   Thu Dec 26 17:43:15 2019 -0300

    Merge pull request react-native-camera#2651 from kant/patch-2

    Fixed typo on line 91

commit 84cf1df
Merge: 44661fc 81fcbcc
Author: Mateus Andrade <mateus.andrade47@outlook.com>
Date:   Thu Dec 26 17:15:20 2019 -0300

    Merge pull request react-native-camera#2655 from MateusAndrade/fix-ci-build

    Fix ci build

commit 81fcbcc
Author: MateusAndrade <mateus.andrade47@outlook.com>
Date:   Thu Dec 26 16:56:50 2019 -0300

    ci: adding clean to gradlew scripts

commit ae687d0
Merge: 4075cdf 44661fc
Author: Mateus Andrade <mateus.andrade47@outlook.com>
Date:   Thu Dec 26 16:51:43 2019 -0300

    Merge pull request react-native-camera#8 from react-native-community/master

    update fork

commit 2cde2e7
Author: simistern <simon160@gmail.com>
Date:   Wed Dec 25 16:00:52 2019 -0500

    Docs: Added several properties and collected the methods into an index

commit 2bb2540
Author: Darío Hereñú <magallania@gmail.com>
Date:   Wed Dec 25 02:30:25 2019 -0300

    Fixed typo on line 91

commit e7aa6a3
Author: Darío Hereñú <magallania@gmail.com>
Date:   Wed Dec 25 02:24:40 2019 -0300

    Semantic issue on line 50

commit 44661fc
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Fri Dec 13 15:07:23 2019 -0300

    chore(deps): bump npm from 6.4.1 to 6.13.4 (react-native-camera#2643)

    Bumps [npm](https://github.com/npm/cli) from 6.4.1 to 6.13.4.
    - [Release notes](https://github.com/npm/cli/releases)
    - [Changelog](https://github.com/npm/cli/blob/latest/CHANGELOG.md)
    - [Commits](npm/cli@v6.4.1...v6.13.4)

    Signed-off-by: dependabot[bot] <support@github.com>

commit c235435
Author: semantic-release-bot <semantic-release-bot@martynus.net>
Date:   Fri Dec 13 17:55:53 2019 +0000

    chore(release): 3.15.0 [skip ci]

    # [3.15.0](react-native-camera/react-native-camera@v3.14.0...v3.15.0) (2019-12-13)

    ### Features

    * **ios:** Make camera ready events to fire also on camera/device change to be consistent with Android. Fire unmount error when session or device fails to start. Update advanced example app to use camera ready event instead. ([react-native-camera#2642](react-native-camera#2642)) ([7abf3f7](react-native-camera@7abf3f7))

commit 7abf3f7
Author: cristianoccazinsp <48869228+cristianoccazinsp@users.noreply.github.com>
Date:   Fri Dec 13 14:51:50 2019 -0300

    feat(ios): Make camera ready events to fire also on camera/device change to be consistent with Android. Fire unmount error when session or device fails to start. Update advanced example app to use camera ready event instead. (react-native-camera#2642)

commit 0745fb9
Author: semantic-release-bot <semantic-release-bot@martynus.net>
Date:   Tue Dec 10 14:07:04 2019 +0000

    chore(release): 3.14.0 [skip ci]

    # [3.14.0](react-native-camera/react-native-camera@v3.13.1...v3.14.0) (2019-12-10)

    ### Bug Fixes

    * **android:** Fix Objects.equals that is only available after API 19 ([react-native-camera#2635](react-native-camera#2635)) ([8c6a26f](react-native-camera@8c6a26f))
    * **example:** fixes and updates in mlkit example ([react-native-camera#2618](react-native-camera#2618)) ([72c5624](react-native-camera@72c5624))
    * **ts:** fixed incorrect type definition file path ([react-native-camera#2622](react-native-camera#2622)) ([047bbea](react-native-camera@047bbea))

    ### Features

    * **android:** Load Android Gradle Plugin conditionally ([react-native-camera#2623](react-native-camera#2623)) ([d8cf6c9](react-native-camera@d8cf6c9))
    * **android:** restore state when useCamera2api is enabled ([react-native-camera#2603](react-native-camera#2603)) ([1f8b863](react-native-camera@1f8b863))
    * **docs:** update onBarCodeRead on Android and add additional SubView library ([react-native-camera#2616](react-native-camera#2616)) ([fe84811](react-native-camera@fe84811))
    * **iOS:** allow for audio session to be kept ([react-native-camera#2636](react-native-camera#2636)) ([fe5d11d](react-native-camera@fe5d11d))

commit fe5d11d
Author: cristianoccazinsp <48869228+cristianoccazinsp@users.noreply.github.com>
Date:   Tue Dec 10 11:02:45 2019 -0300

    feat(iOS): allow for audio session to be kept (react-native-camera#2636)

    * allow for audio session to be kept even after unmounts

    * readme typo

commit 8c6a26f
Author: cristianoccazinsp <48869228+cristianoccazinsp@users.noreply.github.com>
Date:   Tue Dec 10 11:02:16 2019 -0300

    fix(android): Fix Objects.equals that is only available after API 19 (react-native-camera#2635)

commit 047bbea
Author: SaeedZhiany <SaeedZhiany@users.noreply.github.com>
Date:   Tue Dec 3 22:40:26 2019 +0330

    fix(ts): fixed incorrect type definition file path (react-native-camera#2622)

commit d8cf6c9
Author: SaeedZhiany <SaeedZhiany@users.noreply.github.com>
Date:   Tue Dec 3 22:39:23 2019 +0330

    feat(android): Load Android Gradle Plugin conditionally (react-native-camera#2623)

commit 1f8b863
Author: Märt Lõhmus <martlohmus12@gmail.com>
Date:   Mon Dec 2 14:28:13 2019 +0200

    feat(android): restore state when useCamera2api is enabled (react-native-camera#2603)

commit fe84811
Author: Chau Tran <ctch5@mail.umsl.edu>
Date:   Mon Dec 2 06:27:17 2019 -0600

    feat(docs): update onBarCodeRead on Android and add additional SubView library (react-native-camera#2616)

commit 72c5624
Author: Stanimir <sytolk@gmail.com>
Date:   Mon Dec 2 14:24:12 2019 +0200

    fix(example): fixes and updates in mlkit example (react-native-camera#2618)

commit 0af8ea9
Author: semantic-release-bot <semantic-release-bot@martynus.net>
Date:   Sun Dec 1 23:56:03 2019 +0000

    chore(release): 3.13.1 [skip ci]

    ## [3.13.1](react-native-camera/react-native-camera@v3.13.0...v3.13.1) (2019-12-01)

    ### Bug Fixes

    * **android:** barcode option passing to mlkit for Android ([react-native-camera#2614](react-native-camera#2614)) ([32355f4](react-native-camera@32355f4))

commit 32355f4
Author: Kyle Johnson <1007162+kyle-johnson@users.noreply.github.com>
Date:   Sun Dec 1 15:50:57 2019 -0800

    fix(android): barcode option passing to mlkit for Android (react-native-camera#2614)

    * pass barcode options to mlkit

    * rm doubled FORMAT_ALL_FORMATS

commit c728529
Author: semantic-release-bot <semantic-release-bot@martynus.net>
Date:   Fri Nov 29 22:04:16 2019 +0000

    chore(release): 3.13.0 [skip ci]

    # [3.13.0](react-native-camera/react-native-camera@v3.12.0...v3.13.0) (2019-11-29)

    ### Features

    * **types:** Add "URL" to Barcode types & export additional TS types ([react-native-camera#2613](react-native-camera#2613)) ([3f1334c](react-native-camera@3f1334c))

commit 3f1334c
Author: Kyle Johnson <1007162+kyle-johnson@users.noreply.github.com>
Date:   Fri Nov 29 14:00:10 2019 -0800

    feat(types): Add "URL" to Barcode types & export additional TS types (react-native-camera#2613)

    * Add "URL" to flow types

    * add "URL" to barcodes & export additional TS types

    * add optional format to flow

    * add optionl format prop to TS

commit ecb2071
Author: semantic-release-bot <semantic-release-bot@martynus.net>
Date:   Fri Nov 29 21:18:30 2019 +0000

    chore(release): 3.12.0 [skip ci]

    # [3.12.0](react-native-camera/react-native-camera@v3.11.1...v3.12.0) (2019-11-29)

    ### Bug Fixes

    * **ios:** camera is not detecting any faces ([react-native-camera#2611](react-native-camera#2611)) ([b3d0ebe](react-native-camera@b3d0ebe))

    ### Features

    * **docs:** Feature/simplify installtion ([react-native-camera#2606](react-native-camera#2606)) ([a39e8a8](react-native-camera@a39e8a8))

commit a39e8a8
Author: mieszko4 <mieszko4@gmail.com>
Date:   Fri Nov 29 22:14:31 2019 +0100

    feat(docs): Feature/simplify installtion (react-native-camera#2606)

    * docs: split installation into 2 main sections, simplify required steps

    * doc: structure Additional installation steps

    * docs: Hide firebase additional android steps

    * docs: Highlight code snippets, add link to Windows

commit b3d0ebe
Author: annakoro <ann.korostelev@gmail.com>
Date:   Fri Nov 29 17:02:25 2019 +0300

    fix(ios): camera is not detecting any faces (react-native-camera#2611)
@stale
Copy link

stale bot commented May 12, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and i will leave this open.

@stale stale bot added the stale There has been a lack of activity on this issue and it may be closed soon. label May 12, 2020
@stale
Copy link

stale bot commented May 20, 2020

Closing this issue after a prolonged period of inactivity. Fell free to reopen this issue, if this still affecting you.

@stale stale bot closed this as completed May 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Bug Help Wanted stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

5 participants