Fix SF jank classification
In a buffer stuffed state, there is no way the app frame will be
presented on time. It will be at least one vsync late even if the app
frame finished much earlier than expected. The current system wrongly
classifies this as SF Scheduling jank when in reality, the only jank is
that the app is now in a buffer stuffed state.
The other case can also happen, the app could have presented only one
vsync late in a stuffed scenario, but it could have spent some time
waiting on dequeue. To consider this case and give some room for the
app, we try to adjust the deadline within which the app should be ready
to be presented on the next vsync. This way, we can find frames that are
truly long in a buffer stuffed state.
Bug: 180423820
Test: libsurfaceflinger_unittest
Change-Id: I6ff35d018cfab1ef1e96d010165ed7bce013a98e
diff --git a/services/surfaceflinger/FrameTimeline/FrameTimeline.h b/services/surfaceflinger/FrameTimeline/FrameTimeline.h
index d65769b..7c6a0cc 100644
--- a/services/surfaceflinger/FrameTimeline/FrameTimeline.h
+++ b/services/surfaceflinger/FrameTimeline/FrameTimeline.h
@@ -342,7 +342,7 @@
class DisplayFrame {
public:
DisplayFrame(std::shared_ptr<TimeStats> timeStats, JankClassificationThresholds thresholds,
- TraceCookieCounter* traceCookieCounter);
+ nsecs_t hwcDuration, TraceCookieCounter* traceCookieCounter);
virtual ~DisplayFrame() = default;
// Dumpsys interface - dumps only if the DisplayFrame itself is janky or is at least one
// SurfaceFrame is janky.
@@ -371,6 +371,7 @@
// Functions to be used only in testing.
TimelineItem getActuals() const { return mSurfaceFlingerActuals; };
TimelineItem getPredictions() const { return mSurfaceFlingerPredictions; };
+ FrameStartMetadata getFrameStartMetadata() const { return mFrameStartMetadata; };
FramePresentMetadata getFramePresentMetadata() const { return mFramePresentMetadata; };
FrameReadyMetadata getFrameReadyMetadata() const { return mFrameReadyMetadata; };
int32_t getJankType() const { return mJankType; }
@@ -394,6 +395,7 @@
TimelineItem mSurfaceFlingerActuals;
std::shared_ptr<TimeStats> mTimeStats;
const JankClassificationThresholds mJankClassificationThresholds;
+ const nsecs_t mHwcDuration;
// Collection of predictions and actual values sent over by Layers
std::vector<std::shared_ptr<SurfaceFrame>> mSurfaceFrames;
@@ -419,7 +421,8 @@
};
FrameTimeline(std::shared_ptr<TimeStats> timeStats, pid_t surfaceFlingerPid,
- JankClassificationThresholds thresholds = {});
+ JankClassificationThresholds thresholds = {},
+ nsecs_t hwcDuration = kDefaultHwcDuration);
~FrameTimeline() = default;
frametimeline::TokenManager* getTokenManager() override { return &mTokenManager; }
@@ -464,6 +467,11 @@
std::shared_ptr<TimeStats> mTimeStats;
const pid_t mSurfaceFlingerPid;
const JankClassificationThresholds mJankClassificationThresholds;
+ // In SF Predictions, both end & present are the same. The predictions consider the time used by
+ // composer as well, but we have no way to estimate how much time the composer needs. We are
+ // assuming an arbitrary time for the composer work.
+ const nsecs_t mHwcDuration;
+ static constexpr nsecs_t kDefaultHwcDuration = std::chrono::nanoseconds(3ms).count();
static constexpr uint32_t kDefaultMaxDisplayFrames = 64;
// The initial container size for the vector<SurfaceFrames> inside display frame. Although
// this number doesn't represent any bounds on the number of surface frames that can go in a