Flutter Performance Tips: Quick Identification and Raster Cache Optimization
By using a quick identification tip and a unified smoothness metric, developers can see that Flutter often out‑performs native pages on high‑refresh iOS devices and, on Android, can be measured across devices, while optimizing rasterCache hit rates—through flags like will_change, is_complex, complexity_score, visibility rules, and limiting cached items to three per frame—significantly improves rendering performance.
A quick tip for identifying Flutter pages reveals that, on iOS high‑refresh devices, Flutter can achieve higher FPS than native pages.
On Android, establishing a unified smoothness metric helps compare Flutter performance across devices.
The rasterCache hit rate is influenced by factors such as raster thread rasterization time; optimizing this improves frame rendering.
will_change: indicates the layer will change later, so it is not cached.
is_complex: marks the layer as complex, thus it is cached.
complexity_score: calculated from DisplayList instructions; if the score reaches a threshold, the layer is worth caching.
visible and continuously satisfies condition 3 for three consecutive frames.
PrerollContext does not contain a TextureLayer (its content changes unpredictably, so no caching).
PrerollContext does not contain a PlatformViewLayer (its content changes unpredictably, so no caching).
The cache condition is satisfied for three consecutive frames.
For ClipShapeLayer, an extra requirement is clip_behavior_ == Clip::antiAliasWithSaveLayer (a high‑cost operation); the default Clip::hardEdge is not cached.
To avoid excessive impact on the current frame, at most three items can be cached per frame. Using DisplayListRasterCacheItem as an example, the overall flow follows the conditions above.
Xianyu Technology
Official account of the Xianyu technology team
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.