SurfaceFlinger: tune FPS detection logic
Keep 200ms of history for layer instead of 100ms to accomodate
scenarios of YouTube playing music and renders at ~6Hz.
In addition, change the way layers are considered relevant for fps
detection to have a time based mechanism as well. Going by frame number
only makes slow layers to become relevant too late.
Fixes: 135009095
Test: YouTube playing music
Change-Id: Id38290e453111c5cfd4a23383b36b6862c2dd386
diff --git a/services/surfaceflinger/Scheduler/LayerInfo.cpp b/services/surfaceflinger/Scheduler/LayerInfo.cpp
index 95d7d31..3104724 100644
--- a/services/surfaceflinger/Scheduler/LayerInfo.cpp
+++ b/services/surfaceflinger/Scheduler/LayerInfo.cpp
@@ -38,6 +38,12 @@
mLastUpdatedTime = std::max(lastPresentTime, systemTime());
mPresentTimeHistory.insertPresentTime(mLastUpdatedTime);
+ if (mLastPresentTime == 0) {
+ // First frame
+ mLastPresentTime = lastPresentTime;
+ return;
+ }
+
const nsecs_t timeDiff = lastPresentTime - mLastPresentTime;
mLastPresentTime = lastPresentTime;
// Ignore time diff that are too high - those are stale values