flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
165.91k stars 27.4k forks source link

[Android 12] Display Size changes in settings are not reflected immediately #142905

Open ezawa-arise opened 8 months ago

ezawa-arise commented 8 months ago

While using an app developed with Flutter on an Android 12 device, we found a bug in which changing the display size in the OS settings is not reflected in the app. In more detail, the bug states that the first time you change the display size, the change is not reflected, and if you change the display size again, the settings from the first change are reflected.

We have investigated the conditions under which this bug occurs and have confirmed that it is limited to Android 12 and does not occur on Android 10, 11, 13, or iOS 15-17. We have also investigated multiple Flutter and non-Flutter apps and have confirmed that this bug only occurs in apps developed with Flutter.

The following are the steps to reproduce the bug.

Steps to reproduce

  1. Launch any app developed with Flutter on an Android 12 emulator or device.
  2. Open the OS settings screen and change the size on the Display -> Display Size page.
  3. Open the original app and check to see if the size has changed.
  4. Open the OS Settings page again and change the display size.
  5. Open the original app and check if the size has been changed.

Expected results

After Step.3 & Step.5

The display size of the application has been changed to the one you set.

Actual results

After Step.3

The app's display size has not been changed.

After Step.5

The display size is the same as the size set one time before (and this event repeats every time the size is changed afterwards).

Flutter Doctor output

Doctor output ```console [✓] Flutter (Channel stable, 3.13.8, on macOS 13.3.1 22E772610a darwin-arm64, locale ja-JP) • Flutter version 3.13.8 on channel stable at /Users/yuki.ezawa/.asdf/installs/flutter/3.13.8-stable • Upstream repository https://github.com/flutter/flutter.git • Framework revision 6c4930c4ac (4 months ago), 2023-10-18 10:57:55 -0500 • Engine revision 767d8c75e8 • Dart version 3.1.4 • DevTools version 2.25.0 [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2) • Android SDK at /Users/yuki.ezawa/Library/Android/sdk • Platform android-33, build-tools 33.0.2 • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 14.2) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 14C18 • CocoaPods version 1.11.3 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2022.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.6+0-17.0.6b802.4-9586694) [✓] VS Code (version 1.85.1) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.80.0 [✓] Connected device (5 available) • sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64 • Android 13 (API 33) (emulator) • sdk gphone64 arm64 (mobile) • emulator-5556 • android-arm64 • Android 12 (API 31) (emulator) • iPhone SE (3rd generation) (mobile) • 812919F4-7E51-4EC4-9368-262C7BC99202 • ios • com.apple.CoreSimulator.SimRuntime.iOS-16-2 (simulator) • macOS (desktop) • macos • darwin-arm64 • macOS 13.3.1 22E772610a darwin-arm64 • Chrome (web) • chrome • web-javascript • Google Chrome 121.0.6167.139 [✓] Network resources • All expected network resources are available. • No issues found! ```
RudraOp9 commented 8 months ago

can i get the release / debug application to test my self. and also instead of changing by going ( Display -> Display Size page.) do this by going Settings -> developer options -> dpi for android (in your case) . also verify that is this this problem with all android 12 devices or is that your specific.

ezawa-arise commented 8 months ago

@RudraOp9 Thank you for your comment.

can i get the release / debug application to test my self.

We are sorry, but due to an event that occurred in the development of an application for business use, we are unable to provide you with the application. Instead, we can confirm that it can be reproduced with "Google Ads," one of the Flutter-made apps available on the Google Play Store. We believe we can also reproduce it with the Flutter default app.

and also instead of changing by going ( Display -> Display Size page.) do this by going Settings -> developer options -> dpi for android (in your case) .

This issue is not intended to be a developer option, as this bug is caused by general Android user operations.

also verify that is this this problem with all android 12 devices or is that your specific.

Thank you for pointing this out. We believe it occurs on all Android 12 devices, but indeed we have only confirmed it on some Android 12 devices. Below are the specifications of the Android 12 devices used in our investigation

danagbemava-nc commented 8 months ago

Hi @ezawa-arise, it appears that you are using an older version of the flutter framework, can you upgrade to the latest version of flutter stable (3.16.9) to see if you still experience this issue?

Please provide the updated output of flutter doctor -v if you still experience this issue after the upgrade.

Thank you

ezawa-arise commented 8 months ago

@danagbemava-nc

I still experience this issue after upgrade to flutter 3.16.9-stable.

Attached below is a log of flutter doctor -v.

[✓] Flutter (Channel stable, 3.16.9, on macOS 13.3.1 22E772610a darwin-arm64, locale ja-JP)
    • Flutter version 3.16.9 on channel stable at /Users/yuki.ezawa/.asdf/installs/flutter/3.16.9-stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 41456452f2 (12 days ago), 2024-01-25 10:06:23 -0800
    • Engine revision f40e976bed
    • Dart version 3.2.6
    • DevTools version 2.28.5

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at /Users/yuki.ezawa/Library/Android/sdk
    • Platform android-33, build-tools 33.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14C18
    • CocoaPods version 1.11.3

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

[✓] Android Studio (version 2022.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.6+0-17.0.6b802.4-9586694)

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

