Make sure the relayoutWindow is called when Activity restarted

The host visibility was always invisible while making an Activity
window active because the host visibility was updated afterward
(in ActivityThread#handleStartActivity). Therefore, #relayoutWindow
could be skipped and not recreating Surface if the view visibility is
not changed since last traversal.

Bug: 226324982
Test: repro steps on the bug
Change-Id: Id677a375bc2f75b055a9d35c8b8488e97c24eae9
This commit is contained in:
Louis Chang
2022-06-14 15:53:51 +08:00
parent d7a3e60763
commit 4b91fbf942

View File

@@ -2019,13 +2019,10 @@ public final class ViewRootImpl implements ViewParent,
renderer.setStopped(mStopped);
}
if (!mStopped) {
// Unnecessary to traverse if the window is not yet visible.
if (getHostVisibility() == View.VISIBLE) {
// Make sure that relayoutWindow will be called to get valid surface because
// the previous surface may have been released.
mAppVisibilityChanged = true;
scheduleTraversals();
}
// Make sure that relayoutWindow will be called to get valid surface because
// the previous surface may have been released.
mAppVisibilityChanged = true;
scheduleTraversals();
} else {
if (renderer != null) {
renderer.destroyHardwareResources(mView);