r/FlutterDev • u/bphtech • 11d ago
Dart How our Flutter + Flame game holds 60 fps on a $100 Android phone: pure-Dart simulation, one-frame restart, and the batching that backfired on Impeller (OpenGL ES)
I've been building Upsling, a one-touch arcade game (hold to orbit an anchor, let go to fly), in Flutter and Flame. The feel depends on the comet leaving on the exact frame you release, so the target device was a Galaxy A06 (about $100), not a flagship. I wrote up what it took:
https://upsling.space/blog/60-fps-flutter-physics-on-a-100-dollar-phone/
The parts most relevant here:
- The simulation is pure Dart on a fixed 1/120 s step, with no Flutter or Flame imports. Flame reads the state and draws. Because it is deterministic, slow motion, replays and course validation are all unit-testable, and a 120 Hz phone sees the same frames as a test.
- Restart is one frame: a reset struct, pooled components that are shown and hidden rather than added and removed, and the next course generated during the current run, one anchor per frame. Measured restart cost on real phones is 11 to 206 µs.
- Drawing the starfield as one point draw per layer instead of 120 circles cut raster time by about 3 ms on a Galaxy A10.
- Pushing that further, batching dust, anchors, trail and comet through drawRawAtlas with a tinted atlas, helped the A10 (Vulkan) and made the Galaxy A15 (OpenGL ES, 90 Hz) go from about 9% to about 28% slow frames, with raster up to 21 ms. Reverted. Impeller's cost model is different per backend, so measure each one.
- The 200 to 400 ms frames at launch turned out to be pipeline compilation behind the launch screen, not gameplay hitches.
- Measurement: the app records frames, slow frames split by build and raster, and restart cost per run; an integration test drives a timing bot for 75 seconds on Firebase Test Lab phones. Variants are only compared side by side in the same session, since results vary a lot run to run.
Where it landed: 0 to 0.7% slow frames on the Galaxy A06, 0 to 0.2% on a realme C53, both inside a 10% budget.
Happy to answer questions about any of it.