summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Zuccarini <acul@google.com>2023-06-15 13:15:55 +0000
committerLuca Zuccarini <acul@google.com>2023-06-15 13:15:55 +0000
commit103188a89c2e143d93a22a8e55f5ead46ee4b7ad (patch)
tree79443b05eea4eca55fd5d87ab8b55985cf44e7ba
parentd2e06de8053d8785eff42faaad3650d5070e9eec (diff)
downloadbase-103188a89c2e143d93a22a8e55f5ead46ee4b7ad.tar.gz
Avoid refreshing the media output dialog UI while dismissing.
refresh() currently performs several binder calls on the UI thread. During launch of the dialog this happens before the animation, so while there is a slight delay there are no frame drops. However when closing the dialog the call happens after the animation has already started, causing it to stutter significantly. The proper fix would be to rearchitect this dialog so that state can be loaded ahead of time and in the background, so the UI can start off pre-populated and updates can come in whenever available. This would be a risky change at this point in the U release cycle, and I'm not familiar with the code enough to write it confidently, so for now simply avoiding the updates if the dialog is dismissing removes the jank, though it is only a band-aid. Bug: 287191450 Flag: N/A Test: see videos in the bug Change-Id: If25937c86499b947a2f0d9971783f153f8e1a743
-rw-r--r--packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseDialog.java22
1 files changed, 17 insertions, 5 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseDialog.java b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseDialog.java
index 0a5b4b3066a0..7712690de195 100644
--- a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseDialog.java
+++ b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseDialog.java
@@ -105,6 +105,7 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
private WallpaperColors mWallpaperColors;
private boolean mShouldLaunchLeBroadcastDialog;
private boolean mIsLeBroadcastCallbackRegistered;
+ private boolean mDismissing;
MediaOutputBaseAdapter mAdapter;
@@ -265,13 +266,22 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
mDevicesRecyclerView.setHasFixedSize(false);
// Init bottom buttons
mDoneButton.setOnClickListener(v -> dismiss());
- mStopButton.setOnClickListener(v -> {
- mMediaOutputController.releaseSession();
- dismiss();
- });
+ mStopButton.setOnClickListener(v -> onStopButtonClick());
mAppButton.setOnClickListener(mMediaOutputController::tryToLaunchMediaApplication);
mMediaMetadataSectionLayout.setOnClickListener(
mMediaOutputController::tryToLaunchMediaApplication);
+
+ mDismissing = false;
+ }
+
+ @Override
+ public void dismiss() {
+ // TODO(287191450): remove this once expensive binder calls are removed from refresh().
+ // Due to these binder calls on the UI thread, calling refresh() during dismissal causes
+ // significant frame drops for the dismissal animation. Since the dialog is going away
+ // anyway, we use this state to turn refresh() into a no-op.
+ mDismissing = true;
+ super.dismiss();
}
@Override
@@ -299,7 +309,9 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
}
void refresh(boolean deviceSetChanged) {
- if (mMediaOutputController.isRefreshing()) {
+ // TODO(287191450): remove binder calls in this method from the UI thread.
+ // If the dialog is going away or is already refreshing, do nothing.
+ if (mDismissing || mMediaOutputController.isRefreshing()) {
return;
}
mMediaOutputController.setRefreshing(true);