# Cannot capture the SurfaceFlinger

**URL:** <https://forums.imgtec.com/t/cannot-capture-the-surfaceflinger/3391>\
**Category:** PowerVR Insider\
**Created:** [May 28, 2021, 7:42am UTC](https://forums.imgtec.com/t/cannot-capture-the-surfaceflinger/3391 "2021-05-28T07:42:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![YoungJun](https://avatars.discourse-cdn.com/v4/letter/y/3ec8ea/32.png) [@YoungJun](https://forums.imgtec.com/u/YoungJun)\
**Post date:** [May 28, 2021, 7:42am UTC](https://forums.imgtec.com/t/cannot-capture-the-surfaceflinger/3391/1 "2021-05-28T07:42:18Z")

</div>

Hi,

I want to capture android’s SurfaceFlinger using PVRCarbon.  
I tried to capture with the PVRCarbon GUI tool, but there is no ‘SurfaceFlinger’ on the list.  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/imagination1/original/1X/33926a6f654cd28efb28bb41ca7e0fcbbe559092.png)

Is it impossible? or any other way?

---

<div class="post-metadata">

**Author:** ![LawrenceGreen](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/lawrencegreen/32/378_2.png) [@LawrenceGreen](https://forums.imgtec.com/u/LawrenceGreen)\
**Post date:** [May 28, 2021, 9:40am UTC](https://forums.imgtec.com/t/cannot-capture-the-surfaceflinger/3391/2 "2021-05-28T09:40:08Z")

</div>

Hello YoungJun,

I’ll pass your query onto the Carbon team, in the meantime a couple things to note. it looks like you’re using an outdated version of Carbon, the newest version is available on our new developer portal : [Downloads - Imagination Developers](https://developer.imaginationtech.com/downloads/)

Secondly, I’d recommend using PVRTune while running another application, as I know that the surface flinger shows up while running another application. I might also recommend taking a carbon recording of another application, and checking the list of function calls to see if any of them are owned by the surface flinger.

I’ll further investigate profiling the surface flinger itself.

All the best,  
Lawrence

---

<div class="post-metadata">

**Author:** ![YoungJun](https://avatars.discourse-cdn.com/v4/letter/y/3ec8ea/32.png) [@YoungJun](https://forums.imgtec.com/u/YoungJun)\
**Post date:** [June 1, 2021, 1:35am UTC](https://forums.imgtec.com/t/cannot-capture-the-surfaceflinger/3391/3 "2021-06-01T01:35:34Z")

</div>

Hi Lawrence,

Thanks for your effort. I changed the newer Carbon version with your comment, but it is not on the list.  
Secondly thing, You’re right. An update to the screen is required for the surface flinger to work. I ran PVRTune as your recommendation but still couldn’t check the surface flinger.

I hope your help.

Thanks,  
Youngjun

---

<div class="post-metadata">

**Author:** ![LawrenceGreen](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/lawrencegreen/32/378_2.png) [@LawrenceGreen](https://forums.imgtec.com/u/LawrenceGreen)\
**Post date:** [June 2, 2021, 4:26pm UTC](https://forums.imgtec.com/t/cannot-capture-the-surfaceflinger/3391/4 "2021-06-02T16:26:32Z")

</div>

Hi Youngjun,

Just to double check and help us identify the difficulties, which PowerVR device are you using? and do you know the DDK version?  
When I take a recording of an SDK example with PVRTuneDeveloper 21.1, I see a render task with a different PID interrupting the application’s render task. You can distinguish the PID at a glance by the colour on the top of the task, the surface flinger should stand out from being different from the surrounding tasks, as you can see below.

![Screenshot 2021-06-02 160444](https://us1.discourse-cdn.com/flex015/uploads/imagination1/original/1X/21b626584d34f31a5cf3cd1d4e39bed7f9bc6dba.png)  
 ![Screenshot 2021-06-02 161644](https://us1.discourse-cdn.com/flex015/uploads/imagination1/original/1X/3eabbe92b60d9485d11a3688afac90e23d10e23b.png)

I’m still looking into capturing the surface flinger directly, and will let you know if I find anything further

---

<div class="post-metadata">

**Author:** ![YoungJun](https://avatars.discourse-cdn.com/v4/letter/y/3ec8ea/32.png) [@YoungJun](https://forums.imgtec.com/u/YoungJun)\
**Post date:** [June 3, 2021, 5:57am UTC](https://forums.imgtec.com/t/cannot-capture-the-surfaceflinger/3391/5 "2021-06-03T05:57:05Z")

</div>

Hi Lawrence,

Thanks for your effort. This is my device information,

> Driver Version: Rogue\_DDK\_Android rogueddk 1.13@5776728 (Unknown) (release) build options: 0x00000010 android  
> Device Name: PowerVR\_9XTP  
> GPU variant BVNC: 27.5.254.2 (HW)  
> Firmware Version: 1.13 @ 5776728 (release) build options: 0x80000010 android

I’ll also do try to capture the surface flinger.

Thanks,  
Youngjun

---

<div class="post-metadata">

**Author:** ![LawrenceGreen](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/lawrencegreen/32/378_2.png) [@LawrenceGreen](https://forums.imgtec.com/u/LawrenceGreen)\
**Post date:** [June 4, 2021, 3:01pm UTC](https://forums.imgtec.com/t/cannot-capture-the-surfaceflinger/3391/6 "2021-06-04T15:01:15Z")

</div>

Hi Youngjun,

I’ve had some feedback from the tools team, and it should theoretically be possible with Carbon, it involves a similar process to capturing the Weston compositor. You have to manually set up the layers on the system.  
You can find more detailed instructions for loading PVRCarbon layers to start recordings from within the documentation folder inside carbon for more detail, but I’ll also list the steps here.

- Copy the layers inside `Recorder/Android/[DEVICE_CPU_ARCHITECTURE]/` to `/data/local/debug/gles`

```auto
adb root
adb disable-verity
adb reboot
adb root
adb shell setenforce 0
adb shell mkdir -p "/data/local/debug/gles"
adb push libEGL.so "/data/local/debug/gles"
adb push libGLESv2.so "/data/local/debug/gles"
adb push libPVRCarbon.so "/data/local/debug/gles"
adb push libGlLayer_PowerVR_carbon.so "/data/local/debug/gles"

```

- Enable the PVRRecording Layer globally

```auto
adb shell settings put global enable_gpu_debug_layers 1 
adb shell setprop debug.gles.layers libGlLayer_PowerVR_carbon.so

```

- Upon restarting surface flinger the Carbon recording layer might be able to start recording, killing surface flinger should cause android to restart it.

```auto
adb shell pidof surfaceflinger
adb shell kill -9 <PID Returned from the previous statement>

```

However Since you said that the surface flinger is not appearing inside of PVRTune this might raise some issues. Tune uses the GPU counters, so any work submitted to the GPU should be appearing there. If Tune is not detecting the surface flinger, this might suggest that surface flinger is being accelerated by another piece of hardware or not being accelerated at all. If this is the case, Carbon won’t be able to record this workload since it might not be done via API calls, and carbon captures its recordings via a list of API calls.

Hopefully this method is successful, all the best,  
Lawrence
