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());
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.