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

Commit 0e8452bb authored by Pascal Mütschard's avatar Pascal Mütschard
Browse files

Add the expected and actual frame duration to the SF jank data.

Adds the expected and actual frame duration, that is the frame durations
as shown in the frame timeline in Perfetto, to the jank data exposed by
SurfaceFlinger.

This reverts commit e7938906.

Bug: b/354763298
Test: libsurfaceflinger_unittest manual
Flag: com.android.internal.jank.use_sf_frame_duration
Change-Id: Ifa060c02a5619a1e99e44f71a15fc4666a338011
parent 53a8ef05
Loading
Loading
Loading
Loading
+11 −1
Original line number Original line Diff line number Diff line
@@ -29,7 +29,17 @@ parcelable JankData {
  int jankType;
  int jankType;


  /**
  /**
   * Expected duration in nanoseconds of this frame.
   * Time between frames in nanoseconds.
   */
   */
  long frameIntervalNs;
  long frameIntervalNs;

  /**
   * Time allocated to the application to render this frame.
   */
  long scheduledAppFrameTimeNs;

  /**
   * Time taken by the application to render this frame.
   */
  long actualAppFrameTimeNs;
}
}
+17 −0
Original line number Original line Diff line number Diff line
@@ -697,6 +697,23 @@ void SurfaceFrame::onPresent(nsecs_t presentTime, int32_t displayFrameJankType,
        jd.jankType = mJankType;
        jd.jankType = mJankType;
        jd.frameIntervalNs =
        jd.frameIntervalNs =
                (mRenderRate ? *mRenderRate : mDisplayFrameRenderRate).getPeriodNsecs();
                (mRenderRate ? *mRenderRate : mDisplayFrameRenderRate).getPeriodNsecs();

        if (mPredictionState == PredictionState::Valid) {
            jd.scheduledAppFrameTimeNs = mPredictions.endTime - mPredictions.startTime;

            // Using expected start, rather than actual, to measure the entire frame time. That is
            // if the application starts the frame later than scheduled, include that delay in the
            // frame time, as it usually means main thread being busy with non-rendering work.
            if (mPresentState == PresentState::Dropped) {
                jd.actualAppFrameTimeNs = mDropTime - mPredictions.startTime;
            } else {
                jd.actualAppFrameTimeNs = mActuals.endTime - mPredictions.startTime;
            }
        } else {
            jd.scheduledAppFrameTimeNs = 0;
            jd.actualAppFrameTimeNs = 0;
        }

        JankTracker::onJankData(mLayerId, jd);
        JankTracker::onJankData(mLayerId, jd);
    }
    }
}
}