preface
This is the first article in a new column called “SimowCE Bulletin board.” In this series, I’m going to share some interesting and useful information. It won’t be too long, but it will be full of good stuff. Therefore, if you feel that the content is useful, I hope you can put the public number ** “set as the star standard” **, so that as long as the public number update you can receive the first time notice.
Today I will share a detailed explanation of the tag in Systrace. There are many contents in Systrace. What contents does it show? What exactly does all this mean? What does it do? Don’t worry. Just listen to me.
HW_VSYNC_ON_XXX
Value types
Boolean value: 1 indicates that the HW VSYNC signal switch is turned on, 0 indicates that the switch is turned off.
A time to
HW VYSNC hardware signals are turned on and off.
explain
First of all, the XXX after HW_VSYNC_ON_XXX is usually a string of numbers, representing the displayID. If you have an external monitor on your machine, you can use the displayID to distinguish between the HW VSYNC hardware signals of different screens. The XXX in HW_VSYNC_XXX below has the same meaning.
HW VSYNC hardware signal is always turned on and off because the Android Display/Graphic Framework relies on not hardware signal but software signal — DispSync. HW VSYNC is only used for calibration. When the error of VSYNC exceeds a certain threshold, DispSync will actively turn on HW VSYNC signal for calibration. (Currently) After receiving 6 hardware signals, HW VSYNC signal will be closed. I don’t need to elaborate on DispSync in detail in this article.
role
Most upper level developers don’t need to worry about this tag because they work on bug-free hardware. However, this premise is not valid for the developers of the phone manufacturer, so this tag is very useful as a time anchor to analyze various bugs caused by the hardware side in the early stage of the project.
HW_VSYNC_XXX
Value types
The instantaneous Boolean value, which changes from 1 to 0 or 0 to 1, indicates that HW_VSYNC is emitted at the current time.
A time to
HW VSYNC when the hardware signal is emitted.
explain
It is important to note that HW_VSYNC_XXX appears to be an interval from Systrace, as shown in the figure above.
But actually, HW_VSYNC_XXX in Systrace should read like this:
The value of HW_VSYNC_XXX is a transient value, which records that the HW VSYNC hardware signal was received at the current time. Therefore, in Systrace, when the value of HW_VSYNC_XXX changes from 1 to 0 or from 0 to 1, Both represent receiving HW VSYNC signals, similar to pulse signals in an oscilloscope. To see how this is represented in code:
bool HWComposer::onVsync(hwc2_display_t hwcDisplayId, int64_t timestamp) {
. const auto tag = "HW_VSYNC_" + to_string(*displayId);
ATRACE_INT(tag.c_str(), displayData.vsyncTraceToggle);
displayData.vsyncTraceToggle = ! displayData.vsyncTraceToggle; return true; } Copy the code
When I received the HW of hardware VSYNC signal after HWComposer: : onVsync () this function will be called back, and then the displayData. VsyncTraceToggle values will be the not all the time, Simulate the appearance of a pulse signal and assign to HW_VSYNC_XXX.
HW_VSYNC_ON_XXX and HW VSYNC (HW VSYNC) are not sent to HW VSYNC (HW VSYNC). It’s the same picture, but we’ve added some labels:
Is that clear and intuitive?
That’s why this type of value is called a transient Boolean value, meaning it only makes sense when the value changes.
role
Like HW_VSYNC_XXX, most people do not use it. You can’t imagine HW VSYNC hardware signals not sending or sending random signals.
hasClientComposition
Value types
Boolean value, 1 means that there is GPU synthesis in this synthesis (note that there is GPU synthesis, not only GPU synthesis), 0 means that there is no GPU synthesis in this synthesis.
A time to
At the beginning of the SurfaceFlinger: : doComposition ().
explain
The SurfaceFlinger comes in two types, depending on the hardware you compose:
-
CLIENT synthesis, also known as GPU synthesis, calls a series of OpenGL ES interfaces through CompositionEngine to complete the synthesis operation.
-
DEVICE composition is also known as HWC composition, which uses Hardware Composer to compose. Hardware Composer is a special piece of Hardware, formerly known as SDE on the Qualcomm platform, now known as DPU. Using Hardware Composer has its advantages, such as power saving, which is probably its biggest advantage. However, there are disadvantages, such as:
-
DEVICE synthesis is not possible in some scenarios such as Layer rounded, total number of layers exceeds hardware limit, etc.
-
The composition logic and policy are basically vendor’s closed source implementation. Since the policy is closed source, if there is a problem, it can only rely on Vendor to solve it, which is not convenient for debugging.
role
We have said that the advantage of DEVICE synthesis compared with GPU synthesis is power saving. If it is found that the scene that should be DEVICE synthesis has hasClientComposition equal to 1, then there is a problem with the synthesis strategy and some power consumption problems may be solved.
FrameMissed/GpuFrameMissed/HwcFrameMissed
Value types
Boolean, 1 means the last composition had the corresponding FrameMissed type and 0 means it did not.
A time to
SurfaceFlinger syntheses the beginning of the Invalidate phase.
explain
FrameMissed GpuFrameMissed/HwcFrameMissed represent SurfaceFlinger last the result of the synthesis, we referred to in the calculation principle of FPS, when SurfaceFlinger synthetic frame display on the screen, Present fence will signal. Therefore, present Fence Signal can be considered as a complete synthesis.
Therefore, every time the SurfaceFlinger is first woken up by vsync-sf, it checks the last composition by checking if the last composition of the present fence has a signal. If not, it is considered a FrameMissed, and the GpuFrameMissed and HwcFrameMissed are set based on whether the GPU or HWC was involved in the last composition.
role
Present Fence didn’t signal in time for two main reasons:
- Something wrong with the Display.
- The App/ game GPU load is so high that the bottom layer spends most of its time waiting for the GPU rendering to finish, delaying the present fence signal, resulting in FrameMissed.
FrameMissed currently has two functions on Android:
- Statistics.
- Android has a debug switch that can skip the composition of a frame if it detects a frame emissed in the previous frame, giving the underlying layer more time to display. The intention is good, not to make the bottom layer too busy, by actively skipping composition to slow down the work of the bottom layer. But since skipping compositing is equivalent to actively dropping frames, it can lead to persistent frame drops in some scenarios. So this switch is not usually turned on.
VSYNC-sf/VSYNC-app
Value types
Instantaneous Boolean value. When changing, vsync-SF/vsync-app software signal is sent at that moment.
Timing/interpretation
DispSync is not DispSync.
role
Vsync-app and vsync-sf, as DispSync dispenses, are the starting point of application rendering /SurfaceFlinger composition. This is also the first place we should look to analyze a Systrace. If vsync-SF is missing in a particular location, then it indicates that frames are being dropped, either by SurfaceFlinger (as mentioned earlier); Or the app didn’t finish rendering in time, resulting in lost frames.
A small problem
(The public recently in grayscale q&A function, it is a pity that I have not been grayscale.) Here’s a question for you to think about:
In the Systrace of vsync-sf/vsync-app, there is basically no change in the vsync-app. What is the possible reason?
Think about it, leave a comment in the comments section, and I’ll give you the answer in the next simowCE bulletin. Or if you want to know anything about Systrace, please leave a comment in the comments section.
The tail
As I said in the previous article, I write articles that I do not understand and I am interested in, but this will result in my slow update frequency. I wish there was a content section that updated more frequently. I used to answer people’s questions in some groups, and gradually I found that many of the questions were asked over and over again, indicating that these questions were representative, so I wanted to summarize them so that you could refer to them.
This reminds me of when I was in grade six in primary school, the Chinese teacher would write a question on a small blackboard every day, called “a question every day”, the content is generally some of the high-frequency questions in previous years or some interesting questions. If you are interested, you can write it and ask the teacher to correct it. I remember that I copied the whole “One of the Day” book and felt it was very interesting.
Therefore, I named this new column “Simowce Bulletin board” to pay tribute to my sixth-grade Chinese teacher and to remember my youth.
Well, this issue of “SimowCE bulletin board” ended here, if you want to see the first time “SimowCE bulletin board” update, please set this public number ** “as a star”. If you think this article is well written, the most important thing is to click a big attention **. Your support is the biggest motivation for me to update.
See you in the next simowCE bulletin.
🏆 nuggets technical essay | double festival special articles