Android frame rate analysis

Stuck and stopped:

Rendering is the act of generating frames from an application and displaying them on the screen. To ensure a smooth user interaction with your app, your app should render each frame no longer than 16ms to achieve 60 frames per second (why 60fps?). If your app has a slow UI, the system will have to skip frames, which can make your app feel choppy to the user. We call this a lag

Systrace:

Systrace is a new performance data sampling and analysis tool in Android4.1. It can help developers collect operating information of key Android subsystems (such as SurfaceFlinger/SystemServer/Kernel/Input/Display and other Framework key modules, services, View systems, etc.), thereby helping developers analyze system bottlenecks more intuitively and improve performance .

AndroidStudio CPU Profiler

Systrace's functions include tracking the system's I/O operations, kernel work queues, CPU load, and the health of Android's various subsystems.

Next, capture the game's stuck frame and compile a debug version of the channel package. The running device is android 12 oppo k7 to capture the system trace:

Turn on the debug mode, connect to the device, first select system trace recording in the cup profiler to start capturing the system trace,
insert image description here
wait for a while, and click the stop button to stop capturing.

Note that the freeze frame rate of each version is displayed differently on the studio, read the interface freeze detection for details

Open Systrace as follows:
insert image description here
Below the Display you see the Janky frames track. By default, the Profiler will only show jank frames as candidates for investigation. Within each jank frame, the red highlights how long the frame was past its render deadline. Events longer than 16 milliseconds are indicated in red.

Select the red square in Janky frames, press the M key + double-click the mouse, as shown below:

insert image description here
The red frame, the blank space is the execution of related threads, such as app main thread and renderThread and GPU completion.

Summary : How to use CPU Profiler in these scenarios? The basic idea is: first grasp System Trace, first use System Trace to analyze and locate the problem, if the problem cannot be located, then use Java Method Trace or C/C++ Function Trace to further analyze and locate the problem

perfetto more robust logging

Similar to systemtrace, used in more complex time-consuming analysis.

Use the documentation: https://perfetto.dev/docs/quickstart/android-tracing#perfetto-cmdline

Information reference :

  • Browse the Systrace report: https://developer.android.com/topic/performance/tracing/navigate-report?hl=zh-cn#analysis
  • Interface jam profiler cpu analysis: https://developer.android.com/studio/profile/jank-detection?hl=zh-cn
  • Rendering is slow: https://developer.android.com/topic/performance/vitals/render?hl=zh-cn
  • Practical article on the analysis of Android freeze frame drop problem: https://www.jianshu.com/p/f1a777551b70
  • Android fluency evaluation and freeze optimization: https://ontheway.cool/skills/android/android-fluency-quality-manage.html#_3-%E4%B8%BB%E8%A6%81%E5%8D% A1%E9%A1%BF%E5%8E%9F%E5%9B%A0

Guess you like

Origin blog.csdn.net/hexingen/article/details/131938852