Fix iOS orientation updates during transitions#4117
Conversation
kmichalikk
left a comment
There was a problem hiding this comment.
Thanks for the PR. Please answer my comments. Also, I would like to have a step-by-step instructions on how to reproduce the bug. Most preferably, prepare an issue test in our repo with a code that could be put into one file. If expo is required, then paste the file in the PR and tell what to do besides create-expo-app, but please don't add unnecessary dependencies, expo-router, etc, if not necessary.
|
Updated the PR description with step-by-step reproduction instructions and a one-file native-stack example. The branch already includes the iOS 16 availability guard and resolves the orientation update controller from the scene used for the geometry request. |
kmichalikk
left a comment
There was a problem hiding this comment.
I tested some more and I can see that on our FabricExample the one-file example works correctly without patches, on expo with react-navigation template it works only if expo-dev-client is uninstalled, and it fails if it is installed, patch doesn't help there. So I am not able to successfully reproduce & see it being fixed, I don't know how to proceed here.
cc @kkafar
|
Thanks for retesting. I agree this is a blocker for the PR as currently framed. I checked the external repro again, and it is not a pure
This PR only targets the second part, so if the |
Summary
windowScene.interfaceOrientation.Root cause
enforceDesiredDeviceOrientationgated iOS 16+requestGeometryUpdatebehind a pre-iOS-16 heuristic that compares the current device and scene interface orientations. During navigation transitions, scene restoration, or after previous geometry updates,windowScene.interfaceOrientationcan be stale. When the stale orientation still appears to satisfy the new mask, the method skips the iOS 16+ geometry request completely.UIKit may also reject a transition-time request while its supported-orientation cache still reflects the outgoing screen. The previous error handler was empty, so these failed requests disappeared without another attempt.
Reproduction
This is easiest to reproduce with the Expo repro from the issue because it exercises native-stack per-screen orientation changes during a real iOS transition.
git clone https://github.com/JeanDes-Code/orientation-lock-reprocd orientation-lock-repronpm installpatches/react-native-screens+4.23.0.patchso the app runs against unpatched react-native-screens. Theexpo-screen-orientationpatch can remain.npm installnpx expo prebuild --cleannpx expo run:iosoptions={{ orientation: 'landscape_right' }}.The app-level repro is equivalent to this single-file native-stack setup:
Validation
yarn check-typesyarn lint-swiftxcodebuild -workspace FabricExample/ios/FabricExample.xcworkspace -scheme FabricExample -configuration Debug -destination "platform=iOS Simulator,name=iPhone 17 Pro Max,OS=latest" -derivedDataPath /Users/sorincioban/Library/Developer/Xcode/DerivedData/RNScreensOSS CODE_SIGNING_ALLOWED=NO buildFixes #3831