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
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 43/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- ios, objective-c
- Área
- mobile
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- C++
- Estrellas
- 9
- Forks
- 6
- Merge medio
- 18 h 4 min
- PR fusionados (30 d)
- 25
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de GetStream/webrtc
-
Dificultad 4/5 3-5 días Aptitud para principiantes 68/100
GetStream/webrtc#114 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de GetStream/webrtc
Issues similares
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
raspberrypi/rpi-imager#1804 ·
-
difficulty: easy docs good first issue help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Ryan-Millard/Img2Num#842 ·
Los mantenedores suelen responder en 12 días
-
Unit converter reads out of bounds when the saved UnitConverterPreferences setting is malformedAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
microsoft/calculator#2532 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
-
bug difficulty:easy prio:normal
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
NatronGitHub/openfx-misc#411 ·
Los mantenedores suelen responder en 1 día