Prevent LOAD_RESET signal after too many false positives
If the hint session sends too many LOAD_RESET signals without an actual
workload happening, stop sending LOAD_RESET until something actually
happens.
Bug: 232329572
Test: manual
Change-Id: I8fb34a2ee0ff028c83e955a0283396cd69e52361
diff --git a/libs/hwui/renderthread/HintSessionWrapper.cpp b/libs/hwui/renderthread/HintSessionWrapper.cpp
index 597cbf7..814ac4d 100644
--- a/libs/hwui/renderthread/HintSessionWrapper.cpp
+++ b/libs/hwui/renderthread/HintSessionWrapper.cpp
@@ -156,6 +156,7 @@
void HintSessionWrapper::reportActualWorkDuration(long actualDurationNanos) {
if (!init()) return;
+ mResetsSinceLastReport = 0;
if (actualDurationNanos > kSanityCheckLowerBound &&
actualDurationNanos < kSanityCheckUpperBound) {
gAPH_reportActualWorkDurationFn(mHintSession, actualDurationNanos);
@@ -163,9 +164,12 @@
}
void HintSessionWrapper::sendLoadResetHint() {
+ static constexpr int kMaxResetsSinceLastReport = 2;
if (!init()) return;
nsecs_t now = systemTime();
- if (now - mLastFrameNotification > kResetHintTimeout) {
+ if (now - mLastFrameNotification > kResetHintTimeout &&
+ mResetsSinceLastReport <= kMaxResetsSinceLastReport) {
+ ++mResetsSinceLastReport;
gAPH_sendHintFn(mHintSession, static_cast<int>(SessionHint::CPU_LOAD_RESET));
}
mLastFrameNotification = now;
diff --git a/libs/hwui/renderthread/HintSessionWrapper.h b/libs/hwui/renderthread/HintSessionWrapper.h
index b7a433f..24b8150 100644
--- a/libs/hwui/renderthread/HintSessionWrapper.h
+++ b/libs/hwui/renderthread/HintSessionWrapper.h
@@ -42,6 +42,7 @@
APerformanceHintSession* mHintSession = nullptr;
std::future<APerformanceHintSession*> mHintSessionFuture;
+ int mResetsSinceLastReport = 0;
nsecs_t mLastFrameNotification = 0;
nsecs_t mLastTargetWorkDuration = 0;