text
stringlengths 1
474
|
|---|
and needless processing.When you encounter calls to saveLayer,
|
ask yourself these questions:<topic_end>
|
<topic_start>Checking for non-cached images
|
Caching an image with RepaintBoundary is good,
|
when it makes sense.One of the most expensive operations,
|
from a resource perspective,
|
is rendering a texture using an image file.
|
First, the compressed image
|
is fetched from persistent storage.
|
The image is decompressed into host memory (GPU memory),
|
and transferred to device memory (RAM).In other words, image I/O can be expensive.
|
The cache provides snapshots of complex hierarchies so
|
they are easier to render in subsequent frames.
|
Because raster cache entries are expensive to
|
construct and take up loads of GPU memory,
|
cache images only where absolutely necessary.You can see which images are being cached by enabling the
|
PerformanceOverlayLayer.checkerboardRasterCacheImages switch.Run the app and look for images rendered with a randomly colored
|
checkerboard, indicating that the image is cached.
|
As you interact with the scene, the checkerboarded images
|
should remain constant—you don’t want to see flickering,
|
which would indicate that the cached image is being re-cached.In most cases, you want to see checkerboards on static images,
|
but not on non-static images. If a static image isn’t cached,
|
you can cache it by placing it into a RepaintBoundary
|
widget. Though the engine might still ignore a repaint
|
boundary if it thinks the image isn’t complex enough.<topic_end>
|
<topic_start>
|
Viewing the widget rebuild profiler
|
The Flutter framework is designed to make it hard to create
|
applications that are not 60fps and smooth. Often, if you have jank,
|
it’s because there is a simple bug causing more of the UI to be
|
rebuilt each frame than required. The Widget rebuild profiler
|
helps you debug and fix performance problems due to these sorts
|
of bugs.You can view the widget rebuilt counts for the current screen and
|
frame in the Flutter plugin for Android Studio and IntelliJ.
|
For details on how to do this, see Show performance data<topic_end>
|
<topic_start>
|
Benchmarking
|
You can measure and track your app’s performance by writing
|
benchmark tests. The Flutter Driver library provides support
|
for benchmarking. Using this integration test framework,
|
you can generate metrics to track the following:Tracking these benchmarks allows you to be informed when a
|
regression is introduced that adversely affects performance.For more information, check out Integration testing.<topic_end>
|
<topic_start>
|
Other resources
|
The following resources provide more information on using
|
Flutter’s tools and debugging in Flutter:
|
<topic_end>
|
<topic_start>Debugging performance for web apps
|
info Note
|
Profiling Flutter web apps requires Flutter version 3.14 or later.The Flutter framework emits timeline events as it works to build frames,
|
draw scenes, and track other activity such as garbage collections.
|
These events are exposed in the
|
Chrome DevTools performance panel for debugging.You can also emit your own timeline events using the dart:developer
|
Timeline and TimelineTask APIs for further performance analysis.<topic_end>
|
<topic_start>
|
Optional flags to enhance tracing
|
To configure which timeline events are tracked, set any of the following top-level properties to true
|
in your app’s main method.<topic_end>
|
<topic_start>
|
Instructions
|
<topic_end>
|
<topic_start>Shader compilation jank
|
info Note
|
To learn how to use the Performance View
|
(part of Flutter DevTools)
|
for debugging performance issues,
|
see Using the Performance view.If the animations on your mobile app appear to be janky,
|
but only on the first run,
|
this is likely due to shader compilation.
|
Flutter’s long term solution to
|
shader compilation jank is Impeller,
|
which is in the stable release for iOS
|
and in preview behind a flag on Android.While we work on making Impeller fully production ready,
|
you can mitigate shader compilation jank by bundling
|
precompiled shaders with an iOS app.
|
Unfortunately, this approach doesn’t work well on Android
|
due to precompiled shaders being device or GPU-specific.
|
The Android hardware ecosystem is large enough that the
|
GPU-specific precompiled shaders bundled with an application
|
will work on only a small subset of devices,
|
and will likely make jank worse on the other devices,
|
or even create rendering errors.Also, note that we aren’t planning to make
|
improvements to the developer experience for creating
|
precompiled shaders described below. Instead,
|
we are focusing our energies on the more robust
|
solution to this problem that Impeller offers.<topic_end>
|
<topic_start>
|
What is shader compilation jank?
|
A shader is a piece of code that runs on a
|
GPU (graphics processing unit).
|
When the Skia graphics backend that Flutter uses for rendering
|
sees a new sequence of draw commands for the first time,
|
it sometimes generates and compiles a
|
custom GPU shader for that sequence of commands.
|
This allows that sequence and potentially similar sequences
|
to render as fast as possible.Unfortunately, Skia’s shader generation and compilation
|
happens in sequence with the frame workload.
|
The compilation could cost up to a few hundred milliseconds
|
whereas a smooth frame needs to be drawn within 16 milliseconds
|
for a 60 fps (frame-per-second) display.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.