Google I/O 2022 —When, why, and how to multithread in Flutter

How does jank happen and how to fix it?

Evan Fang
5 min readDec 4, 2022

While your app grows bigger, you might not be surprised that it starts to run slower. The situation happens with some new features, related to heavy tasks such as decoding images with high resolution, computing complicated math, or reading large files. All of these result in one annoying thing — Jank.

This session in Google I/O 2022 reveals the mechanism of how Flutter keeps the app smooth with 60 fps, why it slows down, and how we can fix it.

Table Of Content

  1. Isolate and event loop
  2. Core libraries/system APIs
  3. Spawn an Isolate
    - Compute Isolate — short-lived background tasks
    - Worker Isolate — Long-lived background tasks
  4. Recap
  5. References

Isolate and event loop

All the dart code runs in an isolate with an event loop. Each isolate has a single thread running an event loop, with a chunk of private memory. It is kinda like process in Android. The event loop contains two queues: microtask queue and event queue. We won’t go into the…

--

--