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

Commit 09979fbe authored by John Reck's avatar John Reck
Browse files

Break down jank between frame drops vs. triple buffered

Bug: 70220906
Test: JankyScene vs. systrace vs. jankstats
Change-Id: Ia012685020cc5bcabbd3f92f0bdeb84eaf50733d
parent c1756316
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -56,7 +56,7 @@ message GraphicsStatsJankSummaryProto {
    // Number of "missed vsync" events.
    // Number of "missed vsync" events.
    optional int32 missed_vsync_count = 3;
    optional int32 missed_vsync_count = 3;


    // Number of "high input latency" events.
    // Number of frames in triple-buffering scenario (high input latency)
    optional int32 high_input_latency_count = 4;
    optional int32 high_input_latency_count = 4;


    // Number of "slow UI thread" events.
    // Number of "slow UI thread" events.
@@ -67,6 +67,9 @@ message GraphicsStatsJankSummaryProto {


    // Number of "slow draw" events.
    // Number of "slow draw" events.
    optional int32 slow_draw_count = 7;
    optional int32 slow_draw_count = 7;

    // Number of frames that missed their deadline (aka, visibly janked)
    optional int32 missed_deadline_count = 8;
}
}


message GraphicsStatsHistogramBucketProto {
message GraphicsStatsHistogramBucketProto {
+26 −6
Original line number Original line Diff line number Diff line
@@ -129,22 +129,42 @@ void JankTracker::finishFrame(const FrameInfo& frame) {
            totalDuration -= forgiveAmount;
            totalDuration -= forgiveAmount;
        }
        }
    }
    }

    LOG_ALWAYS_FATAL_IF(totalDuration <= 0, "Impossible totalDuration %" PRId64, totalDuration);
    LOG_ALWAYS_FATAL_IF(totalDuration <= 0, "Impossible totalDuration %" PRId64, totalDuration);
    mData->reportFrame(totalDuration);
    mData->reportFrame(totalDuration);
    (*mGlobalData)->reportFrame(totalDuration);
    (*mGlobalData)->reportFrame(totalDuration);


    // Keep the fast path as fast as possible.
    if (CC_LIKELY(totalDuration < mFrameInterval)) {
        return;
    }

    // Only things like Surface.lockHardwareCanvas() are exempt from tracking
    // Only things like Surface.lockHardwareCanvas() are exempt from tracking
    if (frame[FrameInfoIndex::Flags] & EXEMPT_FRAMES_FLAGS) {
    if (CC_UNLIKELY(frame[FrameInfoIndex::Flags] & EXEMPT_FRAMES_FLAGS)) {
        return;
        return;
    }
    }


    if (totalDuration > mFrameInterval) {
        mData->reportJank();
        mData->reportJank();
        (*mGlobalData)->reportJank();
        (*mGlobalData)->reportJank();
    }

    bool isTripleBuffered = mSwapDeadline > frame[FrameInfoIndex::IntendedVsync];

    mSwapDeadline = std::max(mSwapDeadline + mFrameInterval,
                             frame[FrameInfoIndex::IntendedVsync] + mFrameInterval);

    // If we hit the deadline, cool!
    if (frame[FrameInfoIndex::FrameCompleted] < mSwapDeadline) {
        if (isTripleBuffered) {
            mData->reportJankType(JankType::kHighInputLatency);
            (*mGlobalData)->reportJankType(JankType::kHighInputLatency);
        }
        return;
    }

    mData->reportJankType(JankType::kMissedDeadline);
    (*mGlobalData)->reportJankType(JankType::kMissedDeadline);

    // Janked, reset the swap deadline
    nsecs_t jitterNanos = frame[FrameInfoIndex::FrameCompleted] - frame[FrameInfoIndex::Vsync];
    nsecs_t lastFrameOffset = jitterNanos % mFrameInterval;
    mSwapDeadline = frame[FrameInfoIndex::FrameCompleted] - lastFrameOffset + mFrameInterval;


    for (int i = 0; i < NUM_BUCKETS; i++) {
    for (int i = 0; i < NUM_BUCKETS; i++) {
        int64_t delta = frame.duration(COMPARISONS[i].start, COMPARISONS[i].end);
        int64_t delta = frame.duration(COMPARISONS[i].start, COMPARISONS[i].end);
+1 −0
Original line number Original line Diff line number Diff line
@@ -75,6 +75,7 @@ private:


    std::array<int64_t, NUM_BUCKETS> mThresholds;
    std::array<int64_t, NUM_BUCKETS> mThresholds;
    int64_t mFrameInterval;
    int64_t mFrameInterval;
    nsecs_t mSwapDeadline;
    // The amount of time we will erase from the total duration to account
    // The amount of time we will erase from the total duration to account
    // for SF vsync offsets with HWC2 blocking dequeueBuffers.
    // for SF vsync offsets with HWC2 blocking dequeueBuffers.
    // (Vsync + mDequeueBlockTolerance) is the point at which we expect
    // (Vsync + mDequeueBlockTolerance) is the point at which we expect
+1 −2
Original line number Original line Diff line number Diff line
@@ -23,8 +23,7 @@ namespace uirenderer {


static const char* JANK_TYPE_NAMES[] = {
static const char* JANK_TYPE_NAMES[] = {
        "Missed Vsync",        "High input latency",       "Slow UI thread",
        "Missed Vsync",        "High input latency",       "Slow UI thread",
        "Slow bitmap uploads", "Slow issue draw commands",
        "Slow bitmap uploads", "Slow issue draw commands", "Frame deadline missed"};
};


// The bucketing algorithm controls so to speak
// The bucketing algorithm controls so to speak
// If a frame is <= to this it goes in bucket 0
// If a frame is <= to this it goes in bucket 0
+1 −0
Original line number Original line Diff line number Diff line
@@ -33,6 +33,7 @@ enum JankType {
    kSlowUI,
    kSlowUI,
    kSlowSync,
    kSlowSync,
    kSlowRT,
    kSlowRT,
    kMissedDeadline,


    // must be last
    // must be last
    NUM_BUCKETS,
    NUM_BUCKETS,
Loading