Sub topic 5
Reading the Flutter Frames Chart
What you should know
This chapter assumes that you can build a basic Flutter app, understand widget build methods, and run an app with flutter run. You also need a working Flutter SDK, a physical device or emulator, and DevTools.
The Flutter frames chart helps you answer one question: which frames took too long to display? After you find a slow frame, you can inspect its UI-thread and raster-thread work.
How Flutter produces a frame
Flutter prepares each frame in stages. The UI thread runs Dart code and the Flutter framework. It builds widgets, performs layout, runs paint commands, and creates a scene for the engine. The raster thread then turns that scene into pixels and sends them to the display.
A frame is smooth only when both parts finish before the display needs the next frame.
The frame budget and jank
The frame budget is the time available to produce one frame. At 60 Hz, the display refreshes 60 times per second, so the budget is about 16.67 milliseconds per frame. At 120 Hz, the budget is about 8.33 milliseconds.
When a frame misses its deadline, the display keeps showing the previous frame for longer. Motion appears to pause or jump. This visible stutter is called jank.
The budget is shared by the work needed for that frame. A UI-thread task that takes 20 ms can cause jank even if rasterization is fast. Raster work that takes too long can cause jank even when Dart code finishes quickly.
Launch the app for representative timings
Use profile mode when measuring performance. Debug mode adds checks and instrumentation that can make frames slower than they are in a production-like build. Release mode is fast but does not keep the same profiling connection to DevTools.
First list available devices, then start the selected device in profile mode:
flutter devices
flutter run --profile -d <device-id>Open DevTools from the running application or with the command-line workflow provided by your Flutter setup. Select Performance to view the performance timeline and Flutter frames chart.
Read the Flutter frames chart
The chart shows frame bars along a timeline. Each frame normally contains separate UI and raster timing information. Look for bars that rise above the target frame time or are marked as slow.
| Chart observation | Likely meaning |
|---|---|
| UI bar exceeds the budget | Dart or framework work delayed scene creation |
| Raster bar exceeds the budget | The engine or GPU took too long to draw the scene |
| Both bars are high | The frame has pressure on both sides, or one problem triggered more work |
| A single high bar | An isolated event, such as parsing, garbage collection, or shader work |
Click a slow frame to inspect its details. Start by comparing the UI and raster durations. Do not assume that the widget being displayed caused the problem. A frame can be slow because of work scheduled by a timer, animation callback, data conversion, or image operation.
Distinguish UI-thread and raster-thread jank
UI-thread jank often comes from expensive synchronous Dart work. Common examples include large loops, JSON parsing, sorting, rebuilding too much of a widget tree, and repeated layout work.
Raster-thread jank often comes from expensive drawing. Large images, complex clips, opacity layers, shadows, large save-layer operations, and shader compilation can contribute.
The chart tells you which side exceeded the budget. It does not always identify the exact source. Use the selected frame's timeline events and Frame Analysis details to locate the operation.
Exercise
A frame has a UI duration of 22 ms and a raster duration of 5 ms on a 60 Hz device. Which thread is the first place to investigate, and why?
Show answer
Investigate the UI thread. Its 22 ms of work exceeds the approximately 16.67 ms frame budget, so it can delay the scene before rasterization begins.