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

[web] SystemChrome.setPreferredOrientations crashes silently on Safari #67640

Closed
creativecreatorormaybenot opened this issue Oct 8, 2020 · 6 comments
Labels
a: layout SystemChrome and Framework's Layout Issues browser: safari-macos only manifests in Safari on macOS c: crash Stack traces logged to the console engine flutter/engine repository. See also e: labels. found in release: 1.22 Found to occur in 1.22 found in release: 1.23 Found to occur in 1.23 has reproducible steps The issue has been confirmed reproducible and is ready to work on platform-web Web applications specifically

Comments

@creativecreatorormaybenot
Copy link
Contributor

creativecreatorormaybenot commented Oct 8, 2020

Steps to Reproduce

  1. Be on the beta channel or later with flutter config --enable-web.
  2. Run flutter create bug.
  3. Edit main.dart and add a SystemChrome.setPreferredOrientations (awaited) call:
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await SystemChrome.setPreferredOrientations([]);

  runApp(MyApp());
}

...
  1. flutter run -d chrome the app.
  2. Open the localhost port displayed in Chrome on Safari.

Expected results: the app should start on both Chrome and Safari.

Actual results: will start on Chrome but not on Safari. Removing the SystemChrome line will fix the issue.

JS console (debug mode)

The JS console in Safari will only show the following:

Unhandled Promise Rejection: Error

There is nothing else.

Release mode

The behavior is exactly the same in release builds, i.e. Safari does not run the app.
More importantly: this happens silently, i.e. there is nothing displayed in the JS console.

Because of this, it was incredibly difficult for us to find out why our web app was not working on Safari. In addition to that, dart-lang/sdk#43520 did not allow us to even run the app in debug mode initially.

Versions (click to expand)
Flutter 1.22.0 • channel beta • https://github.com/flutter/flutter.git
Framework • revision d408d302e2 (9 days ago) • 2020-09-29 11:49:17 -0700
Engine • revision 5babba6c4d
Tools • Dart 2.10.0
@TahaTesser
Copy link
Member

TahaTesser commented Oct 8, 2020

Hi @creativecreatorormaybenot

I can reproduce the issue on the latest Channel beta, 1.22.0, and Channel dev, 1.23.0-7.0.pr

Screenshot 2020-10-08 at 9 25 44 PM

flutter doctor -v
[✓] Flutter (Channel dev, 1.23.0-7.0.pre, on Mac OS X 10.15.7 19H2 x86_64,
    locale en-GB)
    • Flutter version 1.23.0-7.0.pre at /Users/tahatesser/Code/flutter_dev
    • Framework revision db6e2d8aa5 (13 days ago), 2020-09-25 06:47:03 -0400
    • Engine revision 3a73d073c8
    • Dart version 2.11.0 (build 2.11.0-161.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/tahatesser/Code/sdk
    • Platform android-30, build-tools 30.0.2
    • ANDROID_HOME = /Users/tahatesser/Code/sdk
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.0.1, Build version 12A7300
    • CocoaPods version 1.10.0.rc.1

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

[✓] Android Studio (version 4.0)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 50.0.1
    • Dart plugin version 193.7547
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6222593)

[✓] VS Code (version 1.49.3)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.15.0

 
[✓] Connected device (4 available)            
    • iPhone 11 Pro Max (mobile) • 8077196C-CC09-401F-8842-06A94368FF46 • ios
      • com.apple.CoreSimulator.SimRuntime.iOS-14-0 (simulator)
    • macOS (desktop)            • macos                                •
      darwin-x64     • Mac OS X 10.15.7 19H2 x86_64
    • Web Server (web)           • web-server                           •
      web-javascript • Flutter Tools
    • Chrome (web)               • chrome                               •
      web-javascript • Google Chrome 85.0.4183.121

• No issues found!
flutter doctor -v
[✓] Flutter (Channel beta, 1.22.0, on Mac OS X 10.15.7 19H2, locale en-GB)
    • Flutter version 1.22.0 at /Users/tahatesser/Code/flutter_beta
    • Framework revision d408d302e2 (9 days ago), 2020-09-29 11:49:17 -0700
    • Engine revision 5babba6c4d
    • Dart version 2.10.0

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/tahatesser/Code/sdk
    • Platform android-30, build-tools 30.0.2
    • ANDROID_HOME = /Users/tahatesser/Code/sdk
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.0.1, Build version 12A7300
    • CocoaPods version 1.10.0.rc.1

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

