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

Commit 8a94550e authored by Adithya Srinivasan's avatar Adithya Srinivasan Committed by Jorim Jaggi
Browse files

Allow AppDeadlineMissed along with DisplayFrame jank for SurfaceFrames

If a DisplayFrame is janky, there is nothing the app could have done to
mitigate it. However, sweeping the app jank under the rug here prevents
the app metrics to recognize a genuine late frame from the app.

Bug: 183127139
Test: libsurfaceflinger_unittest
Change-Id: I62984f6cc8601fbf8bfb56d2e5f823c4f79f934b
parent 7f56cf87
Loading
Loading
Loading
Loading
+3 −7
Original line number Diff line number Diff line
@@ -575,16 +575,12 @@ void SurfaceFrame::classifyJankLocked(int32_t displayFrameJankType, const Fps& r
            }
        } else if (mFrameReadyMetadata == FrameReadyMetadata::LateFinish) {
            // Finish late, Present late
            if (displayFrameJankType == JankType::None) {
                // Display frame is not janky, so purely app's fault
            mJankType |= JankType::AppDeadlineMissed;
            } else {
            // Propagate DisplayFrame's jankType if it is janky
            mJankType |= displayFrameJankType;
        }
    }
}
}

void SurfaceFrame::onPresent(nsecs_t presentTime, int32_t displayFrameJankType, Fps refreshRate,
                             nsecs_t displayDeadlineDelta, nsecs_t displayPresentDelta) {
+9 −7
Original line number Diff line number Diff line
@@ -668,8 +668,9 @@ TEST_F(FrameTimelineTest, presentFenceSignaled_displayFramePredictionExpiredPres
    Fps renderRate = Fps::fromPeriodNsecs(30);

    EXPECT_CALL(*mTimeStats,
                incrementJankyFrames(TimeStats::JankyFramesInfo{refreshRate, renderRate, sUidOne,
                                                                sLayerNameOne, JankType::Unknown,
                incrementJankyFrames(
                        TimeStats::JankyFramesInfo{refreshRate, renderRate, sUidOne, sLayerNameOne,
                                                   JankType::Unknown | JankType::AppDeadlineMissed,
                                                   -1, -1, 25}));
    auto presentFence1 = fenceFactory.createFenceTimeForTest(Fence::NO_FENCE);
    int64_t surfaceFrameToken1 = mTokenManager->generateTokenForPredictions({10, 20, 60});
@@ -697,7 +698,7 @@ TEST_F(FrameTimelineTest, presentFenceSignaled_displayFramePredictionExpiredPres
    EXPECT_EQ(displayFrame->getFramePresentMetadata(), FramePresentMetadata::UnknownPresent);

    EXPECT_EQ(surfaceFrame1->getActuals().presentTime, 90);
    EXPECT_EQ(surfaceFrame1->getJankType(), JankType::Unknown);
    EXPECT_EQ(surfaceFrame1->getJankType(), JankType::Unknown | JankType::AppDeadlineMissed);
}

/*
@@ -1699,9 +1700,9 @@ TEST_F(FrameTimelineTest, jankClassification_surfaceFrameLateFinishEarlyPresent)
}

TEST_F(FrameTimelineTest, jankClassification_surfaceFrameLateFinishLatePresent) {
    // First frame - DisplayFrame is not janky. This should classify the SurfaceFrame as
    // First frame - DisplayFrame is not janky. This should classify the SurfaceFrame as only
    // AppDeadlineMissed. Second frame - DisplayFrame is janky. This should propagate DisplayFrame's
    // jank to the SurfaceFrame.
    // jank to the SurfaceFrame along with AppDeadlineMissed.

    EXPECT_CALL(*mTimeStats, incrementJankyFrames(_)).Times(2);
    auto presentFence1 = fenceFactory.createFenceTimeForTest(Fence::NO_FENCE);
@@ -1771,7 +1772,8 @@ TEST_F(FrameTimelineTest, jankClassification_surfaceFrameLateFinishLatePresent)
    EXPECT_EQ(actuals2.presentTime, 60);
    EXPECT_EQ(presentedSurfaceFrame2.getFramePresentMetadata(), FramePresentMetadata::LatePresent);
    EXPECT_EQ(presentedSurfaceFrame2.getFrameReadyMetadata(), FrameReadyMetadata::LateFinish);
    EXPECT_EQ(presentedSurfaceFrame2.getJankType(), JankType::SurfaceFlingerCpuDeadlineMissed);
    EXPECT_EQ(presentedSurfaceFrame2.getJankType(),
              JankType::SurfaceFlingerCpuDeadlineMissed | JankType::AppDeadlineMissed);
}

TEST_F(FrameTimelineTest, jankClassification_multiJankBufferStuffingAndAppDeadlineMissed) {