diff options
| -rw-r--r-- | core/java/android/view/ViewRootImpl.java | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 3cfda571ae6a..a5ce6e0c0b91 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -2854,7 +2854,6 @@ public final class ViewRootImpl implements ViewParent, return; } } - notifySurfaceCreated(); } else if (surfaceDestroyed) { // If the surface has been removed, then reset the scroll // positions. @@ -2894,10 +2893,6 @@ public final class ViewRootImpl implements ViewParent, } } - if (!surfaceCreated && surfaceReplaced) { - notifySurfaceReplaced(); - } - if (mDragResizing != dragResizing) { if (dragResizing) { mResizeMode = freeformResizing @@ -3110,7 +3105,14 @@ public final class ViewRootImpl implements ViewParent, } } - if (surfaceDestroyed) { + // These callbacks will trigger SurfaceView SurfaceHolder.Callbacks and must be invoked + // after the measure pass. If its invoked before the measure pass and the app modifies + // the view hierarchy in the callbacks, we could leave the views in a broken state. + if (surfaceCreated) { + notifySurfaceCreated(); + } else if (surfaceReplaced) { + notifySurfaceReplaced(); + } else if (surfaceDestroyed) { notifySurfaceDestroyed(); } |