Skip to content

[BUG] iOS Simulator infinite loop rotating orientation #73

@renatomserra

Description

@renatomserra

Describe the bug
Im facing an issue only on iOS where it seems orientation is constantly changing.
It seems when i try to lock i get a new event with new orientation, so it causes an infinite loop.

To Reproduce

  useEffect(() => {
    const listener = RNOrientationDirector.listenForDeviceOrientationChanges(
      ({orientation}) => {
        if (RNOrientationDirector.isLockableOrientation(orientation)) {
          RNOrientationDirector.lockTo(orientation, OrientationType.device);
        }
      },
    );

    return () => {
      listener.remove();
    };
  }, []);

Expected behavior
Would just flip once if orientation changed

Screenshots
If applicable, add screenshots to help explain your problem.

Smartphone (please complete the following information):

  • OS: iOS
  • Device: Iphone 13 Pro Max (simulator)
  • Version 15

Environment

System:
  OS: macOS 15.4.1
  CPU: (8) arm64 Apple M1 Pro
  Memory: 110.69 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.9.0
    path: ~/.nvm/versions/node/v20.9.0/bin/node
  Yarn:
    version: 1.22.19
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.1.0
    path: ~/.nvm/versions/node/v20.9.0/bin/npm
  Watchman:
    version: 2025.04.28.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /Users/renatoserra/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.2
      - iOS 18.2
      - macOS 15.2
      - tvOS 18.2
      - visionOS 2.2
      - watchOS 11.2
  Android SDK:
    Build Tools:
      - 34.0.0
    Android NDK: Not Found
IDEs:
  Android Studio: 2021.2 AI-212.5712.43.2112.8815526
  Xcode:
    version: 16.2/16C5032a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.13
    path: /usr/bin/javac
  Ruby:
    version: 2.7.5
    path: /Users/renatoserra/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 13.6.9
    wanted: 13.6.9
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.74.5
    wanted: 0.74.5
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false
Simulator.Screen.Recording.-.iPhone.13.Pro.Max.-.2025-05-19.at.00.36.01.mp4

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggood first issueGood for newcomers

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions