Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make sense of dumpsys SurfaceFlinger

Is there any documentation on the output of the adb command "dumpsys SurfaceFlinger"?

In particular, I'd like to understand what is the difference between an HWC or GLES layer type, and what does numHwLayers mean?

Here is the section of dumpsys SurfaceFlinger I'm talking about:

  mDebugForceFakeVSync=0
  Display[0] : 768x1280, xdpi=319.790009, ydpi=318.744995, refresh=16666667
  numHwLayers=5, flags=00000000
    type    |  handle  |   hints  |   flags  | tr | blend |  format  |       source crop         |           frame           name
------------+----------+----------+----------+----+-------+----------+---------------------------+--------------------------------
       GLES | b7e1c440 | 00000002 | 00000000 | 00 | 00100 | 00000002 | [  334,   56, 1102, 1190] | [    0,   50,  768, 1184] com.android.systemui.ImageWallpaper
       GLES | b7e1d7c8 | 00000002 | 00000000 | 00 | 00105 | 00000001 | [    0,   50,  768, 1184] | [    0,   50,  768, 1184] com.android.launcher/com.android.launcher2.Launcher
       GLES | b7e701e0 | 00000002 | 00000000 | 00 | 00105 | 00000001 | [    0,    0,  768,   50] | [    0,    0,  768,   50] StatusBar
       GLES | b7e1df68 | 00000002 | 00000000 | 00 | 00100 | 00000001 | [    0,    0,  768,   96] | [    0, 1184,  768, 1280] NavigationBar
  FB TARGET | b7dd3ab0 | 00000000 | 00000000 | 00 | 00105 | 00000001 | [    0,    0,  768, 1280] | [    0,    0,  768, 1280] HWC_FRAMEBUFFER_TARGET
like image 420
Andi Jay Avatar asked Feb 08 '14 06:02

Andi Jay


People also ask

How do you read Dumpsys?

dumpsys is a tool that runs on Android devices and provides information about system services. You can call dumpsys from the command line using the Android Debug Bridge (ADB) to get diagnostic output for all system services running on a connected device.

What is Dumpsys Gfxinfo?

dumpsys is an Android tool that runs on the device and dumps interesting information about the status of system services. Passing the gfxinfo command to dumpsys provides an output in logcat with performance information relating to frames of animation that are occurring during the recording phase.

How does SurfaceFlinger work in Android?

SurfaceFlinger creates the layer and sends it to WindowManager. WindowManager then sends the surface to the app, but keeps the SurfaceControl to manipulate the appearance of the app on the screen. Android 10 adds ASurfaceControl, which is another way that SurfaceFlinger can accept buffers.

What is process SurfaceFlinger?

SurfaceFlinger is an Android system service, responsible for compositing all the application and system surfaces into a single buffer that is finally to be displayed by display controller.


1 Answers

Ok, I have enough figured out to answer my own question, but if anyone has any additional input, please leave them in the comments. There's some additional stuff encountered which I'll note below that still isn't clear.

First, the link below helps explain a few things about how image rendering and compositing happens through SurfaceFlinger: http://source.android.com/devices/graphics.html

If you noticed in the link, there are two ways images are sent to the display. One is to process images with the GPU before sending them to the display, and the other is to use hardware overlays of the display to bypass the GPU and send images directly to the display. The latter method performs better, but you are limited to a certain number of layers/overlays (usually 4). If you have more layers, things have to get processed by the GPU.

The part of dumpsys SurfaceFlinger which was at the center of my question shows you how many layers there are at the moment dumpsys was called, and if those layers are being handled by the Hardware Composer (HWC) or the GPU (GLES). This explains what HWC and GLES mean. Also, numHwLayers is how many overlays the display supports (usually 4).

Also, there are "source crop" and "frame" coordinates. The source crop is the section of an image that will be displayed. For example, if it's a wallpaper that spans multiple display screens (think about what you see on the home screen when you swipe across screens), then at a given moment you will only need a subsection of that larger wallpaper image to display. This means that source crop is just telling you what section of that overall image you are using at the moment. The frame part of it is where that section of the source image is going to actually be display on the screen.

The code for this section of the dumpsys SurfaceFlinger command is located here: \frameworks\native\services\surfaceflinger\DisplayHardware\HWComposer.cpp

It's in a function called "HWComposer::dump"

The above answers my original question, but below are some additional things I noticed:

It looks like there are more composition types than HWC and GLES. In the code noted above, I see a "BACKGROUND" and a "FB TARGET" composite type. FB TARGET seems to always be present when you type "dumpsys SurfaceFlinger" in adb. I think FB Target is simply the frame buffer the complete image will be written to (someone please confirm this). Even if the device is asleep you see this FB TARGET. What I don't understand is, what is this BACKGROUND type? I can't even take a guess on that one. Please leave a comment if you know what this is.

Thanks!

like image 80
Andi Jay Avatar answered Sep 17 '22 12:09

Andi Jay