Skip to content

fix(iOS): bug ios simulator infinite loop rotating orientation #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

gladiuscode
Copy link
Owner

@gladiuscode gladiuscode commented May 20, 2025

Goal

This PR fixes #73 where only on iOS 15, we fall into a loop once we listen for device orientation changes and we lock the interface to the same device orientation.

Specifically, this happens because we use UIDevice.current.setValue to update the orientation when we rotate the device, doing this it triggers the orientationDidChangeNotification event listener that sends a new deviceOrientationDidChange event and the loop starts.

So we simply track the locking status and avoid sending the deviceOrientationDidChange when we are currently locking the interface to a specific orientation

  • Test on iOS 15
  • Test on iOS 16
  • Test on old arch
  • Test on new arch

@gladiuscode gladiuscode self-assigned this May 20, 2025
@gladiuscode gladiuscode added bug Something isn't working iOS iOS only labels May 20, 2025
@gladiuscode gladiuscode linked an issue May 20, 2025 that may be closed by this pull request
@gladiuscode
Copy link
Owner Author

Well it does work, but I've noticed that currently, on iOS 15 only, if we call the lockTo method, it doesn't rotate the interface and that is kinda weird.

Looking it up online, it does seems like you can't force the orientation to a specific one using the UIDevice anymore from iOS 15, so we have a grey zone where we want to lock the interface to a specific orientation, yet we don't rotate it immediately.

I need to look this up.

@gladiuscode
Copy link
Owner Author

Well it does work, but I've noticed that currently, on iOS 15 only, if we call the lockTo method, it doesn't rotate the interface and that is kinda weird.

Looking it up online, it does seems like you can't force the orientation to a specific one using the UIDevice anymore from iOS 15, so we have a grey zone where we want to lock the interface to a specific orientation, yet we don't rotate it immediately.

I need to look this up.

It turns out I was passing the UIInterfaceOrientationMask enum to the UIDevice.current.setValue method and that's not right since the orientation property requires the UIInterfaceOrientation enum.
I've fixed it but I think that I should track it as a different issue, I'm going to open it soon.

@gladiuscode gladiuscode force-pushed the fix/bug-ios-simulator-infinite-loop-rotating-orientation branch from 087c64e to 4843a0b Compare May 24, 2025 16:13
@gladiuscode gladiuscode merged commit dc634c5 into main May 25, 2025
@gladiuscode gladiuscode deleted the fix/bug-ios-simulator-infinite-loop-rotating-orientation branch May 25, 2025 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working iOS iOS only
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] iOS Simulator infinite loop rotating orientation
1 participant