apache / apache/cordova-plugin-screen-orientation
screenOrientation.unlock() doesn't respect the current orientation on iOS devices
- Dominant language
- JavaScript
- Stars
- 219
- Forks
- 234
- PR merge metrics
- No merged PRs in 30d
Description
### 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
```JS
// 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**
```bash
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**
```bash
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
```
Contributor guide
Research direction
Start by tracing the iOS implementation of screenOrientation.unlock() and the lock/unlock calls shown in the JavaScript example. Reproduce the listed portrait-to-landscape flow on iOS and compare it with Android behavior; done means unlocking preserves the device's current landscape orientation rather than restoring portrait.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, ios, java, javascript, objective-c
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100