DO NOT MERGE Fix CtsActivityManagerDeviceTestCases fails

Avoid 'Failed to create EGLSurface for window 0x951b6808, eglErr = EGL_BAD_ALLOC'.
testStackFocusSwitchOnDisplayRemoved, testStackFocusSwitchOnDisplayRemoved2,
testStackFocusSwitchOnDisplayRemoved3 can have the same problem.

When these testcases release the VirtualDisplay, it will trigger
onParentSet() in TaskStackContainers.At that time mBoostedAppAnimationLayer
may be used for animating, and ResizeableActivity is in it. So
mBoostedAppAnimationLayer.destroy() can also destroy the surface of
ResizeableActivity, but at the same time config changed will make
mAttachInfo.mThreadedRenderer.updateSurface(mSurface) of performTraversals()
in ViewRootImpl to update the surface and cause crash like
'Failed to create EGLSurface for window 0x951b6808,eglErr = EGL_BAD_ALLOC'.
So change to use transaction to call destroy() for mBoostedAppAnimationLayer
to delay it, then ResizeableActivity is not in mBoostedAppAnimationLayer
and can test pass.

Bug: 127896059
Test:  run cts-on-gsi -m CtsActivityManagerDeviceTestCases
-t android.server.am.ActivityManagerMultiDisplayTests

Change-Id: I44ee86d1620f9c2953c574146ec6f529ce6f4656
This commit is contained in:
Chuwei Xu
2019-03-22 14:55:55 +08:00
committed by Hung-ying Tyan
parent 507d69d5d9
commit b9932b66e6

View File

@@ -3703,13 +3703,19 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
.show(mSplitScreenDividerAnchor);
scheduleAnimation();
} else {
mAppAnimationLayer.destroy();
// At this time mBoostedAppAnimationLayer may be used for animating,
// and ResizeableActivity is in it. mBoostedAppAnimationLayer.destroy()
// can also destroy the surface of ResizeableActivity, but the surface will
// be used after. So change to use transaction to call destroy to delay it,
// and ResizeableActivity is not in mBoostedAppAnimationLayer.
getPendingTransaction()
.destroy(mAppAnimationLayer)
.destroy(mBoostedAppAnimationLayer)
.destroy(mHomeAppAnimationLayer)
.destroy(mSplitScreenDividerAnchor);
mAppAnimationLayer = null;
mBoostedAppAnimationLayer.destroy();
mBoostedAppAnimationLayer = null;
mHomeAppAnimationLayer.destroy();
mHomeAppAnimationLayer = null;
mSplitScreenDividerAnchor.destroy();
mSplitScreenDividerAnchor = null;
}
}