Don't reuse LOST_SURFACE for stopped
Fixes: 28218991
If a draw() happens while we are stopped, don't report
that the surface is lost because this will prompt
a tear-down of the surface which isn't desired. It can
result in ViewRootImpl ending up in an internally-bad state
in this case.
Change-Id: If3eb8c6bc8702299e5330bc0917952624dce3b7e
diff --git a/libs/hwui/renderthread/DrawFrameTask.cpp b/libs/hwui/renderthread/DrawFrameTask.cpp
index ed472ac..c9c07b3 100644
--- a/libs/hwui/renderthread/DrawFrameTask.cpp
+++ b/libs/hwui/renderthread/DrawFrameTask.cpp
@@ -32,7 +32,7 @@
DrawFrameTask::DrawFrameTask()
: mRenderThread(nullptr)
, mContext(nullptr)
- , mSyncResult(kSync_OK) {
+ , mSyncResult(SyncResult::OK) {
}
DrawFrameTask::~DrawFrameTask() {
@@ -68,7 +68,7 @@
int DrawFrameTask::drawFrame(TreeObserver* observer) {
LOG_ALWAYS_FATAL_IF(!mContext, "Cannot drawFrame with no CanvasContext!");
- mSyncResult = kSync_OK;
+ mSyncResult = SyncResult::OK;
mSyncQueued = systemTime(CLOCK_MONOTONIC);
mObserver = observer;
postAndWait();
@@ -127,13 +127,18 @@
// This is after the prepareTree so that any pending operations
// (RenderNode tree state, prefetched layers, etc...) will be flushed.
if (CC_UNLIKELY(!mContext->hasSurface() || !canDraw)) {
- mSyncResult |= kSync_LostSurfaceRewardIfFound;
+ if (!mContext->hasSurface()) {
+ mSyncResult |= SyncResult::LostSurfaceRewardIfFound;
+ } else {
+ // If we have a surface but can't draw we must be stopped
+ mSyncResult |= SyncResult::ContextIsStopped;
+ }
info.out.canDrawThisFrame = false;
}
if (info.out.hasAnimations) {
if (info.out.requiresUiRedraw) {
- mSyncResult |= kSync_UIRedrawRequired;
+ mSyncResult |= SyncResult::UIRedrawRequired;
}
}
// If prepareTextures is false, we ran out of texture cache space
diff --git a/libs/hwui/renderthread/DrawFrameTask.h b/libs/hwui/renderthread/DrawFrameTask.h
index 9bba065..c02d376 100644
--- a/libs/hwui/renderthread/DrawFrameTask.h
+++ b/libs/hwui/renderthread/DrawFrameTask.h
@@ -40,11 +40,14 @@
class CanvasContext;
class RenderThread;
-enum SyncResult {
- kSync_OK = 0,
- kSync_UIRedrawRequired = 1 << 0,
- kSync_LostSurfaceRewardIfFound = 1 << 1,
+namespace SyncResult {
+enum {
+ OK = 0,
+ UIRedrawRequired = 1 << 0,
+ LostSurfaceRewardIfFound = 1 << 1,
+ ContextIsStopped = 1 << 2,
};
+}
/*
* This is a special Super Task. It is re-used multiple times by RenderProxy,