summaryrefslogtreecommitdiff
path: root/libs/gui/BufferQueueProducer.cpp
diff options
context:
space:
mode:
author Yiwei Zhang <zzyiwei@google.com> 2019-04-16 11:03:01 -0700
committer Yiwei Zhang <zzyiwei@google.com> 2019-04-16 11:20:44 -0700
commitcb7dd008877ec881dc25d7c941bda802a0b467ff (patch)
tree4e07a58f6a85400851211a4750fc2940fe7b6929 /libs/gui/BufferQueueProducer.cpp
parentc4f335d6f4b00bac3fde8c439bcc363dff0a77ac (diff)
TimeStats: fix a racing case
setPostTime is plumbed without BufferQueue lock, and it's called at the end of queueBuffer. If the addAndGetFrameTimestamps is delayed by queueBuffer back pressure (this could happen on special SF/BQ configs), setAcquireFence will be called with a out-of-bound index internally. So this change will tweak the order of the back Pressure logic to make the post time correct when queueBuffer back pressure happens as well as guarding the TimeStats more strictly. Bug: 130515827 Test: all SurfaceFlinger tests Change-Id: I2eace6d8693cc647284de0f33e7b58a6bf79eaaf
Diffstat (limited to 'libs/gui/BufferQueueProducer.cpp')
-rw-r--r--libs/gui/BufferQueueProducer.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/libs/gui/BufferQueueProducer.cpp b/libs/gui/BufferQueueProducer.cpp
index 4ff69c57ce..c94c6b31c6 100644
--- a/libs/gui/BufferQueueProducer.cpp
+++ b/libs/gui/BufferQueueProducer.cpp
@@ -1007,14 +1007,6 @@ status_t BufferQueueProducer::queueBuffer(int slot,
mCallbackCondition.notify_all();
}
- // Wait without lock held
- if (connectedApi == NATIVE_WINDOW_API_EGL) {
- // Waiting here allows for two full buffers to be queued but not a
- // third. In the event that frames take varying time, this makes a
- // small trade-off in favor of latency rather than throughput.
- lastQueuedFence->waitForever("Throttling EGL Production");
- }
-
// Update and get FrameEventHistory.
nsecs_t postedTime = systemTime(SYSTEM_TIME_MONOTONIC);
NewFrameEventsEntry newFrameEventsEntry = {
@@ -1026,6 +1018,14 @@ status_t BufferQueueProducer::queueBuffer(int slot,
addAndGetFrameTimestamps(&newFrameEventsEntry,
getFrameTimestamps ? &output->frameTimestamps : nullptr);
+ // Wait without lock held
+ if (connectedApi == NATIVE_WINDOW_API_EGL) {
+ // Waiting here allows for two full buffers to be queued but not a
+ // third. In the event that frames take varying time, this makes a
+ // small trade-off in favor of latency rather than throughput.
+ lastQueuedFence->waitForever("Throttling EGL Production");
+ }
+
return NO_ERROR;
}