Integrating face recognition into Flutter apps isn't always straightforward. Here are a few real-world challenges we've encountered — and how we solve them.
Immutable Objects and Image Conversion PerformanceObject immutability is a core concept for Flutter’s core language,
Dart, meaning developers typically can't modify objects without creating a copy.
While this has benefits for stability and predictability, it can seriously impact performance when working with images—especially during conversions from camera formats to RGB.
To address this, we often rely on native (
C++) image conversion implemented directly within our Face SDK when working in Flutter.
This approach significantly optimizes image processing operations. In particular, using the
C++ version of image conversion has helped us boost FPS several times over.
Using Dart Isolates for Heavy ProcessingHeavy processing — including Face SDK inference — can often interfere with app performance, especially the UI.
This can lead to lags, stutters, or even app freezes in more extreme cases. To avoid these issues, we recommend using Dart Isolates to offload demanding tasks to separate threads.
To make this easier for developers, we’ve already integrated Isolate support directly into our Flutter plugin.
Here’s a less obvious but equally important scenario:In some apps, you may need to save cropped face images — for example, to display them as thumbnails in a database of registered users. However, converting an RGB image to JPEG can take up to
200–250 ms.
If you attempt this without using Isolates, the camera preview may freeze or stop working entirely. With Isolates, the app stays responsive.
Handling YUV_420_888 to RGB Conversion on AndroidWhen working with
android.hardware.camera2 — the standard package for camera interaction on Android — the image format
YUV_420_888 is commonly used. However, for neural network processing, we often need to convert these images to RGB.
As mentioned earlier, we handle this conversion in native code using our custom implementation. This generally works well — but on some devices (such as the
Honor X8b), the image data doesn’t fully comply with the expected format.
As a result, the converted RGB image becomes corrupted, and the processing pipeline fails.
That’s why we continuously maintain and update our Flutter Face SDK to ensure compatibility across a wide range of smartphones.
The best part?All of these edge cases and performance hurdles are already solved in
3DiVi Face SDK for Flutter—built to accelerate face recognition integration and keep your app running smoothly on real-world devices.