diff options
| author | Jorim Jaggi <jjaggi@google.com> | 2020-02-28 01:40:27 +0100 |
|---|---|---|
| committer | Jorim Jaggi <jjaggi@google.com> | 2020-03-11 22:58:59 +0100 |
| commit | 6d5c801c78093cf9ae70139c4e2a2737efbf2359 (patch) | |
| tree | 1d899ad33f03fe8879f6d90917690a5026078b6a /core/java/android/view/WindowManagerGlobal.java | |
| parent | dd3768ed8c2eec2e315e3386f7d75cb9ae8bcdad (diff) | |
Use separate thread if app doesn't listen to animations
There is no need to introduce jank risk and run the inset
animations on the main thread if the app doesn't listen to
animation events. In that case, move the animations onto a
separate thread.
Bug: 118118435
Test: Inspect systrace
Change-Id: Ib6e4b4ce8e9dd8e27761ced6eb8d7700b6236a32
Diffstat (limited to 'core/java/android/view/WindowManagerGlobal.java')
| -rw-r--r-- | core/java/android/view/WindowManagerGlobal.java | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/core/java/android/view/WindowManagerGlobal.java b/core/java/android/view/WindowManagerGlobal.java index 01a1c77d50af..410d9afe73da 100644 --- a/core/java/android/view/WindowManagerGlobal.java +++ b/core/java/android/view/WindowManagerGlobal.java @@ -504,6 +504,7 @@ public final class WindowManagerGlobal { } void doRemoveView(ViewRootImpl root) { + boolean allViewsRemoved; synchronized (mLock) { final int index = mRoots.indexOf(root); if (index >= 0) { @@ -512,10 +513,17 @@ public final class WindowManagerGlobal { final View view = mViews.remove(index); mDyingViews.remove(view); } + allViewsRemoved = mRoots.isEmpty(); } if (ThreadedRenderer.sTrimForeground && ThreadedRenderer.isAvailable()) { doTrimForeground(); } + + // If we don't have any views anymore in our process, we no longer need the + // InsetsAnimationThread to save some resources. + if (allViewsRemoved) { + InsetsAnimationThread.release(); + } } private int findViewLocked(View view, boolean required) { |
