text
stringlengths
1
474
assets is downloaded by the Flutter engine using the
Play store’s delivery feature.
<topic_end>
<topic_start>Improving rendering performance
info Note
To learn how to use the Performance View
(part of Flutter DevTools)
for debugging performance issues,
see Using the Performance view.Rendering animations in your app is one of the most cited
topics of interest when it comes to measuring performance.
Thanks in part to Flutter’s Skia engine and its ability
to quickly create and dispose of widgets,
Flutter applications are performant by default,
so you only need to avoid common pitfalls to achieve
excellent performance.<topic_end>
<topic_start>
General advice
If you see janky (non-smooth) animations, make
sure that you are profiling performance with an
app built in profile mode.
The default Flutter build creates an app in debug mode,
which is not indicative of release performance.
For information,
see Flutter’s build modes.A couple common pitfalls:For more information on evaluating performance
including information on common pitfalls,
see the following docs:<topic_end>
<topic_start>
Mobile-only advice
Do you see noticeable jank on your mobile app, but only on
the first run of an animation? If so, see
Reduce shader animation jank on mobile.<topic_end>
<topic_start>
Web-only advice
The following series of articles cover what the Flutter Material
team learned when improving performance of the Flutter Gallery
app on the web:
<topic_end>
<topic_start>Flutter performance profiling
info Note
To learn how to use the Performance View
(part of Flutter DevTools)
for debugging performance issues,
see Using the Performance view.<topic_end>
<topic_start>What you'll learn
It’s been said that “a fast app is great,
but a smooth app is even better.”
If your app isn’t rendering smoothly,
how do you fix it? Where do you begin?
This guide shows you where to start,
steps to take, and tools that can help.info Note<topic_end>
<topic_start>
Diagnosing performance problems
To diagnose an app with performance problems, you’ll enable
the performance overlay to look at the UI and raster threads.
Before you begin, make sure that you’re running in
profile mode, and that you’re not using an emulator.
For best results, you might choose the slowest device that
your users might use.<topic_end>
<topic_start>
Connect to a physical device
Almost all performance debugging for Flutter applications
should be conducted on a physical Android or iOS device,
with your Flutter application running in profile mode.
Using debug mode, or running apps on simulators
or emulators, is generally not indicative of the final
behavior of release mode builds.
You should consider checking performance
on the slowest device that your users might reasonably use.<topic_end>
<topic_start>Why you should run on a real device:
<topic_end>
<topic_start>
Run in profile mode
Flutter’s profile mode compiles and launches your application
almost identically to release mode, but with just enough additional
functionality to allow debugging performance problems.
For example, profile mode provides tracing information to the
profiling tools.info Note
DevTools can’t connect to a Flutter web app running
in profile mode. Use Chrome DevTools to
generate timeline events for a web app.Launch the app in profile mode as follows:In VS Code, open your launch.json file, and set the
flutterMode property to profile
(when done profiling, change it back to release or debug):From the command line, use the --profile flag:For more information on the different modes,
see Flutter’s build modes.You’ll begin by opening DevTools and viewing
the performance overlay, as discussed in the next section.<topic_end>
<topic_start>
Launch DevTools
DevTools provides features like profiling, examining the heap,
displaying code coverage, enabling the performance overlay,
and a step-by-step debugger.
DevTools’ Timeline view allows you to investigate the
UI performance of your application on a frame-by-frame basis.Once your app is running in profile mode,
launch DevTools.<topic_end>
<topic_start>
The performance overlay
The performance overlay displays statistics in two graphs
that show where time is being spent in your app. If the UI
is janky (skipping frames), these graphs help you figure out why.
The graphs display on top of your running app, but they aren’t
drawn like a normal widget—the Flutter engine itself
paints the overlay and only minimally impacts performance.