From: Chong Zhang Date: Thu, 14 Jul 2016 22:09:12 +0000 (-0700) Subject: Don't release surface if relayout is visible X-Git-Tag: android-x86-7.1-r1~3341^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=546fd255d4ef5481088243b94a7c6929cd9e2779;p=android-x86%2Fframeworks-base.git Don't release surface if relayout is visible There is a delay from the point we notify the client to go invisible, to the point that request is handled. If a relayout VISIBLE happens during this period, we need to give the client a surface so that any pending draws will go through. bug: 30066966 Change-Id: I0cd4e4be49f3d2d8f726963ed9e23bf0327e1d0f --- diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 84788cfda4da..1b893270b62b 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -2907,9 +2907,23 @@ public class WindowManagerService extends IWindowManager.Stub } result |= RELAYOUT_RES_SURFACE_CHANGED; } + final WindowSurfaceController surfaceController = winAnimator.mSurfaceController; + if (viewVisibility == View.VISIBLE && surfaceController != null) { + // We already told the client to go invisible, but the message may not be + // handled yet, or it might want to draw a last frame. If we already have a + // surface, let the client use that, but don't create new surface at this point. + surfaceController.getSurface(outSurface); + } else { + if (DEBUG_VISIBILITY) Slog.i(TAG_WM, "Releasing surface in: " + win); - outSurface.release(); - if (DEBUG_VISIBILITY) Slog.i(TAG_WM, "Releasing surface in: " + win); + try { + Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "wmReleaseOutSurface_" + + win.mAttrs.getTitle()); + outSurface.release(); + } finally { + Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER); + } + } } if (focusMayChange) { @@ -3044,6 +3058,7 @@ public class WindowManagerService extends IWindowManager.Stub } else { // For some reason there isn't a surface. Clear the // caller's object so they see the same state. + Slog.w(TAG_WM, "Failed to create surface control for " + win); outSurface.release(); } return result;