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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SystemChrome.setPreferredOrientations landscape right or left doesn't work in some conditions #147460

Open
Tom3652 opened this issue Apr 27, 2024 · 3 comments
Assignees
Labels
fyi-ios For the attention of iOS platform team P1 High-priority issues at the top of the work list team-android Owned by Android platform team triaged-android Triaged by Android platform team

Comments

@Tom3652
Copy link

Tom3652 commented Apr 27, 2024

Steps to reproduce

  1. Run the sample code
  2. Rotate the device to landscape mode according to the PreferredOrientations

Expected results

The device should rotate according to the PreferredOrientations selected in the List.

Actual results

  1. If you set :
 await SystemChrome.setPreferredOrientations([
    DeviceOrientation.portraitUp,
    DeviceOrientation.landscapeRight
  ]);

or :

 await SystemChrome.setPreferredOrientations([
    DeviceOrientation.portraitUp,
    DeviceOrientation.landscapeLeft
  ]);

The device doesn't rotate at all from portraitUp

  1. If you set :
 await SystemChrome.setPreferredOrientations([
    DeviceOrientation.portraitUp,
    DeviceOrientation.landscapeRight,
    DeviceOrientation.landscapeLeft
  ]);

The device rotates in all 3 orientations perfectly.

Code sample

Code sample
Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await SystemChrome.setPreferredOrientations([
    DeviceOrientation.portraitUp,
    DeviceOrientation.landscapeRight
  ]);
  runApp(const TestWidget());
}


class TestWidget extends StatefulWidget {
  const TestWidget({super.key});

  @override
  State<TestWidget> createState() => _TestWidgetState();
}

class _TestWidgetState extends State<TestWidget> {
  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: Scaffold(
        body: Center(
          child: Text("Hello world !"),
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.19.6, on macOS 14.4.1 23E224 darwin-x64, locale fr-FR)
    • Flutter version 3.19.6 on channel stable at /Users/foxtom/Desktop/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 54e66469a9 (10 days ago), 2024-04-17 13:08:03 -0700
    • Engine revision c4cd48e186
    • Dart version 3.3.4
    • DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/foxtom/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15E204a
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)

[✓] VS Code (version 1.88.1)
    • VS Code at /Users/foxtom/Desktop/Visual Studio Code.app/Contents
    • Flutter extension version 3.46.0

[✓] Connected device (5 available)
    • moto g 8 power (mobile)     • ZY22BNDW2C                • android-arm64  • Android 11 (API 30)
    • iPhone de Nathalie (mobile) • 00008030-000E64110A8A802E • ios            • iOS 17.4.1 21E236
    • Now You See Me (mobile)     • 00008020-001204401E78002E • ios            • iOS 17.4.1 21E236
    • macOS (desktop)             • macos                     • darwin-x64     • macOS 14.4.1 23E224 darwin-x64
    • Chrome (web)                • chrome                    • web-javascript • Google Chrome 124.0.6367.92
    ! Error: Browsing on the local area network for Apple Watch de Tom. Ensure the device is unlocked and discoverable via Bluetooth. (code -27)

[✓] Network resources
    • All expected network resources are available.

• No issues found!
@darshankawar darshankawar added the in triage Presently being triaged by the triage team label Apr 29, 2024
@darshankawar
Copy link
Member

Thanks for the report @Tom3652
Is this specific to iOS or Android ?
Also, please check below issues and see if they help in your case or not.

#34230
#73651

@darshankawar darshankawar added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Apr 29, 2024
@Tom3652
Copy link
Author

Tom3652 commented Apr 29, 2024

Since you showed me older issues, i have tested them and i have also tested everything using the latest flutter version 3.19.6.

The below tests are made using my sample code in the issue.

  1. IOS :
  • Every rotation (or combination of rotation) is working fine except portraitDown with the error : Failed to change device orientation: Error Domain=UISceneErrorDomain Code=101 "None of the requested orientations are supported by the view controller. Requested: portraitUpsideDown; Supported: landscapeRight" UserInfo={NSLocalizedDescription=None of the requested orientations are supported by the view controller. Requested: portraitUpsideDown; Supported: landscapeRight}

Note : Rotations are blocked if you uncheck the rotation directly in Xcode (in that case, SystemChrome can't do anything)
Capture d’écran 2024-04-29 à 16 57 02

  1. Android :
  • Use portraitUp && landscapeRight or portraitUp && landscapeLeft, only portraitUp is working
  • Use portraitUp && landscapeRight && landscapeLeft it works fine
  • Use landscapeRight || landscapeLeft alone, it starts in the correct orientations but doesn't rotate to the other

This follows my initial issue comment.

For now it's all the tests i have made, i have not tried portraitDown on Android but will update the comment once i do it of course

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Apr 29, 2024
@mossmana mossmana added the P1 High-priority issues at the top of the work list label Apr 29, 2024
@mossmana mossmana self-assigned this Apr 29, 2024
@mossmana mossmana added fyi-ios For the attention of iOS platform team team-android Owned by Android platform team and removed in triage Presently being triaged by the triage team labels Apr 29, 2024
@mossmana
Copy link
Contributor

FYI team-ios: I'm already working on an issue that relates to orientation changes for Android - #144307. So, I can investigate this area of code as it relates to Android. However, there seems to be a cross-platform issue with SystemChrome.setPreferredOrientations. As noted above, there have also been a couple other issues reported in the past for iOS. In response to #147460 (comment), we may want to clarify the expected iOS behavior in regards to Xcode.

@mossmana mossmana added the triaged-android Triaged by Android platform team label Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fyi-ios For the attention of iOS platform team P1 High-priority issues at the top of the work list team-android Owned by Android platform team triaged-android Triaged by Android platform team
Projects
None yet
Development

No branches or pull requests

3 participants