replicant-frameworks_native/libs/gui
Christian Poetzsch 31ab17fb0c Fix the execution point of onFrameAvailable/onFrameReplaced callbacks
In a4650a5 the concept of a maximum frame number allowance for the consumer was
introduced. A call to acquireBuffers will only return buffers when their frame
number is less-than-or-equal-to this maximum frame number. When SurfaceFlinger
is the consumer, this maximum  frame number is calculated in the
onFrameAvailable/onFrameReplaced callbacks. These callbacks are called when a
new buffer is dequeued by the application. The problem is that these callbacks
are called _after_ the fence wait which is used to throttle the frame
production of client apps. When the previous frame needs a long time to draw,
those waits can potentially be a long time. As a result SurfaceFlinger won't do
any composition with the new frame until the wait is over.

Normally this isn't a big problem because there is a queue of buffers for
SurfaceFlinger to work with. However, this changes massively when a client app
is using a swap interval of zero. In this case, a new frame will instantly
replace the previous queued frame. However, SurfaceFlinger doesn't know this
until the onFrameReplaced callback gets called - which is delayed by the fence
wait. If the timing is bad, SurfaceFlinger never gets a chance to pick up a new
frame to do the composition with.

We see this behaviour on our TC development system (slow GPU) with legacy
on-screen benchmarks. Such apps are using a swap interval of zero and sometimes
frames don't get updated for several seconds. This behaviour can be also seen
on a Nexus5, although it isn't as obvious as on our TC.

The fix in this cl is to move the EGL throttling to the end of the queueBuffers
function. This ensures that if a frame gets replaced in the queue, all
consumers who installed the callbacks, get called in a timely fashion.

Change-Id: I36e9ecda162150f41e97d4fb7437963a3d86b371
Signed-off-by: Christian Poetzsch <christian.potzsch@imgtec.com>
2015-12-16 18:46:53 -08:00
..
tests libgui/SurfaceFlinger: Add getConsumerName 2015-06-08 09:40:49 -07:00
Android.mk libgui: Enable -Weverything and -Werror 2015-03-18 15:57:27 -07:00
BitTube.cpp libgui: Enable -Weverything and -Werror 2015-03-18 15:57:27 -07:00
BufferItem.cpp fix BufferItem flatten/unflatten alignment 2015-05-22 10:54:25 -07:00
BufferItemConsumer.cpp Refactor ConsumerBase and it's derived classes. 2015-05-18 14:29:18 -07:00
BufferQueue.cpp libgui: Hook up onFrameReplaced 2015-05-11 15:33:01 -07:00
BufferQueueConsumer.cpp BufferQueueConsumer: signal onFrameReleased on dropped frames 2015-07-17 08:37:47 -07:00
BufferQueueCore.cpp libgui: Add generation numbers to BufferQueue 2015-06-03 11:09:33 -07:00
BufferQueueProducer.cpp Fix the execution point of onFrameAvailable/onFrameReplaced callbacks 2015-12-16 18:46:53 -08:00
BufferSlot.cpp libgui: Enable -Weverything and -Werror 2015-03-18 15:57:27 -07:00
CleanSpec.mk Fix missing parens in CleanSpec.mk. 2012-10-04 20:05:19 -07:00
ConsumerBase.cpp Merge "Refactor ConsumerBase and it's derived classes." into mnc-dev 2015-05-18 21:29:39 +00:00
CpuConsumer.cpp Refactor ConsumerBase and it's derived classes. 2015-05-18 14:29:18 -07:00
DisplayEventReceiver.cpp use a socketpair instead of a pipe in BitTube 2012-04-02 18:41:10 -07:00
GLConsumer.cpp GLConsumer: Fix crop math 2015-06-10 10:24:51 -07:00
GraphicBufferAlloc.cpp libgui: Enable -Weverything and -Werror 2015-03-18 15:57:27 -07:00
GuiConfig.cpp don't use compile-time configuration of libgui as much as possible 2013-03-29 15:33:47 -07:00
IConsumerListener.cpp libgui: Enable -Weverything and -Werror 2015-03-18 15:57:27 -07:00
IDisplayEventConnection.cpp libgui: Enable -Weverything and -Werror 2015-03-18 15:57:27 -07:00
IGraphicBufferAlloc.cpp libgui: Propagate error by clearing sp<GB> 2015-06-01 13:59:15 -07:00
IGraphicBufferConsumer.cpp Fix PTS handling for buffer replacement 2015-05-12 13:10:17 -07:00
IGraphicBufferProducer.cpp Initialize local variables to avoid data leak 2015-09-28 17:08:24 -07:00
IProducerListener.cpp libgui: Enable -Weverything and -Werror 2015-03-18 15:57:27 -07:00
ISensorEventConnection.cpp libgui: Enable -Weverything and -Werror 2015-03-18 15:57:27 -07:00
ISensorServer.cpp Enable sensor data injection mode through adb. 2015-06-30 14:59:58 -07:00
ISurfaceComposer.cpp Bring back support for glReadPixels screenshot path 2015-10-16 14:45:10 -07:00
ISurfaceComposerClient.cpp libgui: Enable -Weverything and -Werror 2015-03-18 15:57:27 -07:00
LayerState.cpp SurfaceFlinger: Native changes to add blur effect 2015-11-08 01:07:13 -08:00
Sensor.cpp Merge "Set DATA_INJECTION mode flag for sensors." into mnc-dr-dev 2015-10-14 21:03:07 +00:00
SensorEventQueue.cpp Enable sensor data injection mode through adb. 2015-06-30 14:59:58 -07:00
SensorManager.cpp SensorManager fixes. 2015-08-25 11:24:02 -07:00
StreamSplitter.cpp DO NOT MERGE libgui: Prepare for IGBC::BufferItem removal 2015-03-19 13:58:07 -07:00
Surface.cpp libgui: Copyback all region except dirty region for newly allocated buffer 2015-10-06 03:22:27 -06:00
SurfaceComposerClient.cpp SurfaceFlinger: Native changes to add blur effect 2015-11-08 01:07:13 -08:00
SurfaceControl.cpp SurfaceFlinger: Native changes to add blur effect 2015-11-08 01:07:13 -08:00
SyncFeatures.cpp libgui: Only allow one return from useFenceSync 2015-03-19 10:32:51 -07:00