1

I'm trying to get a better understanding of how my application is interacting with the Android's buffering system. Specifically, I want to optimize when my frames are being added to SurfaceFlinger's BufferQueue, in relation to the Vsync signal.

I understand that BufferQueue information is included inside SurfaceViews when using them:

      Binder_1-276   (  171) [001] ...1 34110.301903: tracing_mark_write: C|171|SurfaceView|1
surfaceflinger-171   (  171) [001] ...1 34110.314233: tracing_mark_write: C|171|SurfaceView|0

What about if I'm using a TextureView? There is no SurfaceView counter in these cases. Is there any other indicator of buffer state when not using a SurfaceView? Do the application counters also denote BufferQueue state?

      Binder_2-279   (  171) [000] ...1 34169.029234: tracing_mark_write: C|171|com.android.grafika/com.android.grafika.PlayMovieActivity|1

The following line in both BufferQueueProducer.cpp and BufferQueueConsumer.cpp seem to suggest this, but I could use a vote of confidence if at all possible:

ATRACE_INT(mCore->mConsumerName.string(), mCore->mQueue.size());
Shookit
  • 1,162
  • 2
  • 13
  • 29
  • See https://source.android.com/devices/graphics/architecture.html#tracking – fadden Jan 09 '15 at 17:06
  • I've read through this previously, but I don't see SurfaceView in the traces I'm looking at... I have all of the systrace categories enabled, as well. – Shookit Jan 09 '15 at 17:08
  • Actually, I just grepped through a bigger set of traces... youtube does *not* have SurfaceView, but VLC *does*; do you know why this could be? – Shookit Jan 09 '15 at 17:14
  • I don't know if the youtube app uses SurfaceView or TextureView (note the comments in the arch doc about SV vs. TV). Do `adb shell dumpsys SurfaceFlinger` while the app is running to see what windows SurfaceFlinger and HWC know about. If you don't see a separate window for the video then it's probably using TextureView. Easiest way to see the difference is to run Grafika and compare the results from the SurfaceView-based and TextureView-based video players. (Easiest because they're pretty simple, and they share a lot of code, so you can compare them side-by-side meaningfully.) – fadden Jan 09 '15 at 18:41
  • That's a great call, I'll check that out and post my findings. By the way, thanks for your work on Graphika, that's been very useful for getting a better understanding of the graphics subsystem. – Shookit Jan 09 '15 at 18:43

1 Answers1

0

The BufferQueue information is available in systrace/atrace/ftrace, with a few caveats.

In the traces you might see SurfaceView debug information; this will show you the BufferQueue state (but only if a SurfaceView is being used!).

Binder_4-1188  (  171) [000] ...1 12563.059605: tracing_mark_write: C|171|SurfaceView|1

In this case, BufferQueue = 1

If you need this information in a non SurfaceView application (e.g., TextureView), the data is still available under the package name:

Binder_2-279   (  171) [000] ...1 12668.678680: tracing_mark_write: C|171|com.google.android.youtube/com.google.android.apps.youtube.app.WatchWhileActivity|1

Furthermore, there are multiple BufferQueues, and this only tells you about the state of that BufferQueue.

Shookit
  • 1,162
  • 2
  • 13
  • 29