iOS: RTCCameraVideoCapturer tags every frame 90 degrees wrong when the display is not mounted in the device's portrait frame (iPhone Duo inner display); use AVCaptureDevice.RotationCoordinator
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 43/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- ios, objective-c
- 領域
- mobile
調査の方向性
Start in the iOS camera capturer at captureOutput:didOutputSampleBuffer:fromConnection: and updateOrientation, which the issue identifies as the sources of the frame rotation tag. Review the rotation coordinator guidance and the existing orientation table, then check the capture rotation behavior on the iPhone Duo inner display, across folding and unfolding, and with external cameras. Done means frames stay upright in the preview and remotely, while the existing fallback behavior remains covered on older iOS versions and external cameras.
索引モデルが issue の本文から書いたものです。
説明
Versions: StreamWebRTC 145.17.0 (through @stream-io/react-native-webrtc 145.4.1 and @stream-io/video-react-native-sdk 1.46.3). The same code is in 145.25.0 and 156.0.7. iOS 27.1, iPhone Duo. App built with Xcode 27.1 (iOS 27.1 SDK), UIRequiresFullScreenIgnoredStartingWithVersion~iphone set so the app runs full screen on the inner display, landscape allowed during a call.
Steps
- Open the iPhone Duo and start a call on the inner display with the front camera, holding the device so the inner display is in landscape (its natural way).
- Look at the local preview and at the remote side.
Expected: the local preview and the remote side are upright.
Actual: the video is rotated 90 degrees, in the local preview and on the remote side alike. From the code below, every pose of the open device is a quarter turn off, and folding mid-call does not trigger a re-read.
Cause
captureOutput:didOutputSampleBuffer:fromConnection:derives the frame'sRTCVideoRotationfrom a fixed table keyed on the interface orientation read inupdateOrientation(connectedScenes.anyObject.interfaceOrientation): portrait 90, portraitUpsideDown 270, landscapeLeft front 0 / back 180, landscapeRight front 180 / back 0.- The table assumes the display and the device body share one frame of reference. The iPhone Duo's inner display is mounted a quarter turn off the body. When the device is closed, portrait has the charging port down; when it is open, landscape-right has the port down. So on the inner display every interface orientation maps to a tag that is 90 degrees off.
- Folding or unfolding posts no
UIDeviceOrientationDidChangeNotification, soupdateOrientationis not re-run when the app moves between displays either. - WebKit hit the same problem with the same kind of table and fixed it for this device (WebKit PR 79476, "always presented at a 90 degree shift").
Suggested fix
On iOS 17 and later, tag frames from Apple's rotation coordinator instead of the table:
// once per device (recreate on a camera switch)
_coordinator = [[AVCaptureDeviceRotationCoordinator alloc] initWithDevice:device previewLayer:nil];
// KVO on videoRotationAngleForHorizonLevelCapture (delivered on the main queue)
// per frame (or cached on change)
CGFloat angle = _coordinator.videoRotationAngleForHorizonLevelCapture - connection.videoRotationAngle;
long quarter = (((lround(angle / 90.0)) % 4) + 4) % 4;
RTCVideoRotation rotation = (RTCVideoRotation)(quarter * 90);
- Subtract the connection's own
videoRotationAngle. Apple's guidance (Developer Forums thread 813548) is that the coordinator's angle is relative to the unrotated sensor, and iPhone 17 front cameras have a different sensor rotation (the coordinator returns 0 in portrait there, 90 on earlier iPhones). - Apple's iPhone Duo camera talk (Tech Talk 111465) says the rotation coordinator "will update when your app moves displays", which covers fold and unfold.
- Keep the current table as the fallback before iOS 17 and for
AVCaptureDeviceTypeExternal(the coordinator returns 0 for external cameras).
Workaround we use meanwhile
A frame processor registered through react-native-webrtc's ProcessorProvider (track._setVideoEffect). On devices that have AVCaptureDeviceTypeBuiltInInnerUltraWideCamera it re-tags each frame with the angle above when it differs from the capturer's tag. It changes only the rotation tag, never pixels. It would be better in the capturer itself.
Related, separate
When the camera restarts during a Picture in Picture or background-to-foreground transition, updateOrientation runs once at startCaptureWithDevice: and can read portrait from a scene that has not settled. Nothing moves the device, so no device-orientation notification follows, and frames stay tagged portrait until the phone is physically turned. The coordinator also covers this case. Without it, pick the foregroundActive window scene rather than anyObject, read effectiveGeometry.interfaceOrientation (iOS 16 and later), and re-sample when the scene activates.
- 主要言語
- C++
- スター
- 9
- フォーク
- 6
- 平均マージ
- 18時間 4分
- マージ済み PR(30日)
- 25
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
GetStream/webrtc のほかの issue
GetStream/webrtc の issue をすべて見る
似ている issue
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
raspberrypi/rpi-imager#1804 ·
-
difficulty: easy docs good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
Ryan-Millard/Img2Num#842 ·
メンテナーはふだん 12 日以内に返信
-
Unit converter reads out of bounds when the saved UnitConverterPreferences setting is malformedオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
microsoft/calculator#2532 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
-
bug difficulty:easy prio:normal
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
NatronGitHub/openfx-misc#411 ·
メンテナーはふだん 1 日以内に返信