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

Commit 9c3d2f33 authored by Dake Gu's avatar Dake Gu Committed by Automerger Merge Worker
Browse files

Merge "Recompute the mNextFrameStartUnstuffed on every frame" into tm-qpr-dev...

Merge "Recompute the mNextFrameStartUnstuffed on every frame" into tm-qpr-dev am: bb64b1bf am: 48adcad1

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18724189



Change-Id: I02327c4585ddde218bd8e574d3204069399beb72
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 462345ca 48adcad1
Loading
Loading
Loading
Loading
+14 −9
Original line number Diff line number Diff line
@@ -206,6 +206,7 @@ void JankTracker::finishFrame(FrameInfo& frame, std::unique_ptr<FrameMetricsRepo
        frame.set(FrameInfoIndex::FrameDeadline) = deadline;
    }

    bool computeNextFrameStartUnstuffed = false;
    // If we hit the deadline, cool!
    if (frame[FrameInfoIndex::GpuCompleted] < deadline) {
        if (isTripleBuffered) {
@@ -213,7 +214,8 @@ void JankTracker::finishFrame(FrameInfo& frame, std::unique_ptr<FrameMetricsRepo
            (*mGlobalData)->reportJankType(JankType::kHighInputLatency);

            // Buffer stuffing state gets carried over to next frame, unless there is a "pause"
            mNextFrameStartUnstuffed += frameInterval;
            // Instead of increase by frameInterval, recompute to catch up the drifting vsync
            computeNextFrameStartUnstuffed = true;
        }
    } else {
        mData->reportJankType(JankType::kMissedDeadline);
@@ -222,14 +224,7 @@ void JankTracker::finishFrame(FrameInfo& frame, std::unique_ptr<FrameMetricsRepo
        (*mGlobalData)->reportJank();

        // Janked, store the adjust deadline to detect triple buffering in next frame correctly.
        nsecs_t jitterNanos = frame[FrameInfoIndex::GpuCompleted]
                - frame[FrameInfoIndex::Vsync];
        nsecs_t lastFrameOffset = jitterNanos % frameInterval;

        // Note the time when the next frame would start in an unstuffed situation. If it starts
        // earlier, we are in a stuffed situation.
        mNextFrameStartUnstuffed = frame[FrameInfoIndex::GpuCompleted]
                - lastFrameOffset + frameInterval;
        computeNextFrameStartUnstuffed = true;

        recomputeThresholds(frameInterval);
        for (auto& comparison : COMPARISONS) {
@@ -254,6 +249,16 @@ void JankTracker::finishFrame(FrameInfo& frame, std::unique_ptr<FrameMetricsRepo
        }
    }

    if (computeNextFrameStartUnstuffed) {
        nsecs_t jitterNanos = frame[FrameInfoIndex::GpuCompleted] - frame[FrameInfoIndex::Vsync];
        nsecs_t lastFrameOffset = jitterNanos % frameInterval;

        // Note the time when the next frame would start in an unstuffed situation. If it starts
        // earlier, we are in a stuffed situation.
        mNextFrameStartUnstuffed =
                frame[FrameInfoIndex::GpuCompleted] - lastFrameOffset + frameInterval;
    }

    int64_t totalGPUDrawTime = frame.gpuDrawTime();
    if (totalGPUDrawTime >= 0) {
        mData->reportGPUFrame(totalGPUDrawTime);