Flutter applications adapted for HarmonyOS can be debugged using DevTools for Dart code.
HarmonyOS NEXT, Huawei's proprietary operating system, is designed for enhanced performance and seamless cross-device integration, particularly within the Chinese market and Huawei's expanding global footprint. Key to its performance is the elimination of the Android AOSP core, allowing for native HarmonyOS applications to run directly on the HarmonyOS kernel. This shift enables optimizations and performance gains compared to previous HarmonyOS versions which relied on the Android compatibility layer. Performance Analysis and Boundary Definition in HarmonyOS NEXT: Native App Performance: HarmonyOS NEXT is built to excel with native HarmonyOS applications. The absence of the Android compatibility layer eliminates overhead and allows for direct interaction with the HarmonyOS kernel, leading to improved performance, especially in areas like startup time, resource management, and overall responsiveness. Flutter Performance: Flutter applications adapted for HarmonyOS can be debugged using DevTools for Dart code. The performance analysis tools like DevEco Studio Profiler and SmartPerf are available for Flutter developers. Flutter utilizes multiple threads (UI, Raster, I/O, etc.). The performance of the UI thread (where Dart code executes) is critical, as blocking it can impact the entire application. Raster thread (GPU thread) is also important, and its slowness can indicate issues with the UI thread. Performance Analysis Tools: DevEco Profiler: This tool allows developers to record and analyze traces of application behavior. It helps in identifying performance bottlenecks by capturing frame rendering, thread activity, and other relevant metrics. Performance Analysis Kit: This kit provides tools like HiLog (for logging), HiTraceMeter and HiTraceChain (for tracing), and HiAppEvent (for event logging). These tools are crucial for identifying and resolving performance issues, as well as for fault analysis and online monitoring. AppAnalyzer: This tool helps in assessing the quality of HarmonyOS apps, including performance, and provides feedback for optimization. Key Performance Indicators: Frame Rate: A high frame rate (e.g., 60fps or 120fps) is crucial for smooth user experience. Performance analysis tools can help identify if the UI thread is exceeding the time limit for rendering a single frame (e.g., 16.67ms for 60fps or 8.33ms for 120fps). CPU Usage: Monitoring CPU usage helps in identifying if any specific part of the application is consuming excessive resources, which can lead to performance degradation. Memory Usage: Efficient memory management is crucial for overall system performance. Tools like DevEco Profiler can help track memory allocation and deallocation, identifying potential memory leaks or excessive memory consumption. Cross-Platform Compatibility: HarmonyOS NEXT, while focusing on native apps, also needs to ensure a good experience for applications developed with cross-platform frameworks like Flutter. Performance analysis tools and techniques are available to address performance challenges in these scenarios. Boundary Definition: HarmonyOS Native vs. Android Compatibility: HarmonyOS NEXT is designed to be a native platform, meaning it doesn't rely on the Android compatibility layer (AOSP) for running applications. This is a significant boundary, as it means Android apps will not run directly on HarmonyOS NEXT. Developers need to port or rewrite their Android apps to be compatible with HarmonyOS NEXT. App Quality: Huawei provides tools and guidelines for assessing the quality of HarmonyOS apps, including performance, usability, and security. These guidelines define the boundaries for acceptable app performance and behavior. Cross-Device Capabilities: HarmonyOS NEXT emphasizes seamless cross-device integration. The boundary here is defined by the ability of applications to adapt to different screen sizes and input methods while maintaining a consistent user experience. Performance Benchmarks: Huawei has defined specific performance benchmarks and scoring rules for HarmonyOS apps. These benchmarks act as boundaries, indicating the level of performance that is expected for an application to be considered high-quality.
Flutter applications adapted for HarmonyOS can be debugged using DevTools for Dart code.
Prerequisites
- OpenHarmony Next system
- Flutter interface running in foreground
- Analysis tools: DevEco Studio Profiler SmartPerf
Flutter Thread Architecture
Flutter utilizes multiple threads for essential operations. All Dart code executes on the UI thread, which impacts other threads:
- Platform Thread Main platform thread where plugin code runs
-
UI Thread
Executes Dart code in Dart VM. Handles:
- Developer-written code
- Framework-generated code
- Creates lightweight layer trees (device-agnostic rendering commands)
- Sends layer trees to GPU thread Critical: Never block this thread! Appears in performance overlay's bottom bar.
-
Raster Thread (GPU Thread)
Processes layer trees and sends to GPU. While you can't directly interact:
- Slowness indicates Dart code issues
- Hosts Skia graphics library
- Appears in performance overlay's top bar
- I/O Thread Handles heavy I/O operations to prevent blocking UI/raster threads. Not shown in performance overlay.
-
RenderService Thread
RS process main thread. After Flutter renders frames:
- Texture mode: Composites with main thread (affected by main thread)
- Surface mode: Direct display (unaffected by main thread)
Problem Boundary Definition
In DevEco Studio:
- Open Profiler tab
- Capture application trace
- Focus on
<x>.ui
,<x>.raster
, and RenderService main threads
The missing frames in the RenderService in the above image are due to the UI thread taking a longer time per frame, exceeding one frame (at a frame rate of 120, one frame is 8.33 milliseconds).
If the total duration of. ui and. master in a frame rendering process exceeds one frame time, the performance issue can be defined as Flutter problem. The positioning of the problem requires further performance analysis.
Top comments (0)