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

Issue #1725: RNCamera Android Orientation
Created: 2018-08-02T12:46:17Z
So, RNCamera on Android will frequently save pictures in the wrong orientation. This seems to happen especially when the app's orientation has been locked - in my case, my app is locked to landscape orientation, and pictures will be saved correctly in one orientation, and upside down in the other orientation.
I'm very much not an expert on this, but I've been digging through the code and other posted issues, and near as I can tell this happens because RNCamera is finding its orientation by listening for onOrientationChanged events. (I don't know if locking the orientation blocks these events from firing or what, but like I said, very much not an expert)
The fixOrientation option seems to take the final image, read its real exif orientation, then processes the image to match that, I think? The big problem is that it's slow as hell, especially compared to RCTCamera.
So I figured I'd check in case I've missed a solution or workaround somewhere - has anybody figured out how to fix this, or come up with a workaround that doesn't multiply the amount of time it takes to take a picture?
If not, I think I may have found where the camera orientation change happens. Please correct me if I'm wrong: The RNCameraView implements Google's CameraView, and just straight up calls super.takePicture(). CameraView seems to be a very nice and neat and convenient wrapper around the Camera API, so that's nice, except it bases its orientation on listening for onOrientationChanged events.
So, in theory, adding a check for the device's real orientation to CameraView's takePicture() function might solve the orientation issue without needing to reprocess every single picture.
EDIT: Yeah, I was mostly wrong, slightly right. CameraView uses yet another wrapper around the Camera API, and that's where the API is really called. Camera1.java takePictureInternal(). Finally, something I recognize from the old version.
Heading to lunch now, but I'm gonna try that after. Figured I'd put this up. Am I on totally the wrong path here? Has anybody solved this, so I don't have to waste time being wrong or duplicating someone else's solution?

Duplicate issue #1652: [Android] when orientation is locked programmatically, recorded video is sometimes rotated
Created: 2018-06-20T00:22:13Z
Which implementation are you using
RNCamera
Android
Steps to reproduce

Lock the screen orientation to portrait mode programatically
Mount the camera component
start recording

Expected behaviour
If the video has been recorded with the physical orientation of the phone in landscape or portrait mode, those videos should have the correct orientation when they are played.
Actual behaviour

When the orientation is locked to portrait programmatically and the phone is placed in landscape physical orientation, the recorded video comes rotated.
When the orientation is locked to portrait programmatically and the phone is placed in portrait physical orientation, the recorded video orientation comes out okay.

Environment

React Native version:  0.55.4
React Native platform + platform version:  Android 5.0

react-native-camera
Version: npm version or "master": master
In order to make this work some changes in https://github.com/react-native-community/react-native-camera/blob/master/android/src/main/java/com/google/android/cameraview/DisplayOrientationDetector.java#L59 would need to be made. The current limitation is that Display.getRotation gets the screen rotation based on the natural state of the device. When the orientation is locked programmatically, this value never changes.
A potential solution is to use the orientation from the listener in order to set the output video orientation and use Display.getRotation to set the video preview orientation
I'd love to send a PR with this solution. However, I want to understand if you guys would be willing to accept my changes.

Closing comment (2018-12-12T14:56:23Z): Possibly related to #1725