diff options
| author | 2024-09-03 11:02:11 +0200 | |
|---|---|---|
| committer | 2024-09-03 11:04:45 +0200 | |
| commit | 0e8452bba5108587a688c2e90c8c57a8cef19ae8 (patch) | |
| tree | a698ccb152648943c1060f6be8e25e7bd15550ae | |
| parent | 53a8ef0537e22c082e58b9e4f1491e6362040873 (diff) | |
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 e79389068c08c3eba422e8f3975b222849f0b326.
Bug: b/354763298
Test: libsurfaceflinger_unittest manual
Flag: com.android.internal.jank.use_sf_frame_duration
Change-Id: Ifa060c02a5619a1e99e44f71a15fc4666a338011
| -rw-r--r-- | libs/gui/aidl/android/gui/JankData.aidl | 12 | ||||
| -rw-r--r-- | services/surfaceflinger/FrameTimeline/FrameTimeline.cpp | 17 |
2 files changed, 28 insertions, 1 deletions
diff --git a/libs/gui/aidl/android/gui/JankData.aidl b/libs/gui/aidl/android/gui/JankData.aidl index 7ea9d22ecf..ec13681182 100644 --- a/libs/gui/aidl/android/gui/JankData.aidl +++ b/libs/gui/aidl/android/gui/JankData.aidl @@ -29,7 +29,17 @@ parcelable JankData { int jankType; /** - * Expected duration in nanoseconds of this frame. + * Time between frames in nanoseconds. */ long frameIntervalNs; + + /** + * Time allocated to the application to render this frame. + */ + long scheduledAppFrameTimeNs; + + /** + * Time taken by the application to render this frame. + */ + long actualAppFrameTimeNs; } diff --git a/services/surfaceflinger/FrameTimeline/FrameTimeline.cpp b/services/surfaceflinger/FrameTimeline/FrameTimeline.cpp index 2a0ee5a993..3736abc79f 100644 --- a/services/surfaceflinger/FrameTimeline/FrameTimeline.cpp +++ b/services/surfaceflinger/FrameTimeline/FrameTimeline.cpp @@ -697,6 +697,23 @@ void SurfaceFrame::onPresent(nsecs_t presentTime, int32_t displayFrameJankType, jd.jankType = mJankType; jd.frameIntervalNs = (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); } } |