Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(@capacitor/screen-orientation): iOS landscape lock using incorrect mappings #2022

Closed
brian-weasner opened this issue Feb 2, 2024 · 9 comments
Labels
type: bug A confirmed bug report

Comments

@brian-weasner
Copy link
Contributor

brian-weasner commented Feb 2, 2024

Bug Report

Plugin(s)

@capacitor/screen-orientation@5.0.6

Capacitor Version

馃拪   Capacitor Doctor  馃拪 

Latest Dependencies:

  @capacitor/cli: 5.6.0
  @capacitor/core: 5.6.0
  @capacitor/android: 5.6.0
  @capacitor/ios: 5.6.0

Installed Dependencies:

  @capacitor/cli: 5.2.3
  @capacitor/android: 5.4.1
  @capacitor/core: 5.4.1
  @capacitor/ios: 5.4.1

[success] iOS looking great! 馃憣
[success] Android looking great! 馃憣

Platform(s)

  • iOS 14.5 SEE NOTE in technical details below
  • iOS 16.2, and 17.1

Current Behavior

  1. Rotate iOS device to be in landscape.
  2. Query the orientation
  3. Lock to that orientation.
  4. See the screen rotate 180 degrees in the other landscape position.

Expected Behavior

  1. Rotate iOS device to be in landscape.
  2. Query the orientation
  3. Lock to that orientation.
  4. Screen orientation should lock to the current orientation and not rotate.

Code Reproduction

I verified that this is also an issue in the repo https://github.com/WIStudent/capacitor-screen-orientation-issue-reproduction-app made by @WIStudent

Other Technical Details

iOS 14.5

After the screen is locked to the current orientation and the screen rotates 180 degrees, if you query for the current location again, it still shows that the current orientation is NOT THE SAME as the original.

iOS 16.2 & 17.1

After the screen is locked to the current orientation and the screen rotates 180 degrees, if you query for the current location again, it still shows that the current orientation is THE SAME as the original.

What is the issue

Issue lies in the difference between LandscapeLeft and LandscapeRight in UIDeviceOrientation and UIInterfaceOrientation

In UIDeviceOrientation, the focus for left and right is based on the position of the camera, while in UIInterfaceOrientation, the focus for left and right is based on the position of the home button. Both of which, camera and home button, are on opposite sides of the phone.

How to fix

Either:

  1. Change mappings in fromOrientationTypeToMask and fromOrientationTypeToInt so that

    • landscape-primary maps to UIInterfaceOrientationMask.landscapeRight and UIInterfaceOrientation.landscapeRight.rawValue respectfully
    • landscape-secondary maps to UIInterfaceOrientationMask.landscapeLeft and UIInterfaceOrientation.landscapeLeft.rawValue respectfully
  2. Change mapping in fromDeviceOrientationToOrientationType so that

    • UIDeviceOrientation.landscapeRight maps to landscape-primary
    • UIDeviceOrientation.landscapeLeft maps to landscape-secondary

1. IS PREFERRED because it will align the landscape-primary value on iOS and Android devices by having the camera/top of the device on the left, and the home button/bottom of the device on the right. Currently they are in sync on both devices when retrieving current orientation, but not when locking to a specific landscape orientation.

@ionitron-bot ionitron-bot bot added the triage label Feb 2, 2024
@IT-MikeS
Copy link
Contributor

Tracking in #2039

@brian-weasner
Copy link
Contributor Author

This is not completed and the linked ticket does not describe the same problem.

@IT-MikeS
Copy link
Contributor

Ah I see now what you mean. Okay I'm going to reopen this and add it as a bug.

@IT-MikeS IT-MikeS reopened this Feb 23, 2024
@IT-MikeS IT-MikeS changed the title @capacitor/screen-orientation iOS landscape lock behavior incorrect. (Fix included in issue description) bug(@capacitor/screen-orientation): iOS landscape lock using incorrect mappings Feb 23, 2024
@IT-MikeS IT-MikeS added the type: bug A confirmed bug report label Feb 23, 2024
Copy link

ionitron-bot bot commented Feb 23, 2024

This issue has been labeled as type: bug. This label is added to issues that that have been reproduced and are being tracked in our internal issue tracker.

@brian-weasner
Copy link
Contributor Author

@IT-MikeS Is there any eta for when my pr can get looked at, merged and released?
I ask because it has been a couple of months since the issue has been opened, and over a month since the fix was submitted for review.

@IT-MikeS
Copy link
Contributor

IT-MikeS commented Apr 18, 2024

I believe its being looked at now

@brian-weasner
Copy link
Contributor Author

Looks like my Pr has been merged into the 5.x branch! Thank you @IT-MikeS
If you don't mind me asking how long until a new version is published? I assume that version bumping was not something I was supposed to do in the pr?

@IT-MikeS
Copy link
Contributor

No, there will be a release as soon as the thumbs up is given, normally we wait until there are a few fixes in making the release more impactful rather than constant small releases. Expect to see it I'd say within a week but don't quote me on that.

However if you look at the Versions tab on NPM (https://www.npmjs.com/package/@capacitor/screen-orientation?activeTab=versions) you can see there is a nightly, this will have the fixes in it, and may help get you unblocked for development but I don't recommend using it in production

Copy link

ionitron-bot bot commented May 7, 2024

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of the plugin, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators May 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug A confirmed bug report
Projects
None yet
Development

No branches or pull requests

2 participants