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
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user