From 5fc80e7b32a00b4e43b4ce13d60bd82796130182 Mon Sep 17 00:00:00 2001 From: chaviw Date: Thu, 30 Apr 2020 12:14:35 -0700 Subject: [PATCH] Send drawFinish callback even if did not draw There are cases where ViewRootImpl requests to draw, but there was nothing new to draw. In that case, the callback will never be invoked and ViewRootImpl will wait forever. This change will invoke the callback even if there is nothing to draw. It will use the last frameNumber since nothing new has drawn Test: Request draw with nothing new. Callback is invoked Fixes: 155429223 Change-Id: I7c9ed7fd63a451b17133a11ffbcf8fb64be558e5 --- libs/hwui/renderthread/CanvasContext.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp index c19b1878ad45b..335bcdcfc1fb1 100644 --- a/libs/hwui/renderthread/CanvasContext.cpp +++ b/libs/hwui/renderthread/CanvasContext.cpp @@ -440,6 +440,12 @@ void CanvasContext::draw() { if (dirty.isEmpty() && Properties::skipEmptyFrames && !surfaceRequiresRedraw()) { mCurrentFrameInfo->addFlag(FrameInfoFlags::SkippedFrame); + // Notify the callbacks, even if there's nothing to draw so they aren't waiting + // indefinitely + for (auto& func : mFrameCompleteCallbacks) { + std::invoke(func, mFrameNumber); + } + mFrameCompleteCallbacks.clear(); return; }