From 9e3cd0533fa4dbca75d65750f9ffcd9817779c3c Mon Sep 17 00:00:00 2001 From: chaviw Date: Tue, 31 May 2022 13:48:56 -0500 Subject: [PATCH] Remove lock when calling Surface.destroy Surface already has a lock on the native object so it's safe to call destroy without holding additional locks. This also fixes ANR issues where an app is still attempting to render when the window is destroyed. Test: App from bug doesn't ANR Bug: 234006724 Change-Id: I0d323c03f299e5857d1950870498f3182d019924 --- core/java/android/view/SurfaceView.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java index 2e48c2b77233c..7e264cea46bb4 100644 --- a/core/java/android/view/SurfaceView.java +++ b/core/java/android/view/SurfaceView.java @@ -719,13 +719,8 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall private void releaseSurfaces(boolean releaseSurfacePackage) { mSurfaceAlpha = 1f; - - mSurfaceLock.lock(); - try { - mSurface.destroy(); - } finally { - mSurfaceLock.unlock(); - } + mSurface.destroy(); + synchronized (mSurfaceControlLock) { if (mBlastBufferQueue != null) { mBlastBufferQueue.destroy();