cordova-plugin-screen-orientation icon indicating copy to clipboard operation
cordova-plugin-screen-orientation copied to clipboard

screenOrientation.unlock() doesn't respect the current orientation on iOS devices

Open jonastg opened this issue 6 years ago • 12 comments

Expected behaviour

The device should keep the current screen orientation — the screen was previously locked — after the screen is unlocked.

Actual behaviour

The screen rotates to the previous orientation when the screen was locked.

Steps to reproduce it

  • The device is in portrait orientation.
  • The user does action that locks screen in landscape orientation.
  • The user rotates the device to watch screen in landscape mode.
  • The user finish the action by which screen was locked.
  • Screen is unlocked and it rotates to portrait (instead keep landscape).

It fails on

  • [X] iOS devices

It works on

  • [X] Android devices

OS versions tested

  • iOS 9.3.5
  • iOS 11.4.1
  • Android 7.0

Code example

// player is instance of plyr.io
this.player.on('enterfullscreen', () => {
  this.statusBar.hide();
  this.screenOrientation.lock(this.screenOrientation.ORIENTATIONS.LANDSCAPE);
});
this.player.on('exitfullscreen', () => {
  this.screenOrientation.unlock();
  this.statusBar.show();
});

Build system

Android

Ionic:

   ionic (Ionic CLI)  : 4.0.5
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.2.0

Cordova:

   cordova (Cordova CLI) : 8.0.0
   Cordova Platforms     : android 7.1.2

System:

   Android SDK Tools : 26.1.1
   NodeJS            : v8.11.3
   npm               : 6.4.1
   OS                : Linux 4.4

iOS

Ionic:

   ionic (Ionic CLI)  : 4.2.1
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.2.0

Cordova:

   cordova (Cordova CLI) : 8.0.0
   Cordova Platforms     : ios 4.5.5
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.2, cordova-plugin-ionic-webview 1.2.1, (and 16 other plugins)

System:

   ios-deploy : 2.0.0
   ios-sim    : 7.0.0
   NodeJS     : v6.10.1
   npm        : 3.10.10
   OS         : macOS High Sierra
   Xcode      : Xcode 10.0 Build version 10A255

jonastg avatar Nov 20 '18 15:11 jonastg

Hm, I think you are using "locked" here in two different meanings - one for this plugin and one for locking the device. You might want to update and clarify that ;) (maybe just add the method calls to the "Steps to reproduce it" list)

janpio avatar Nov 20 '18 15:11 janpio

Thank you for your feedback! I mean about blocking the screen orientation. I have updated expected behaviour description and added a code example.

jonastg avatar Nov 20 '18 16:11 jonastg

The issue describes same bug that jira ticket, it would be great if any of the available PRs that fix the problem is merged.

jonastg avatar Nov 21 '18 12:11 jonastg

Feel free to point out the best PR (here) and document how you tested and confirmed its correctness (in the PR comments). Thanks.

janpio avatar Nov 21 '18 12:11 janpio

Not to hijack the issue, but it's simply not working for me. On app mount (using Vuetify), I set it to portrait and lock it. However it simply hangs the initial UI load. If I place it later, say on the "Home Page" after a successful login, the page loads fine, but no locking ever occurs. Please advise.

humblecoder avatar Nov 24 '18 02:11 humblecoder

You just did hijack this issue @humblecoder. Please create a new issue with your problem and we will see if we can help you. (I will hide your comment and this reponse later.)

janpio avatar Nov 24 '18 12:11 janpio

I've tried the valid PR #31 but it doesn't work as expected. See comment https://github.com/apache/cordova-plugin-screen-orientation/pull/31#issuecomment-455197262.

jonastg avatar Jan 25 '19 13:01 jonastg

Any news on this issue ?

RHinderiks avatar May 07 '19 14:05 RHinderiks

@jonastg @janpio @humblecoder @RHinderiks @infil00p - Can You guys once try by installing plugin from here - https://github.com/Anuj-logiciel/cordova-plugin-screen-orientation

Anuj-logiciel avatar Jul 30 '19 18:07 Anuj-logiciel

I correct the problem like that, https://github.com/ozgeekemen/cordova-plugin-screen-orientation/commit/e53bf7416a7e40f5658e5b50e2ac05476dd07429

ozgeekemen avatar Feb 04 '20 10:02 ozgeekemen

Comment line 76 of CDVOrientation.m file It works for me!

RiccardoFeliciotti94 avatar Feb 24 '20 19:02 RiccardoFeliciotti94

Hi guys,

2 1/2 years later and the bug is still present. Is this plugin dead or what needs to be done to get this fixed and a consistent behaviour?

phal0r avatar Nov 25 '20 08:11 phal0r