Which shader warm‑up strategy yields the lowest first‑frame latency in Flutter?
29K reputation · 12 Mar 2023, 14:13 UTC
Goal
Determine the most effective shader warm‑up approach to reduce the first‑frame latency caused by on‑demand shader compilation in Flutter.
Constraints & Uncertainty
Flutter’s Skia backend compiles shaders the first time they are used, producing noticeable spikes in frame time. The experimental Impeller backend pre‑compiles a larger shader set at launch, trading startup time for smoother runtime. The shader warm‑up API (FlutterEngine.runWithEntrypoint) exists, but the documentation does not prescribe which shaders to preload. Additionally, Flutter has not defined a policy for persisting shader caches across app updates, leaving developers to decide whether to bundle a cache or rely on on‑device compilation. Device GPU and driver variations further complicate measurement generalizability.
Unresolved Questions
- What specific set of shaders should be warmed up via the runWithEntrypoint API to minimize jank across the broadest range of Android and iOS devices?
- Does the Impeller backend automatically persist its pre‑compiled shader cache between app updates, or must developers manage cache persistence manually?
- Is there an optimal strategy that combines Impeller pre‑compilation, manual warm‑up, and cache persistence to achieve the lowest first‑frame latency without excessive launch overhead?