Often good reading, old age to learn spandex.

What is a 60 FPS?

60fps: The screen refreshes 60 times per second, which is 1/60 ~=16.67ms per frame

Refresh rate vs. frame rate?

Refresh rate: the number of screen refreshes per second. Most mobile screens now refresh at 60HZ frame rate: the number of frames drawn by the GPU in one second.

Why 60fps?

Currently, The Frame rate of Android is 60fps (16.67ms per drawing), and the screen refresh rate of mobile phone is 60HZ (16.67ms per refresh), so the current Android phone is basically this configuration, the optimal solution at the current stage.

Why do I get stuck and lose frames?

Android system sends VSYNC signal every 16ms to trigger GPU to render UI. If your time is 20ms, the system cannot update any content because it is not ready when it gets VSYNC signal. Then the user sees the same frame in 32ms, and the frame will be lost, resulting in lag.

Field experience

(1) Practical operation environment

  • Optional, use your own environment and code as well
  • SamplePop code download
  • The SamplePop environment is as follows:

Android Studio 4.0 Gradle Version 6.1.1 Android API Version 30

(2) Sample code

public void onFramesLossMonitor(View view) { Log.d(TAG, "onFramesLossMonitor: "); startAnimator(); } private void startAnimator() { Log.d(TAG, "startAnimator: "); ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, 1f); valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { mMonitorBgView.setAlpha((float) animation.getAnimatedValue()); monitorDoSomeThings(); }}); valueAnimator.setDuration(500); valueAnimator.start(); } private void monitorDoSomeThings() { Log.d(TAG, "monitorDoSomeThings: "); try { Thread.sleep(50); } catch (InterruptedException e) { Log.d(TAG, "writeSomething: "); }}Copy the code

Export the HTML file report as described in the previous section, locate the process corresponding to the package name, and check the Frames to indicate that there is a delay (lost Frames). Green: < 1* vsync Yellow: 1* vsync to 2 * vsync Red: > 2 * vsync

(3) Results report

Open the running Systrace result report:

Keyboard shortcuts: W: Zoom in on the Tracking timeline A: Pan to the left on the tracking timeline S: Zoom out on the tracking timeline D: Pan to the right on the tracking timeline E: Locate the tracking timeline with the current mouse position M: Highlight the current selection

The pipe color description is as follows: Gray: The pipe is hibernating. Blue: Runnable (it can run, but the scheduler has not yet chosen to run it). Green: Running (the scheduler thinks it is running). Red: Uninterruptible sleep (usually in a sleep lock state in the kernel). You can indicate I/O load, which is useful when debugging performance problems. Orange: The sleep cannot be interrupted due to I/O load.

(4) Single frame information

Clicking on a single frame will prompt caton’s details and suggestions.

Xiaobian extension links

  • SamplePop code download
  • Android Performance Optimization family Bucket

Refer to the link

  • Browse Systrace report on Google
  • Google official website -> Slow rendering cases
  • Learn about Systrace
  • Good blog post -> Just read this one

Lotus palace – like beauty makeup, lotus leaf green for clothes

❤ ❤ than heart