Flush mPostDrawTransaction when WSA is torn down

When ViewRootImpl gets a sync request from WM, it will wait until it
gets a transaction complete callback before continuing. This means WM
must apply the transaction that contains the buffer. In this case, the
finishDraw was racing the WSA getting marked as hidden. When WSA is
hidden, we don't apply the transaction right away in case we want to
synchronize with some initial properties. So for this case, the buffer
was never getting submitted.

Instead, apply mPostDrawTransaction when the WSA SurfaceControl is
getting destroyed to ensure we don't leave any pending transactions when
getitng torn down.

Test: Pip, rotate to landscape, dismiss, re-open app in portrait
Fixes: 191151909
Change-Id: I00606c0ed250a10e1651c403665f39be52e9a89e
This commit is contained in:
chaviw
2021-06-24 16:19:04 -05:00
parent 0acf11a23d
commit 7da389fc6c

View File

@@ -16,12 +16,6 @@
package com.android.server.wm;
import static android.graphics.Matrix.MSCALE_X;
import static android.graphics.Matrix.MSCALE_Y;
import static android.graphics.Matrix.MSKEW_X;
import static android.graphics.Matrix.MSKEW_Y;
import static android.graphics.Matrix.MTRANS_X;
import static android.graphics.Matrix.MTRANS_Y;
import static android.view.WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
@@ -54,14 +48,12 @@ import static com.android.server.wm.WindowStateAnimatorProto.SURFACE;
import static com.android.server.wm.WindowStateAnimatorProto.SYSTEM_DECOR_RECT;
import android.content.Context;
import android.graphics.Matrix;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.os.Debug;
import android.os.Trace;
import android.util.Slog;
import android.util.proto.ProtoOutputStream;
import android.view.DisplayInfo;
import android.view.Surface.OutOfResourcesException;
import android.view.SurfaceControl;
import android.view.WindowManager;
@@ -260,7 +252,10 @@ class WindowStateAnimator {
}
if (postDrawTransaction != null) {
if (mLastHidden) {
// If there is no surface, the last draw was for the previous surface. We don't want to
// wait until the new surface is shown and instead just apply the transaction right
// away.
if (mLastHidden && mDrawState != NO_SURFACE) {
mPostDrawTransaction.merge(postDrawTransaction);
layoutNeeded = true;
} else {
@@ -830,6 +825,10 @@ class WindowStateAnimator {
}
void destroySurface(SurfaceControl.Transaction t) {
// Since the SurfaceControl is getting torn down, it's safe to just clean up any
// pending transactions that were in mPostDrawTransaction, as well.
t.merge(mPostDrawTransaction);
try {
if (mSurfaceController != null) {
mSurfaceController.destroy(t);