跪拜 Guibai
← All articles
Flutter · Kotlin · Architecture

That 150ms Flutter Sensor Latency Is a Channel Misuse, Not a Framework Limit

By GitLqr ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

A single misdiagnosed latency figure can cascade into costly framework migrations and spook teams evaluating Flutter for hardware-adjacent apps. The fix is a standard, documented pattern, not a rewrite.

Summary

A recent migration story pinned Flutter's sensor latency at 150ms and declared a physical limit, but the number points to a textbook implementation mistake. MethodChannel carries per-call serialization, JNI, and engine-thread overhead that compounds into triple-digit milliseconds when used as a pipe for high-frequency sensor streams. The correct tool, EventChannel, maintains a single open stream with far lower overhead and is designed exactly for native-to-Dart data push.

Production experience with the same bridging pattern shows P95 latency under 10ms once the channel type and threading model are fixed. The sensor read must happen on a native background thread, not the main thread, and raw sensor rates should be throttled to match UI needs before hitting the bridge.

Before abandoning Flutter for KMP over a latency number, teams should audit three things: whether they are using EventChannel instead of MethodChannel, whether native reads run off the main thread, and whether native-side throttling is in place. A migration decision built on a misdiagnosed bottleneck risks misleading the wider engineering community.

Takeaways
MethodChannel is a transactional request-response mechanism; using it for continuous sensor streams causes serialization and thread-switching overhead that accumulates to 150ms or more.
EventChannel maintains a persistent stream and is the correct Flutter primitive for native-to-Dart data push, cutting per-message overhead dramatically.
Running sensor reads on the native main thread adds latency regardless of channel choice; a background thread is required for low-latency streaming.
Raw sensor sampling rates often exceed UI requirements, so native-side throttling before the bridge is essential for stable performance.
Production P95 latency under 10ms is achievable with EventChannel, background-thread reads, and throttling, matching the 5ms native figure that triggered the original migration.
Conclusions

The 150ms figure is not a Flutter performance ceiling but a diagnostic signal: it tells you MethodChannel is being used where EventChannel belongs.

Tutorials and sample code that default to MethodChannel for all native communication create a systemic pitfall that can mislead entire engineering teams into blaming the framework.

A migration decision based on a single misread metric can propagate through the community as received wisdom, discouraging adoption of a tool that would work fine with a small, documented correction.

Concepts & terms
MethodChannel
A Flutter Platform Channel designed for single request-response calls between Dart and native code. Each invocation pays serialization, engine-bridge, and (on Android) JNI overhead, making it unsuitable for high-frequency streaming.
EventChannel
A Flutter Platform Channel built for continuous, one-way data streams from native code to Dart. It maintains a single open stream, avoiding the per-message overhead of MethodChannel.
P95 latency
The 95th percentile latency value, meaning 95% of requests or events complete within this time. It captures tail behavior better than averages for real-time systems.
From the discussion

The discussion pushes back against the 150ms claim, asserting that MethodChannel latency alone is on the order of milliseconds, not triple digits. A link to a JNI benchmark is offered as supporting evidence. The original article's team is faulted for mishandling binary sensor data and drawing an incorrect conclusion about Flutter's capability. One open question remains about whether large-string parsing would still incur significant overhead.

MethodChannel round-trip latency is inherently a few milliseconds, making a 150ms figure suspect unless data volume is extreme.
A JNI benchmark repository is cited as a reference for cross-boundary performance.
The original article's conclusion that Flutter cannot handle sensor data is attributed to poor binary-data handling, not a platform limitation.
Whether large-string parsing across the channel introduces its own bottleneck is left as an unresolved concern.
Featured comments
卡米

That article claiming 150ms—I feel there's definitely something wrong with it. Unless the data volume is huge, the pure native-to-Flutter latency using MethodChannel—there's no official figure, but it can definitely be done in a few milliseconds.

卡米

You can refer to this https://github.com/descosmos/jnigen_benchmark/tree/master

GitLqr

Yes, the tech team behind that article didn't handle Flutter's processing of sensor binary data properly, and then jumped to the wrong conclusion that Flutter couldn't do it.

懒洋君

So if it's parsing a large string, is it still very slow?

See top comments, translated →
Source: juejin.cn ↗ Google Translate ↗ Backup ↗