fix: Remove sensorOrientation
hack on iOS, it's always portrait
#3096
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
So either I was completely drunk when building this initially, or I was way too tired already.
But I just re-visited the orientation implementation on iOS, and it seems like
.sensorOrientation
always returns.portrait
!I just tested this on both my iPhone 15 Pro and my iPhone 8 and they work in every orientation - no matter if landscape or portrait, no matter if front or back camera.
I revisited the orientation implementation because I wanted to to get rid of the
sensorOrientation
hack I built.The hack was that everytime I want to know the
sensorOrientation
of anAVCaptureDevice
, I have to build up an AVCaptureSession and attach a Video Output to it - which was slow (~5ms per call, 20 calls on an iPhone 15 Pro at startup), and was insanely hacky.It also crashed when you don't have camera permission yet, or the device is invalid.
This is the hacky code btw:
react-native-vision-camera/package/ios/Core/Extensions/AVCaptureDevice+sensorOrientation.swift
Lines 18 to 73 in 0654898
And now I just return
.portrait
- which works and speeds up the app! :)Changes
So now
sensorOrientation
doesnTested on
Related issues