Account for refresh rate in sf adpf hint session rate limiter
Currently, the SurfaceFlinger hint session rate limiter will send hints
after 80ms of inactivity regardless of refresh rate, which can lead to
issues at lower rates (eg: 30fps) where we skip the window that we
should send the hint in and go stale. This patch addresses that
oversight.
Bug: b/240473968
Test: manual
Change-Id: I27ce9229537e445f202e948ab201cc0242882667
diff --git a/services/surfaceflinger/DisplayHardware/PowerAdvisor.cpp b/services/surfaceflinger/DisplayHardware/PowerAdvisor.cpp
index b9d4753..62078ba 100644
--- a/services/surfaceflinger/DisplayHardware/PowerAdvisor.cpp
+++ b/services/surfaceflinger/DisplayHardware/PowerAdvisor.cpp
@@ -759,9 +759,10 @@
}
bool AidlPowerHalWrapper::shouldReportActualDurations() {
- // Report if we have never reported before or are approaching a stale session
+ // Report if we have never reported before or will go stale next frame
if (!mLastActualDurationSent.has_value() ||
- (systemTime() - mLastActualReportTimestamp) > kStaleTimeout.count()) {
+ (mLastTargetDurationSent + systemTime() - mLastActualReportTimestamp) >
+ kStaleTimeout.count()) {
return true;
}
diff --git a/services/surfaceflinger/DisplayHardware/PowerAdvisor.h b/services/surfaceflinger/DisplayHardware/PowerAdvisor.h
index 98921b0..a93744f 100644
--- a/services/surfaceflinger/DisplayHardware/PowerAdvisor.h
+++ b/services/surfaceflinger/DisplayHardware/PowerAdvisor.h
@@ -332,7 +332,7 @@
static const bool sTraceHintSessionData;
static constexpr const std::chrono::nanoseconds kDefaultTarget = 16ms;
// Amount of time after the last message was sent before the session goes stale
- // actually 100ms but we use 80 here to ideally avoid going stale
+ // actually 100ms but we use 80 here to give some slack
static constexpr const std::chrono::nanoseconds kStaleTimeout = 80ms;
};