From 41ef56626842c74e23d0633d7035f5a13156686c Mon Sep 17 00:00:00 2001 From: Greg Daniel Date: Mon, 1 Feb 2021 14:25:48 -0500 Subject: Change CacheManager to not flush and submit at end of trimMemory. The flush and submit at the start of trim memory now syncs the cpu so that all work is done on the gpu and the max possible amount of resources can be freed This fixes CacheManager unit test since the submit at the end trim memory was causing new resources to be available to be purged. Test: locally ran unit tests Bug: 178978639 Change-Id: I8b57b042dd146fc6c1083540715295e93fd113d3 (cherry picked from commit 846644a46e6c5d9bb82382da438a67a067a8a0ce) --- libs/hwui/renderthread/CacheManager.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'libs/hwui/renderthread/CacheManager.cpp') diff --git a/libs/hwui/renderthread/CacheManager.cpp b/libs/hwui/renderthread/CacheManager.cpp index 85924c5e8939..d998e5031984 100644 --- a/libs/hwui/renderthread/CacheManager.cpp +++ b/libs/hwui/renderthread/CacheManager.cpp @@ -101,7 +101,8 @@ void CacheManager::trimMemory(TrimMemoryMode mode) { return; } - mGrContext->flushAndSubmit(); + // flush and submit all work to the gpu and wait for it to finish + mGrContext->flushAndSubmit(/*syncCpu=*/true); switch (mode) { case TrimMemoryMode::Complete: @@ -119,11 +120,6 @@ void CacheManager::trimMemory(TrimMemoryMode mode) { SkGraphics::SetFontCacheLimit(mMaxCpuFontCacheBytes); break; } - - // We must sync the cpu to make sure deletions of resources still queued up on the GPU actually - // happen. - mGrContext->flush({}); - mGrContext->submit(true); } void CacheManager::trimStaleResources() { -- cgit v1.2.3