Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a3fe67b0 authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

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
parent 6df72d72
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -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<Surface> BLASTBufferQueue::getSurface(bool includeSurfaceControlHandle) {
+3 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@

#include <system/window.h>
#include <thread>
#include <queue>

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<int64_t> mNextFrameTimelineVsyncIdQueue GUARDED_BY(mMutex);
};

} // namespace android