[✓] Android Studio (version 4.0)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 50.0.1
    • Dart plugin version 193.7547
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6222593)

[✓] VS Code (version 1.49.3)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.15.0

 
[✓] Connected device (3 available)            
    • iPhone 11 Pro Max (mobile) • 8077196C-CC09-401F-8842-06A94368FF46 • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-14-0 (simulator)
    • Web Server (web)           • web-server                           • web-javascript • Flutter Tools
    • Chrome (web)               • chrome                               • web-javascript • Google Chrome
      85.0.4183.121

• No issues found!

However issue seems to be fixed on the latest Channel master, 1.23.0-8.0.pre.223, keeping the issue open for tracking the fix for beta

Screenshot 2020-10-08 at 9 22 54 PM

flutter doctor -v
[✓] Flutter (Channel master, 1.23.0-8.0.pre.223, on Mac OS X 10.15.7 19H2 x86_64, locale en-GB)
    • Flutter version 1.23.0-8.0.pre.223 at /Users/tahatesser/Code/flutter_master
    • Framework revision 82ff246156 (49 minutes ago), 2020-10-08 11:09:27 -0400
    • Engine revision 2eac514f26
    • Dart version 2.11.0 (build 2.11.0-186.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/tahatesser/Code/sdk
    • Platform android-30, build-tools 30.0.2
    • ANDROID_HOME = /Users/tahatesser/Code/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.0.1, Build version 12A7300
    • CocoaPods version 1.10.0.rc.1

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

[✓] Android Studio (version 4.0)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 50.0.1
    • Dart plugin version 193.7547
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] VS Code (version 1.49.3)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.15.0

 
[✓] Connected device (4 available)            
    • iPhone 11 Pro Max (mobile) • 8077196C-CC09-401F-8842-06A94368FF46 • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-14-0 (simulator)
    • macOS (desktop)            • macos                                • darwin-x64     • Mac OS X
      10.15.7 19H2 x86_64
    • Web Server (web)           • web-server                           • web-javascript • Flutter Tools
    • Chrome (web)               • chrome                               • web-javascript • Google Chrome
      85.0.4183.121

• No issues found!
complete code sample
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await SystemChrome.setPreferredOrientations([]);
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Material App',
      theme: ThemeData.dark(),
      home: Home(),
    );
  }
}

class Home extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Material App Bar'),
      ),
      body: Center(
        child: Container(
          child: Text('Hello World'),
        ),
      ),
      floatingActionButton: FloatingActionButton(
        child: Icon(Icons.add),
        onPressed: () {},
      ),
    );
  }
}

@TahaTesser TahaTesser added a: layout SystemChrome and Framework's Layout Issues browser: safari-macos only manifests in Safari on macOS engine flutter/engine repository. See also e: labels. found in release: 1.22 Found to occur in 1.22 found in release: 1.23 Found to occur in 1.23 has reproducible steps The issue has been confirmed reproducible and is ready to work on platform-web Web applications specifically c: crash Stack traces logged to the console labels Oct 8, 2020
@creativecreatorormaybenot
Copy link
Contributor Author

@TahaTesser Thanks a lot! Did you also test on dev? I tested on dev (but not on master) and was able to produce the error on macOS Safari.

@TahaTesser
Copy link
Member

TahaTesser commented Oct 8, 2020

@creativecreatorormaybenot
I did try on dev as mentioned earlier #67640 (comment) , Issue exists on dev

@creativecreatorormaybenot
Copy link
Contributor Author

@TahaTesser I did not realize there were two channels in the first header, sorry.

@ferhatb
Copy link
Contributor

ferhatb commented Oct 8, 2020

Closing. Will get fix on next dev release.

@ferhatb ferhatb closed this as completed Oct 8, 2020
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: layout SystemChrome and Framework's Layout Issues browser: safari-macos only manifests in Safari on macOS c: crash Stack traces logged to the console engine flutter/engine repository. See also e: labels. found in release: 1.22 Found to occur in 1.22 found in release: 1.23 Found to occur in 1.23 has reproducible steps The issue has been confirmed reproducible and is ready to work on platform-web Web applications specifically
Projects
None yet
Development

No branches or pull requests

3 participants