Repository: react-native-camera/react-native-camera

Issue #1613: RNCamera: Front Camera shows black screen in example app on iOS
Created: 2018-06-06T21:00:45Z
While ttrying testing (and fixing the feature #1606) with the rn-camera-example application ( https://github.com/react-native-community/rncamera-example). I discovered the following problems:
Steps to reproduce:

Clone rn-camera-example at the current master (rnc-archive/rncamera-example@4f87d52)

git clone https://github.com/react-native-community/rncamera-example.git
cd rncamera-example
# checkout commit in which this occures (master at time of the posting)
git checkout 4f87d52fe41be0bb85eb57b7e7f1456e2f7cdc5f

Install react-native-camera at the version before #1606 got merged

yarn add react-native-camera@https://github.com/react-native-community/react-native-camera.git#9cddb2a7213697663f6e53ad8c9603cd11c16754


Open xcode project and run App on device.


Use the toggle button to switch between cameras.


Observation:

The Front Camera only shows a black screen (sometimes the app crashes while switching)
After the RNCamera Component shows a black screen pressing the SNAP button results in  an application crash a thrown exception

ExceptionsManager.js:73 Exception thrown while executing UI block: *** -[AVCaptureStillImageOutput captureStillImageAsynchronouslyFromConnection:completionHandler:] Inactive/invalid connection passed

Investigation:
When I install the following version of react-native-camera (4a9322c) aka the commit before the preview feature was implemented:
yarn add react-native-camera@https://github.com/react-native-community/react-native-camera.git#4a9322cb8b7d455fc28f7e67a15bff2fd9d7ea3e
The app crashes upon start (with EXC_BAD_ACCESS )
Poor mans console output 😢:
2018-06-06 23:40:02.768087+0200 RNCameraExample[1240:505681] Instantiated <GMVFaceDetector: 0x1740917b0>
2018-06-06 23:40:02.798836+0200 RNCameraExample[1240:505681] Instantiated <GMVFaceDetector: 0x1702817c0>
(lldb)

After applying the following patch everything seems to be fine:
diff --git a/App.js b/App.js
index 47b560d..8440591 100644
--- a/App.js
+++ b/App.js
@@ -192,9 +192,9 @@ export default class CameraScreen extends React.Component {
         zoom={this.state.zoom}
         whiteBalance={this.state.whiteBalance}
         ratio={this.state.ratio}
-        faceDetectionLandmarks={RNCamera.Constants.FaceDetection.Landmarks.all}
-        onFacesDetected={this.onFacesDetected}
-        onFaceDetectionError={this.onFaceDetectionError}
+        // faceDetectionLandmarks={RNCamera.Constants.FaceDetection.Landmarks.all}
+        // onFacesDetected={this.onFacesDetected}
+        // onFaceDetectionError={this.onFaceDetectionError}
         focusDepth={this.state.depth}
         permissionDialogTitle={'Permission to use camera'}
         permissionDialogMessage={'We need your permission to use your camera phone'}
It seems like there a two different problems:

The preview feature somehow breaked using the front camera
Using the face detection results in a bad access crash

Duplicate issue #1763: onFacesDetected breaks app on iOS (device-only)
Created: 2018-08-27T13:44:56Z
Which implementation are you using
RNCamera
Steps to reproduce

Install react-native-camera with face detection using only manual procedures (no cocoapods or react-native link)
Import { RNCamera, FaceDetector }
Add component to page with onFacesDetected callback

Expected behaviour
It should call the callback method defined
Actual behaviour
The app completely freezes and loses connection to Xcode (only on hardware. simulator does not crash)
Environment

React Native version: 0.56.0
React Native platform + platform version: iOS 11.4

react-native-camera
Version: npm version

Closing comment (2018-12-03T01:48:14Z): This might be related to #1613