Need some detail of how SurfaceFlinger and BufferQueue works on Android platform

616 Views Asked by At

I'm investigating the issue with application hang. The issue is only reproducible on Samsung S22 with adaptive fps feature ON. My app uses opengl to render its content. Also we use VideoView widget from Android SDK to playback some short movies. The problem occurs in a moment while video playback is paused and moved out of the screen. As I can see, my app's native render thread hangs on eglSwapBuffers call.

As I understand, Android render works roughly as following:

  • my app produces the buffer with data during the frame.
  • after data is ready, it performs eglSwapBuffers. This involves queueBuffer() passing the data to SurfaceFlinger's BufferQueue, then waits for next free buffer in dequeueBuffer().
  • on VSYNC-sf signal SurfaceFlinger takes the buffer with acquireBuffer() and pass it to the consumer (HWC I guess?).
  • Some external consumer uses the buffer, draw data and then release the buffer back in releaseBufferCallback()

From systrace dump I can see that at some point the SurfaceFlinger stops processing queued buffers, BufferQueue raises to its maximum and application hangs trying to dequeue next free buffer at eglSwapBuffers call. No more acquireBuffer() or releaseBufferCallback() happens.

The questions are: who is a Consumer side? How can I track which system fails? Why may SurfaceFlinger stop processing buffers?

Any suggestions are highly appreciated! Best regards!

systrace screenshot

0

There are 0 best solutions below