fix(ios): use connection rotation for frame coordinates - #4177
Open
huytdps13400 wants to merge 1 commit into
Open
fix(ios): use connection rotation for frame coordinates#4177huytdps13400 wants to merge 1 commit into
huytdps13400 wants to merge 1 commit into
Conversation
|
@huytdps13400 is attempting to deploy a commit to the Margelo Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Frame.orientationandFrame.isMirroredsemantics unchangedThis replaces the closed #4175 with a smaller, data-driven fix for #4114.
Why
AVCaptureVideoPreviewLayerconverts capture-device points in the camera's unrotated image space, whileAVCaptureVideoDataOutputcan physically rotate and mirror delivered buffers. The converter previously received the public output-relative orientation/mirroring values, so Frame and PreviewView did not necessarily refer to the same intermediate coordinate space.The prior PR attempted to bridge the spaces by assuming every camera's native sensor orientation was
.left. That is not valid across devices. This version reads the connection's actualvideoRotationAngleon iOS 17+ instead. Apple explicitly documents that the default can be 180° on newer front-camera iPads and recommends accounting for the connection's default rotation. Older iOS and visionOS retain the existingvideoOrientationbehavior becausevideoRotationAngleis unavailable there.AVCaptureConnection.videoRotationAngleAVCaptureVideoPreviewLayer.layerPointConverted(fromCaptureDevicePoint:)No Android code or public API is changed.
Verification
maps a square Frame region onto a square View regionremains the end-to-end CI oracle1.0; old output-relative wiring3.1604938271604937; 180° connection default and inverse round-trip passbun camera typecheckbun lint-swiftxcodebuild -project apps/simple-camera/ios/Pods/Pods.xcodeproj -scheme VisionCamera -configuration Debug -sdk iphonesimulator -destination 'generic/platform=iOS Simulator' CODE_SIGNING_ALLOWED=NO build(arm64 + x86_64)git diff --checkThe physical-camera Harness run remains the final end-to-end check, especially for a Spring 2024+ front-camera iPad.
Fixes #4114.
Replaces #4175.