r/FlutterDev • u/zennnmind • 13m ago
Plugin I build FastLottie. Faster than native — the Lottie renderer Flutter deserves
Hey everyone,
If you've ever tried rendering a chat screen or sticker picker full of Lottie animations in Flutter, you've probably hit the same wall I did: dropped frames, GC spikes, and memory usage shooting up as soon as more than a few stickers are on screen at once.
I got tired of working around it, so I built a 2D Lottie & Telegram `.tgs` engine from scratch called FastLottie (v1.0). The goal was to make dense sticker grids feel effortless—and on heavy stress tests, it ended up beating native Kotlin, C++ `dotlottie`, and `lottie-ios`.
Benchmarks
| Metric | FastLottie v1.0 | Baseline |
| :--- | :--- | :--- |
| RAM — 24× stickers @ 120 Hz (Apple M5) | 209 MiB | `lottie-ios`: 3.27 GiB (~15× less) |
| Total PSS | 249.5 MiB | Pure Native Kotlin: 373.7 MiB |
| Parse speed vs. Native Kotlin | 2× – 17.5× faster | — |
| Parse speed vs. Swift | 4.2× – 10.3× faster | — |
How it works under the hood
* Zero-DOM UTF-8 parsing (off the UI isolate): Instead of decoding JSON into large Dart `Map`/`List` trees that trigger GC storms, FastLottie scans raw UTF-8 bytes directly into columnar `TypedData` tracks designed for `Float32x4` SIMD evaluation.
* Bounded VRAM via LZ4 strip cache: Native C/SIMD kernels rasterize into adaptive LZ4 strips (~17.7 µs decode) with a 32 MiB default GPU budget and optional `.flcache` disk caching.
* Zero PlatformView tax: No `AndroidView`, no `UIKitView`. Direct Flutter texture composition skips the +164 MiB PlatformView overhead altogether.
* Web support via Wasm: Uses dedicated Web Workers paired with C Wasm SIMD kernels so heavy animations don't block the main thread.
Drop-in API
Supports both `.json` and Telegram `.tgs` files out of the box:
```dart
FastLottie.asset('assets/sticker.tgs')
```
You can switch between Shared Raster**,** Vector**, or** Direct Canvas modes depending on the widget, and use `FastLottiePlaybackScope` to manage off-screen playback in scrollable feeds.
---
Would love feedback from anyone building chat UIs, sticker pickers, or animation-heavy feeds. Happy to dive into the C/SIMD internals, texture pipeline, or benchmark setup in the comments!