Loading libs/hwui/renderthread/CanvasContext.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -139,6 +139,7 @@ CanvasContext::~CanvasContext() { mRenderNodes.clear(); mRenderThread.cacheManager().unregisterCanvasContext(this); mRenderThread.renderState().removeContextCallback(this); mHintSessionWrapper->destroy(); } void CanvasContext::addRenderNode(RenderNode* node, bool placeFront) { Loading libs/hwui/renderthread/HintSessionWrapper.cpp +0 −1 Original line number Diff line number Diff line Loading @@ -158,7 +158,6 @@ void HintSessionWrapper::sendLoadResetHint() { void HintSessionWrapper::sendLoadIncreaseHint() { if (!init()) return; mBinding->sendHint(mHintSession, static_cast<int32_t>(SessionHint::CPU_LOAD_UP)); mLastFrameNotification = systemTime(); } bool HintSessionWrapper::alive() { Loading libs/hwui/tests/unit/HintSessionWrapperTests.cpp +57 −2 Original line number Diff line number Diff line Loading @@ -259,6 +259,31 @@ TEST_F(HintSessionWrapperTests, delayedDeletionResolvesAfterAsyncCreationFinishe TEST_F(HintSessionWrapperTests, delayedDeletionDoesNotKillReusedSession) { EXPECT_CALL(*sMockBinding, fakeCloseSession(sessionPtr)).Times(0); EXPECT_CALL(*sMockBinding, fakeReportActualWorkDuration(sessionPtr, 5_ms)).Times(1); mWrapper->init(); waitForWrapperReady(); // Init a second time just to grab the wrapper from the promise mWrapper->init(); EXPECT_EQ(mWrapper->alive(), true); // First schedule the deletion scheduleDelayedDestroyManaged(); // Then, report an actual duration mWrapper->reportActualWorkDuration(5_ms); // Then, run the delayed deletion after sending the update allowDelayedDestructionToStart(); waitForDelayedDestructionToFinish(); // Ensure it didn't close within the timeframe of the test Mock::VerifyAndClearExpectations(sMockBinding.get()); EXPECT_EQ(mWrapper->alive(), true); } TEST_F(HintSessionWrapperTests, loadUpDoesNotResetDeletionTimer) { EXPECT_CALL(*sMockBinding, fakeCloseSession(sessionPtr)).Times(1); EXPECT_CALL(*sMockBinding, fakeSendHint(sessionPtr, static_cast<int32_t>(SessionHint::CPU_LOAD_UP))) .Times(1); Loading @@ -272,16 +297,46 @@ TEST_F(HintSessionWrapperTests, delayedDeletionDoesNotKillReusedSession) { // First schedule the deletion scheduleDelayedDestroyManaged(); // Then, send a hint to update the timestamp // Then, send a load_up hint mWrapper->sendLoadIncreaseHint(); // Then, run the delayed deletion after sending the update allowDelayedDestructionToStart(); waitForDelayedDestructionToFinish(); // Ensure it didn't close within the timeframe of the test // Ensure it closed within the timeframe of the test Mock::VerifyAndClearExpectations(sMockBinding.get()); EXPECT_EQ(mWrapper->alive(), false); } TEST_F(HintSessionWrapperTests, manualSessionDestroyPlaysNiceWithDelayedDestruct) { EXPECT_CALL(*sMockBinding, fakeCloseSession(sessionPtr)).Times(1); mWrapper->init(); waitForWrapperReady(); // Init a second time just to grab the wrapper from the promise mWrapper->init(); EXPECT_EQ(mWrapper->alive(), true); // First schedule the deletion scheduleDelayedDestroyManaged(); // Then, kill the session mWrapper->destroy(); // Verify it died Mock::VerifyAndClearExpectations(sMockBinding.get()); EXPECT_EQ(mWrapper->alive(), false); EXPECT_CALL(*sMockBinding, fakeCloseSession(sessionPtr)).Times(0); // Then, run the delayed deletion after manually killing the session allowDelayedDestructionToStart(); waitForDelayedDestructionToFinish(); // Ensure it didn't close again and is still dead Mock::VerifyAndClearExpectations(sMockBinding.get()); EXPECT_EQ(mWrapper->alive(), false); } } // namespace android::uirenderer::renderthread No newline at end of file Loading
libs/hwui/renderthread/CanvasContext.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -139,6 +139,7 @@ CanvasContext::~CanvasContext() { mRenderNodes.clear(); mRenderThread.cacheManager().unregisterCanvasContext(this); mRenderThread.renderState().removeContextCallback(this); mHintSessionWrapper->destroy(); } void CanvasContext::addRenderNode(RenderNode* node, bool placeFront) { Loading
libs/hwui/renderthread/HintSessionWrapper.cpp +0 −1 Original line number Diff line number Diff line Loading @@ -158,7 +158,6 @@ void HintSessionWrapper::sendLoadResetHint() { void HintSessionWrapper::sendLoadIncreaseHint() { if (!init()) return; mBinding->sendHint(mHintSession, static_cast<int32_t>(SessionHint::CPU_LOAD_UP)); mLastFrameNotification = systemTime(); } bool HintSessionWrapper::alive() { Loading
libs/hwui/tests/unit/HintSessionWrapperTests.cpp +57 −2 Original line number Diff line number Diff line Loading @@ -259,6 +259,31 @@ TEST_F(HintSessionWrapperTests, delayedDeletionResolvesAfterAsyncCreationFinishe TEST_F(HintSessionWrapperTests, delayedDeletionDoesNotKillReusedSession) { EXPECT_CALL(*sMockBinding, fakeCloseSession(sessionPtr)).Times(0); EXPECT_CALL(*sMockBinding, fakeReportActualWorkDuration(sessionPtr, 5_ms)).Times(1); mWrapper->init(); waitForWrapperReady(); // Init a second time just to grab the wrapper from the promise mWrapper->init(); EXPECT_EQ(mWrapper->alive(), true); // First schedule the deletion scheduleDelayedDestroyManaged(); // Then, report an actual duration mWrapper->reportActualWorkDuration(5_ms); // Then, run the delayed deletion after sending the update allowDelayedDestructionToStart(); waitForDelayedDestructionToFinish(); // Ensure it didn't close within the timeframe of the test Mock::VerifyAndClearExpectations(sMockBinding.get()); EXPECT_EQ(mWrapper->alive(), true); } TEST_F(HintSessionWrapperTests, loadUpDoesNotResetDeletionTimer) { EXPECT_CALL(*sMockBinding, fakeCloseSession(sessionPtr)).Times(1); EXPECT_CALL(*sMockBinding, fakeSendHint(sessionPtr, static_cast<int32_t>(SessionHint::CPU_LOAD_UP))) .Times(1); Loading @@ -272,16 +297,46 @@ TEST_F(HintSessionWrapperTests, delayedDeletionDoesNotKillReusedSession) { // First schedule the deletion scheduleDelayedDestroyManaged(); // Then, send a hint to update the timestamp // Then, send a load_up hint mWrapper->sendLoadIncreaseHint(); // Then, run the delayed deletion after sending the update allowDelayedDestructionToStart(); waitForDelayedDestructionToFinish(); // Ensure it didn't close within the timeframe of the test // Ensure it closed within the timeframe of the test Mock::VerifyAndClearExpectations(sMockBinding.get()); EXPECT_EQ(mWrapper->alive(), false); } TEST_F(HintSessionWrapperTests, manualSessionDestroyPlaysNiceWithDelayedDestruct) { EXPECT_CALL(*sMockBinding, fakeCloseSession(sessionPtr)).Times(1); mWrapper->init(); waitForWrapperReady(); // Init a second time just to grab the wrapper from the promise mWrapper->init(); EXPECT_EQ(mWrapper->alive(), true); // First schedule the deletion scheduleDelayedDestroyManaged(); // Then, kill the session mWrapper->destroy(); // Verify it died Mock::VerifyAndClearExpectations(sMockBinding.get()); EXPECT_EQ(mWrapper->alive(), false); EXPECT_CALL(*sMockBinding, fakeCloseSession(sessionPtr)).Times(0); // Then, run the delayed deletion after manually killing the session allowDelayedDestructionToStart(); waitForDelayedDestructionToFinish(); // Ensure it didn't close again and is still dead Mock::VerifyAndClearExpectations(sMockBinding.get()); EXPECT_EQ(mWrapper->alive(), false); } } // namespace android::uirenderer::renderthread No newline at end of file