From da3559683482a61d93b06bed6f46349f6f01dc63 Mon Sep 17 00:00:00 2001 From: John Reck Date: Thu, 24 Jun 2021 17:09:32 -0400 Subject: Delete RenderProxy off of the cleaner thread Speculation for the cause of an ANR. HardwareRenderer's cleaner can block on RenderThread, which in turn blocks ART's cleaner thread. This can potentially cause other blockages, but it's also poor behavior to have such a long-running Cleaner anyway. Avoid this by putting cleanup to CommonPool. Bug: 191514384 Test: make, CtsUiRenderingTestCases still passes Change-Id: I8190f7862528c3ac39ce636f6fca229322480968 --- libs/hwui/renderthread/RenderProxy.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'libs/hwui/renderthread/RenderProxy.cpp') diff --git a/libs/hwui/renderthread/RenderProxy.cpp b/libs/hwui/renderthread/RenderProxy.cpp index c47050c31e9a..8291fa7e4bab 100644 --- a/libs/hwui/renderthread/RenderProxy.cpp +++ b/libs/hwui/renderthread/RenderProxy.cpp @@ -26,6 +26,7 @@ #include "renderthread/CanvasContext.h" #include "renderthread/RenderTask.h" #include "renderthread/RenderThread.h" +#include "thread/CommonPool.h" #include "utils/Macros.h" #include "utils/TimeUtils.h" @@ -42,6 +43,17 @@ RenderProxy::RenderProxy(bool translucent, RenderNode* rootRenderNode, mDrawFrameTask.setContext(&mRenderThread, mContext, rootRenderNode); } +void RenderProxy::asyncDelete(RenderProxy* proxy) { + if (!proxy) return; + + if (proxy->mContext) { + // Use the common pool because ~RenderProxy blocks on calling into RenderThread + CommonPool::post([proxy]() { delete proxy; }); + } else { + delete proxy; + } +} + RenderProxy::~RenderProxy() { destroyContext(); } -- cgit v1.2.3