[✓] Connected device (4 available)
    • sdk gphone64 arm64 (mobile)         • emulator-5554                        • android-arm64  • Android 12 (API 31) (emulator)
    • iPhone SE (3rd generation) (mobile) • 812919F4-7E51-4EC4-9368-262C7BC99202 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-16-2 (simulator)
    • macOS (desktop)                     • macos                                • darwin-arm64   • macOS 13.3.1 22E772610a darwin-arm64
    • Chrome (web)                        • chrome                               • web-javascript • Google Chrome 121.0.6167.139

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

• No issues found!
danagbemava-nc commented 8 months ago

Reproducible only on android 12 using any flutter app and the steps outlined above.

Labeling for further investigation.

flutter doctor -v (stable and master) ```bash [✓] Flutter (Channel stable, 3.16.9, on macOS 14.1 23B74 darwin-x64, locale en-VN) • Flutter version 3.16.9 on channel stable at /Users/huynq/Documents/GitHub/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 41456452f2 (14 hours ago), 2024-01-25 10:06:23 -0800 • Engine revision f40e976bed • Dart version 3.2.6 • DevTools version 2.28.5 [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at /Users/huynq/Library/Android/sdk • Platform android-34, build-tools 34.0.0 • ANDROID_HOME = /Users/huynq/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 15.0.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15A507 • CocoaPods version 1.14.3 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2023.1) • Android Studio at /Applications/Android Studio Hedgehog.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.7+0-17.0.7b1000.6-10550314) [✓] Android Studio (version 2022.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 • android-studio-dir = /Applications/Android Studio.app/ • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694) [✓] VS Code (version 1.85.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.80.0 [✓] Connected device (4 available) • RMX2001 (mobile) • EUYTFEUSQSRGDA6D • android-arm64 • Android 11 (API 30) • iPhone (mobile) • d9a94afe2b649fef56ba0bfeb052f0f2a7dae95e • ios • iOS 15.8 19H370 • macOS (desktop) • macos • darwin-x64 • macOS 14.1 23B74 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 120.0.6099.234 [✓] Network resources • All expected network resources are available. • No issues found! ``` ```bash [!] Flutter (Channel master, 3.20.0-2.0.pre.17, on macOS 14.1 23B74 darwin-x64, locale en-VN) • Flutter version 3.20.0-2.0.pre.17 on channel master at /Users/huynq/Documents/GitHub/flutter_master ! Warning: `flutter` on your path resolves to /Users/huynq/Documents/GitHub/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/huynq/Documents/GitHub/flutter_master. Consider adding /Users/huynq/Documents/GitHub/flutter_master/bin to the front of your path. ! Warning: `dart` on your path resolves to /Users/huynq/Documents/GitHub/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/huynq/Documents/GitHub/flutter_master. Consider adding /Users/huynq/Documents/GitHub/flutter_master/bin to the front of your path. • Upstream repository https://github.com/flutter/flutter.git • Framework revision 6322fef7e0 (29 minutes ago), 2024-02-05 21:53:12 -0500 • Engine revision 808886312e • Dart version 3.4.0 (build 3.4.0-104.0.dev) • DevTools version 2.32.0 • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades. [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at /Users/huynq/Library/Android/sdk • Platform android-34, build-tools 34.0.0 • ANDROID_HOME = /Users/huynq/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 15.0.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15A507 • CocoaPods version 1.14.3 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2023.1) • Android Studio at /Applications/Android Studio Hedgehog.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.7+0-17.0.7b1000.6-10550314) [✓] Android Studio (version 2022.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 • android-studio-dir = /Applications/Android Studio.app/ • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694) [✓] VS Code (version 1.85.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.80.0 [✓] Connected device (4 available) • RMX2001 (mobile) • EUYTFEUSQSRGDA6D • android-arm64 • Android 11 (API 30) • iPhone (mobile) • d9a94afe2b649fef56ba0bfeb052f0f2a7dae95e • ios • iOS 15.8 19H370 • macOS (desktop) • macos • darwin-x64 • macOS 14.1 23B74 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 121.0.6167.139 [✓] Network resources • All expected network resources are available. ! Doctor found issues in 1 category. ```
G9T3N commented 2 months ago

try this in your code it my fix the problem builder: (context, child) { final originalTextScaleFactor = MediaQuery.of(context).textScaler; final boldText = MediaQuery.boldTextOf(context); final newMediaQueryData = MediaQuery.of(context).copyWith( textScaler: originalTextScaleFactor.clamp( minScaleFactor: 0.8, maxScaleFactor: 1.0, ), boldText: boldText, ); return MediaQuery(data: newMediaQueryData, child: child!); },

add this under MaterialAppWidget if this property is doesn't available try use GetMaterialApp

like this

return GetMaterialApp( builder: (context, child) { final originalTextScaleFactor = MediaQuery.of(context).textScaler; final boldText = MediaQuery.boldTextOf(context); final newMediaQueryData = MediaQuery.of(context).copyWith( textScaler: originalTextScaleFactor.clamp( minScaleFactor: 0.8, maxScaleFactor: 1.0, ), boldText: boldText, ); return MediaQuery(data: newMediaQueryData, child: child!); }, getPages: route, locale: const Locale('ar'), debugShowCheckedModeBanner: false, initialBinding: IntialBindings(), title: 'First Method', // You can use the library anywhere in the app even in theme theme: AppThemes.appLightTheme, home: // Directionality(textDirection: TextDirection.rtl, child: ) child! // ), ); }, child: const Home(),