Member-only story
Boosting Flutter Image Processing Performance with Rust ~40x speed up
I recently faced a task in Flutter: combine multiple high-resolution images (taken by mobile phones) vertically. While this sounds simple, the performance was a big issue.
The Challenge
I used a Pixel 8 Pro to combine three 3024×4032 images.
1. Dart (main thread):
- ❌ UI froze for 17 seconds.
- App Size: 27.9MB (Apk)
2. Dart (Isolate):
- ✅ UI stayed smooth.
- But it took 42 seconds — still way too slow!
- App Size: 27.9MB (Apk)
At this point, I knew I had to find another way, d art is not ideal for high-performance tasks. Its single-threaded design means that even using isolates won’t achieve the efficiency of true multithreading, especially for demanding tasks like image processing.
Solution: Rust 🦀
I decided to try Rust to handle the image processing logic.
Boom! Processing time dropped to just 1 second.
Here’s the breakdown:
- Dart (main thread): 17,667 ms (17 seconds), App Size: 27.9MB (Apk)
- Dart (Isolate): 42,840 ms (42 seconds), App…