From 80923d5913f0cf42cf353a44fc533aa4936a1d6e Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Thu, 19 Apr 2018 13:05:08 -0700 Subject: ViewRoot: Check Surface validity before initializing renderer from draw(). Imagine we have a ViewRoot for a PopupWindow so it's view visibility will not directly be affected by the stopped state, but we still will end up destroying the surface. We could see a handler queue like this: ("handleStopped", "performTraversals"). If there were no size changes we won't call relayout and we won't notice we have lost the Surface and it seems there is nothing to prevent us from continuing in to draw. However, if we have handled STOP then the surface is now destroyed. Ensure we respect the stop signal and the released state it sets on the Surface. The original intent of this code-path should be preserved in the case that the client receives a new surface from relayout even if it hasn't yet received setWindowStopped(false). Bug: 62536731 Test: Manual Change-Id: I0eccd4dbfd00f9f61ad37086299f986463082a1f --- core/java/android/view/ViewRootImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'core/java/android/view/ViewRootImpl.java') diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 19ead600e2dc..4bd6fc8b665f 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -3272,7 +3272,8 @@ public final class ViewRootImpl implements ViewParent, // eglTerminate() for instance. if (mAttachInfo.mThreadedRenderer != null && !mAttachInfo.mThreadedRenderer.isEnabled() && - mAttachInfo.mThreadedRenderer.isRequested()) { + mAttachInfo.mThreadedRenderer.isRequested() && + mSurface.isValid()) { try { mAttachInfo.mThreadedRenderer.initializeIfNeeded( -- cgit v1.2.3