[DO NOT MERGE] Revert "Mitigation for mass GC deletion"
Revert submission 24828717
Reason for revert: performance concerns
Reverted changes: /q/submissionid:24828717
Bug: 300360668
Bug: 302620048
Change-Id: Iefb7488f6e100ca7cbb0d43337e5830860ebebe5
diff --git a/libs/hwui/renderthread/HintSessionWrapper.cpp b/libs/hwui/renderthread/HintSessionWrapper.cpp
index d1ebe6d..b34da51 100644
--- a/libs/hwui/renderthread/HintSessionWrapper.cpp
+++ b/libs/hwui/renderthread/HintSessionWrapper.cpp
@@ -24,7 +24,6 @@
#include <vector>
#include "../Properties.h"
-#include "RenderThread.h"
#include "thread/CommonPool.h"
using namespace std::chrono_literals;
@@ -63,9 +62,8 @@
}
void HintSessionWrapper::destroy() {
- if (mHintSessionFuture.has_value()) {
- mHintSession = mHintSessionFuture->get();
- mHintSessionFuture = std::nullopt;
+ if (mHintSessionFuture.valid()) {
+ mHintSession = mHintSessionFuture.get();
}
if (mHintSession) {
mBinding->closeSession(mHintSession);
@@ -76,12 +74,12 @@
bool HintSessionWrapper::init() {
if (mHintSession != nullptr) return true;
+
// If we're waiting for the session
- if (mHintSessionFuture.has_value()) {
+ if (mHintSessionFuture.valid()) {
// If the session is here
- if (mHintSessionFuture->wait_for(0s) == std::future_status::ready) {
- mHintSession = mHintSessionFuture->get();
- mHintSessionFuture = std::nullopt;
+ if (mHintSessionFuture.wait_for(0s) == std::future_status::ready) {
+ mHintSession = mHintSessionFuture.get();
if (mHintSession != nullptr) {
mSessionValid = true;
return true;
@@ -138,7 +136,6 @@
actualDurationNanos < kSanityCheckUpperBound) {
mBinding->reportActualWorkDuration(mHintSession, actualDurationNanos);
}
- mLastFrameNotification = systemTime();
}
void HintSessionWrapper::sendLoadResetHint() {
@@ -156,28 +153,6 @@
void HintSessionWrapper::sendLoadIncreaseHint() {
if (!init()) return;
mBinding->sendHint(mHintSession, static_cast<int32_t>(SessionHint::CPU_LOAD_UP));
- mLastFrameNotification = systemTime();
-}
-
-bool HintSessionWrapper::alive() {
- return mHintSession != nullptr;
-}
-
-nsecs_t HintSessionWrapper::getLastUpdate() {
- return mLastFrameNotification;
-}
-
-// Requires passing in its shared_ptr since it shouldn't own a shared_ptr to itself
-void HintSessionWrapper::delayedDestroy(RenderThread& rt, nsecs_t delay,
- std::shared_ptr<HintSessionWrapper> wrapperPtr) {
- nsecs_t lastUpdate = wrapperPtr->getLastUpdate();
- rt.queue().postDelayed(delay, [lastUpdate = lastUpdate, wrapper = wrapperPtr]() mutable {
- if (wrapper->getLastUpdate() == lastUpdate) {
- wrapper->destroy();
- }
- // Ensure the shared_ptr is killed at the end of the method
- wrapper = nullptr;
- });
}
} /* namespace renderthread */