From a3fe67b0397113b0325fc1824d127c049f96aaf5 Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Tue, 1 Dec 2020 00:24:33 +0100 Subject: Fix vsyncId for long frames and double stuffed Since the vsyncId was applied immediately, and since we are doing client-side queing in case we are double stuffed, there was a scenario when setFrameTimelineVsyncId was applied too early meaning that the previous frame was tagged with the id from the next frame. To fix that, we set the pending vsync id and then apply it together with the buffer. Test: Expand quick settings, ensure no missing jank data for shared timeline jank classification Change-Id: Id54133b84e5305d7f1f21dbfd9f0889ef3e464c9 --- libs/gui/BLASTBufferQueue.cpp | 11 +++++++---- libs/gui/include/gui/BLASTBufferQueue.h | 3 +++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/libs/gui/BLASTBufferQueue.cpp b/libs/gui/BLASTBufferQueue.cpp index e6aa02a8fe..3a3a96fc32 100644 --- a/libs/gui/BLASTBufferQueue.cpp +++ b/libs/gui/BLASTBufferQueue.cpp @@ -289,6 +289,11 @@ void BLASTBufferQueue::processNextBufferLocked(bool useNextTransaction) { t->setDesiredPresentTime(bufferItem.mTimestamp); t->setFrameNumber(mSurfaceControl, bufferItem.mFrameNumber); + if (!mNextFrameTimelineVsyncIdQueue.empty()) { + t->setFrameTimelineVsync(mSurfaceControl, mNextFrameTimelineVsyncIdQueue.front()); + mNextFrameTimelineVsyncIdQueue.pop(); + } + if (mAutoRefresh != bufferItem.mAutoRefresh) { t->setAutoRefresh(mSurfaceControl, bufferItem.mAutoRefresh); mAutoRefresh = bufferItem.mAutoRefresh; @@ -417,10 +422,8 @@ status_t BLASTBufferQueue::setFrameRate(float frameRate, int8_t compatibility, status_t BLASTBufferQueue::setFrameTimelineVsync(int64_t frameTimelineVsyncId) { std::unique_lock _lock{mMutex}; - SurfaceComposerClient::Transaction t; - - return t.setFrameTimelineVsync(mSurfaceControl, frameTimelineVsyncId) - .apply(); + mNextFrameTimelineVsyncIdQueue.push(frameTimelineVsyncId); + return OK; } sp BLASTBufferQueue::getSurface(bool includeSurfaceControlHandle) { diff --git a/libs/gui/include/gui/BLASTBufferQueue.h b/libs/gui/include/gui/BLASTBufferQueue.h index 9fb7d6fd36..bdf128a538 100644 --- a/libs/gui/include/gui/BLASTBufferQueue.h +++ b/libs/gui/include/gui/BLASTBufferQueue.h @@ -28,6 +28,7 @@ #include #include +#include namespace android { @@ -143,6 +144,8 @@ private: // should acquire the next frame as soon as it can and not wait for a frame to become available. // This is only relevant for shared buffer mode. bool mAutoRefresh GUARDED_BY(mMutex) = false; + + std::queue mNextFrameTimelineVsyncIdQueue GUARDED_BY(mMutex); }; } // namespace android -- cgit v1.2.3-59-g8ed1b