HarmonyOS Flutter Performance Optimization: Slide Response Latency
This article analyzes trace diagnostics for slide response latency in Flutter applications under touch interaction scenarios.
Finger Press (Initial Touch)
The finger press event establishes the foundation for all subsequent interactions, capturing:
- Initial touch coordinates
- Targeted UI controls
- Interaction context
Event Flow:
- mmi_service thread handles multimodal input events
- Flutter application listens and responds to touch events
Trace Characteristics:
- In
mmi_service
thread:"service report touchId:[id], type: down"
immediately after"package touchEvent"
- In application main thread:
"DispatchTouchEvent"
with coordinates andtype: 0
(down event)
These traces correspond directly across threads:
Finger Slide (Movement)
Slide events follow a controlled delivery mechanism different from initial presses.
Key Differences:
-
Not immediate: Governed by
vsync-app
signal - Initial position: Matches press coordinates (first move event)
-
Type identifier:
type: move
(numerical value: 2)
Event Sequence:
-
mmi_service
thread detects movement -
VSyncGenerator
produces synchronization signal -
DVSync-app
processes the signal - Application main thread receives event
Trace Flow:
Slide Threshold (TouchSlop)
The system-defined minimum recognition distance for slide gestures:
- Default value: 18 units
- Customizable: Developers can adjust per control
Calculation Method:
- Capture touch coordinates from main thread traces
- Compute coordinate offsets between events
- Verify if offset exceeds threshold:
const distance = Math.sqrt(
Math.abs(x2 - x1)**2 +
Math.abs(y2 - y1)**2
);
const isSlide = distance > TOUCH_SLOP;
First Frame Rendering
When slide distance exceeds threshold:
- Flutter triggers UI update operations
- Actual rendering waits for next VSync signal
- One-frame delay occurs before visual update
Trace Pattern:
First Frame Completion
Rendering completion identification:
-
Development tracing:
RSHardwareThread
in RS process -
Automated testing:
dpu_gfx_primary
thread (hardware signal proxy)
Completion Trace:
Measuring Slide Response Latency
Total response duration spans:
```
Start: mmi_service "package touchEvent" (finger press)
End: RSHardwareThread/dpu_gfx_primary (first slide frame rendered)
```
Optimization Focus Areas:
- Touch event propagation time
- VSync signal generation latency
- Frame scheduling efficiency
- Render service processing time
- Hardware composition duration
This analysis methodology enables precise identification of performance bottlenecks in Flutter slide interactions on HarmonyOS, providing actionable insights for latency reduction.
Top comments (0)