From 544c52279b9348760314ebbd705ffa94e13ae28b Mon Sep 17 00:00:00 2001 From: JihCheng Chiu Date: Tue, 2 Apr 2019 20:50:58 +0800 Subject: Change the position of addAndGetFrameTimestamps when queueBuffer BufferQueueProducer's addAndGetFrameTimestamps() call Layer to add a new time record. When SurfaceFlinger latch buffer, it will fill related information into the new record. Nevertheless, queueBuffer call onFrameAvailable() before addAndGetFrameTimestamps(). SurfaceFlinger main thread may latch buffer before this thread add a new time record. Then it cause that main thread can not fill related information into the record. Therefore addAndGetFrameTimestamps() should be called before call onFrameAvailable(). Bug: 146193345 Test: run cts-on-gsi -m CtsDeqpTestCases -t dEQP-EGL.functional.get_frame_timestamps#rgba8888_depth_stencil Change-Id: Ie54480b7f8626d4cfa7f9a131f3e4fdcf211915d --- libs/gui/BufferQueueProducer.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'libs/gui/BufferQueueProducer.cpp') diff --git a/libs/gui/BufferQueueProducer.cpp b/libs/gui/BufferQueueProducer.cpp index 92ab41019e..3efb1b6acb 100644 --- a/libs/gui/BufferQueueProducer.cpp +++ b/libs/gui/BufferQueueProducer.cpp @@ -981,6 +981,17 @@ status_t BufferQueueProducer::queueBuffer(int slot, item.mGraphicBuffer.clear(); } + // Update and get FrameEventHistory. + nsecs_t postedTime = systemTime(SYSTEM_TIME_MONOTONIC); + NewFrameEventsEntry newFrameEventsEntry = { + currentFrameNumber, + postedTime, + requestedPresentTimestamp, + std::move(acquireFenceTime) + }; + addAndGetFrameTimestamps(&newFrameEventsEntry, + getFrameTimestamps ? &output->frameTimestamps : nullptr); + // Call back without the main BufferQueue lock held, but with the callback // lock held so we can ensure that callbacks occur in order @@ -1010,17 +1021,6 @@ status_t BufferQueueProducer::queueBuffer(int slot, mCallbackCondition.notify_all(); } - // Update and get FrameEventHistory. - nsecs_t postedTime = systemTime(SYSTEM_TIME_MONOTONIC); - NewFrameEventsEntry newFrameEventsEntry = { - currentFrameNumber, - postedTime, - requestedPresentTimestamp, - std::move(acquireFenceTime) - }; - 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 -- cgit v1.2.3-59-g8ed1b