summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Matt Buckley <mattbuckley@google.com> 2023-09-26 19:30:25 +0000
committer Matt Buckley <mattbuckley@google.com> 2023-09-26 21:34:11 +0000
commit1b99d78960682dca27c8d234b48263a54fd223ec (patch)
tree531938d1903e5b7b6e8ea2607c6868e39dab395a
parentcab681542a0710c0308415d78686b7e31edefb64 (diff)
Send cached target duration when creating sessions
This fixes an issue where the default target duration was being sent when re-creating sessions, after the true target duration was already known. This caused the wrong value in PowerHAL, and no corrective update was sent because the cached value never changed. Bug: 301806277 Test: hwuitest Change-Id: I80d90e855fce92264d8341aad78b19dc547b65f4
-rw-r--r--libs/hwui/renderthread/HintSessionWrapper.cpp12
-rw-r--r--libs/hwui/renderthread/HintSessionWrapper.h1
2 files changed, 8 insertions, 5 deletions
diff --git a/libs/hwui/renderthread/HintSessionWrapper.cpp b/libs/hwui/renderthread/HintSessionWrapper.cpp
index d1ebe6d9f576..1c3399a6650d 100644
--- a/libs/hwui/renderthread/HintSessionWrapper.cpp
+++ b/libs/hwui/renderthread/HintSessionWrapper.cpp
@@ -72,6 +72,7 @@ void HintSessionWrapper::destroy() {
mSessionValid = true;
mHintSession = nullptr;
}
+ mResetsSinceLastReport = 0;
}
bool HintSessionWrapper::init() {
@@ -109,12 +110,13 @@ bool HintSessionWrapper::init() {
tids.push_back(mUiThreadId);
tids.push_back(mRenderThreadId);
- // Use a placeholder target value to initialize,
- // this will always be replaced elsewhere before it gets used
- int64_t defaultTargetDurationNanos = 16666667;
+ // Use the cached target value if there is one, otherwise use a default. This is to ensure
+ // the cached target and target in PowerHAL are consistent, and that it updates correctly
+ // whenever there is a change.
+ int64_t targetDurationNanos =
+ mLastTargetWorkDuration == 0 ? kDefaultTargetDuration : mLastTargetWorkDuration;
mHintSessionFuture = CommonPool::async([=, this, tids = std::move(tids)] {
- return mBinding->createSession(manager, tids.data(), tids.size(),
- defaultTargetDurationNanos);
+ return mBinding->createSession(manager, tids.data(), tids.size(), targetDurationNanos);
});
return false;
}
diff --git a/libs/hwui/renderthread/HintSessionWrapper.h b/libs/hwui/renderthread/HintSessionWrapper.h
index 36e91ea33c75..41891cd80a42 100644
--- a/libs/hwui/renderthread/HintSessionWrapper.h
+++ b/libs/hwui/renderthread/HintSessionWrapper.h
@@ -65,6 +65,7 @@ private:
static constexpr nsecs_t kResetHintTimeout = 100_ms;
static constexpr int64_t kSanityCheckLowerBound = 100_us;
static constexpr int64_t kSanityCheckUpperBound = 10_s;
+ static constexpr int64_t kDefaultTargetDuration = 16666667;
// Allows easier stub when testing
class HintSessionBinding {