diff options
| author | Robert Carr <racarr@google.com> | 2020-06-19 13:14:00 -0700 |
|---|---|---|
| committer | Robert Carr <racarr@google.com> | 2020-06-19 13:14:00 -0700 |
| commit | 7a31b8b1df353e2a8c5245b645bb1c836e37c51a (patch) | |
| tree | 424559eca161a4a3202bcfdcc8f374b12962eed8 /core/java/android | |
| parent | 5409e24105ba32dc524a78b9be3d0f2d3beef69a (diff) | |
SurfaceControlViewHost: Release ViewRoot from finalizer
If we don't explicitly go through the doDie process the
WindowManagerGlobal instance will hold the ViewRoot alive
indefinitely. This accidental leak could be very expensive so
we prevent it with a finalizer.
Bug: 157709599
Test: Existing tests pass
Change-Id: I4fdf368eed4b4e43faacd9f62b6d9fddfd9b7ef2
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/view/SurfaceControlViewHost.java | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/core/java/android/view/SurfaceControlViewHost.java b/core/java/android/view/SurfaceControlViewHost.java index df4c084e7349..86a4fe170387 100644 --- a/core/java/android/view/SurfaceControlViewHost.java +++ b/core/java/android/view/SurfaceControlViewHost.java @@ -178,6 +178,17 @@ public class SurfaceControlViewHost { } /** + * @hide + */ + @Override + protected void finalize() throws Throwable { + // We aren't on the UI thread here so we need to pass false to + // doDie + mViewRoot.die(false /* immediate */); + } + + + /** * Return a SurfacePackage for the root SurfaceControl of the embedded hierarchy. * Rather than be directly reparented using {@link SurfaceControl.Transaction} this * SurfacePackage should be passed to {@link SurfaceView#setChildSurfacePackage} |
