Repository navigation
Severe jank observed when enabling useMaterial3 in Flutter 3 #104229
Description
Activity
- addedin triagePresently being triaged by the triage teamPresently being triaged by the triage team
on May 20, 2022 Issue is reproducible on
stableandmasteronly onandroid.I tested on a
POCO X3 NFCand I did about 300 taps withuseMaterial3false/true.When useMaterial3 was false, the framerate was steady, around 59fps whereas if it was true, it kept reducing until I ended up around 48fps or so. I have attached below devtools json files captured for both
androidandiOS. The other platforms I tested on (chrome and macOS) showed the same performance asiOSwithuseMaterial3: true.code sample
import 'package:flutter/material.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.blue, useMaterial3: true, ), home: const MyHomePage(title: 'Flutter Demo Home Page'), ); } } class MyHomePage extends StatefulWidget { const MyHomePage({Key? key, required this.title}) : super(key: key); final String title; @override State<MyHomePage> createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { int _counter = 0; void _incrementCounter() { setState(() { _counter++; }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(widget.title), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ const Text( 'You have pushed the button this many times:', ), Text( '$_counter', style: Theme.of(context).textTheme.headline4, ), ], ), ), floatingActionButton: FloatingActionButton( onPressed: _incrementCounter, tooltip: 'Increment', child: const Icon(Icons.add), ), ); } }
flutter doctor -v
[✓] Flutter (Channel stable, 3.0.1, on macOS 12.3.1 21E258 darwin-arm, locale en-GB) • Flutter version 3.0.1 at /Users/nexus/dev/sdks/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision fb57da5f94 (10 hours ago), 2022-05-19 15:50:29 -0700 • Engine revision caaafc5604 • Dart version 2.17.1 • DevTools version 2.12.2 [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0) • Android SDK at /Users/nexus/Library/Android/sdk • Platform android-32, build-tools 31.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 13.3.1) • Xcode at /Applications/Xcode.app/Contents/Developer • CocoaPods version 1.11.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2021.1) • 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 11.0.11+0-b60-7772763) [✓] VS Code (version 1.67.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.40.0 [✓] Connected device (4 available) • M2007J20CG (mobile) • 5dd3be00 • android-arm64 • Android 11 (API 30) • Nexus (mobile) • 00008020-001875E83A38002E • ios • iOS 15.4.1 19E258 • macOS (desktop) • macos • darwin-arm64 • macOS 12.3.1 21E258 darwin-arm • Chrome (web) • chrome • web-javascript • Google Chrome 101.0.4951.64 [✓] HTTP Host Availability • All required HTTP hosts are available • No issues found![✓] Flutter (Channel master, 3.1.0-0.0.pre.821, on macOS 12.3.1 21E258 darwin-arm, locale en-GB) • Flutter version 3.1.0-0.0.pre.821 at /Users/nexus/dev/sdks/flutters • Upstream repository https://github.com/flutter/flutter.git • Framework revision 03ec6b9eff (4 hours ago), 2022-05-20 00:48:08 -0400 • Engine revision 9685c81221 • Dart version 2.18.0 (build 2.18.0-130.0.dev) • DevTools version 2.13.1 [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0) • Android SDK at /Users/nexus/Library/Android/sdk • Platform android-32, build-tools 31.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 13.3.1) • Xcode at /Applications/Xcode.app/Contents/Developer • CocoaPods version 1.11.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2021.1) • 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 11.0.11+0-b60-7772763) [✓] VS Code (version 1.67.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.40.0 [✓] Connected device (4 available) • M2007J20CG (mobile) • 5dd3be00 • android-arm64 • Android 11 (API 30) • Nexus (mobile) • 00008020-001875E83A38002E • ios • iOS 15.4.1 19E258 • macOS (desktop) • macos • darwin-arm64 • macOS 12.3.1 21E258 darwin-arm • Chrome (web) • chrome • web-javascript • Google Chrome 101.0.4951.64 [✓] HTTP Host Availability • All required HTTP hosts are available • No issues found!Reacted by jongkb- addedplatform-androidAndroid applications specificallyAndroid applications specificallyengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.p: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packagesc: performanceRelates to speed or footprint issues (see "perf:" labels)Relates to speed or footprint issues (see "perf:" labels)has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onfound in release: 3.0Found to occur in 3.0Found to occur in 3.0found in release: 3.1Found to occur in 3.1Found to occur in 3.1and removedin triagePresently being triaged by the triage teamPresently being triaged by the triage team
on May 20, 2022 - addedP2Important issues not at the top of the work listImportant issues not at the top of the work list
on May 23, 2022 - addedframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.and removedengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.
on May 25, 2022 Removing engine tag and early-onset-jank project because this turned out to be a framework bug.
- addedr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
on May 25, 2022 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 -vand a minimal reproduction of the issue.- locked as resolved and limited conversation to collaborators
on Jun 8, 2022
Turning on
useMaterial3flag in Flutter 3 caused app to slow down with very severe jank after a while of use. This issue is observed in both my test devices: Xiaomi Mi A2 (Android 10) and Oppo R9s (Android 6.0.1). Probably has to do with the shader-use implementation in Material 3?Steps to Reproduce
flutter create.useMaterial3: truetoThemeData.Repeat steps by omitting useMaterial3 or setting the flag to false and compare performance results.
Expected results:
Consistent near-60 FPS throughout.
Actual results:
useMaterial3 == true:
Decreasing FPS with repeated taps on '+' button. After 200 taps, framerate dropped to 28 FPS on Xiaomi Mi A2 and 16 FPS on Oppo R9s.
useMaterial3 == false:
Results are as expected.
Code sample
Logs
useMaterial3: true (after 200 taps)
useMaterial3: false (after 200 taps)