From c35411ccabe0bac5d1bbe159a3140a659985ebd0 Mon Sep 17 00:00:00 2001 From: Chandru S Date: Tue, 28 Jan 2025 21:34:35 +0000 Subject: Explicitly use main dispatcher for the window root view blurs The plan is to submit this CL and then move the flag to staging again, get new jank metrics and see how much it improves jank compared to the previous flag flip. Bug: 392240569 Flag: com.android.systemui.bouncer_ui_revamp Test: NA, everything builds, blur works. Change-Id: Ie6de9b15b7291dbc5b07e4fb417e1529ad0fcb36 --- .../android/systemui/shade/NotificationShadeWindowViewTest.kt | 2 ++ .../systemui/shade/NotificationShadeWindowViewController.java | 10 ++++++++-- .../src/com/android/systemui/window/ui/WindowRootViewBinder.kt | 4 +++- .../shade/NotificationShadeWindowViewControllerTest.kt | 1 + 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationShadeWindowViewTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationShadeWindowViewTest.kt index 555c717e1e65..93d1f593e81f 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationShadeWindowViewTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationShadeWindowViewTest.kt @@ -78,6 +78,7 @@ import java.util.Optional import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.emptyFlow import kotlinx.coroutines.test.TestScope +import kotlinx.coroutines.test.UnconfinedTestDispatcher import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Test @@ -220,6 +221,7 @@ class NotificationShadeWindowViewTest : SysuiTestCase() { mock(), { configurationForwarder }, brightnessMirrorShowingInteractor, + UnconfinedTestDispatcher(), ) controller.setupExpandedStatusBar() diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowViewController.java index 255494f014e3..10a9fd20ee5a 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowViewController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowViewController.java @@ -45,6 +45,7 @@ import com.android.systemui.bouncer.shared.flag.ComposeBouncerFlags; import com.android.systemui.bouncer.ui.binder.BouncerViewBinder; import com.android.systemui.classifier.FalsingCollector; import com.android.systemui.dagger.SysUISingleton; +import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dock.DockManager; import com.android.systemui.dump.DumpManager; import com.android.systemui.flags.FeatureFlagsClassic; @@ -87,6 +88,8 @@ import com.android.systemui.util.time.SystemClock; import com.android.systemui.window.ui.WindowRootViewBinder; import com.android.systemui.window.ui.viewmodel.WindowRootViewModel; +import kotlinx.coroutines.CoroutineDispatcher; +import kotlinx.coroutines.ExperimentalCoroutinesApi; import kotlinx.coroutines.flow.Flow; import java.io.PrintWriter; @@ -119,6 +122,7 @@ public class NotificationShadeWindowViewController implements Dumpable { private final PrimaryBouncerInteractor mPrimaryBouncerInteractor; private final AlternateBouncerInteractor mAlternateBouncerInteractor; private final QuickSettingsController mQuickSettingsController; + private final CoroutineDispatcher mMainDispatcher; private final KeyguardTransitionInteractor mKeyguardTransitionInteractor; private final GlanceableHubContainerController mGlanceableHubContainerController; @@ -204,7 +208,8 @@ public class NotificationShadeWindowViewController implements Dumpable { AlternateBouncerInteractor alternateBouncerInteractor, BouncerViewBinder bouncerViewBinder, @ShadeDisplayAware Provider configurationForwarder, - BrightnessMirrorShowingInteractor brightnessMirrorShowingInteractor) { + BrightnessMirrorShowingInteractor brightnessMirrorShowingInteractor, + @Main CoroutineDispatcher mainDispatcher) { mLockscreenShadeTransitionController = transitionController; mFalsingCollector = falsingCollector; mStatusBarStateController = statusBarStateController; @@ -232,6 +237,7 @@ public class NotificationShadeWindowViewController implements Dumpable { mPrimaryBouncerInteractor = primaryBouncerInteractor; mAlternateBouncerInteractor = alternateBouncerInteractor; mQuickSettingsController = quickSettingsController; + mMainDispatcher = mainDispatcher; // This view is not part of the newly inflated expanded status bar. mBrightnessMirror = mView.findViewById(R.id.brightness_mirror_container); @@ -286,7 +292,7 @@ public class NotificationShadeWindowViewController implements Dumpable { if (SceneContainerFlag.isEnabled()) return; WindowRootViewBinder.INSTANCE.bind(mView, windowRootViewModelFactory, blurUtils, - choreographer); + choreographer, mMainDispatcher); } private void bindBouncer(BouncerViewBinder bouncerViewBinder) { diff --git a/packages/SystemUI/src/com/android/systemui/window/ui/WindowRootViewBinder.kt b/packages/SystemUI/src/com/android/systemui/window/ui/WindowRootViewBinder.kt index 7f4bfb094a7b..e09a74cd0ad3 100644 --- a/packages/SystemUI/src/com/android/systemui/window/ui/WindowRootViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/window/ui/WindowRootViewBinder.kt @@ -26,6 +26,7 @@ import com.android.systemui.lifecycle.viewModel import com.android.systemui.scene.ui.view.WindowRootView import com.android.systemui.statusbar.BlurUtils import com.android.systemui.window.ui.viewmodel.WindowRootViewModel +import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.awaitCancellation import kotlinx.coroutines.flow.filter import kotlinx.coroutines.launch @@ -42,11 +43,12 @@ object WindowRootViewBinder { viewModelFactory: WindowRootViewModel.Factory, blurUtils: BlurUtils?, choreographer: Choreographer?, + mainDispatcher: CoroutineDispatcher, ) { if (!Flags.bouncerUiRevamp() && !Flags.glanceableHubBlurredBackground()) return if (blurUtils == null || choreographer == null) return - view.repeatWhenAttached { + view.repeatWhenAttached(mainDispatcher) { Log.d(TAG, "Binding root view") var frameCallbackPendingExecution: FrameCallback? = null view.viewModel( diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowViewControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowViewControllerTest.kt index 70450d29c74e..49d6909c1f93 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowViewControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowViewControllerTest.kt @@ -254,6 +254,7 @@ class NotificationShadeWindowViewControllerTest(flags: FlagsParameterization) : mock(BouncerViewBinder::class.java), { mock(ConfigurationForwarder::class.java) }, brightnessMirrorShowingInteractor, + kosmos.testDispatcher, ) underTest.setupExpandedStatusBar() underTest.setDragDownHelper(dragDownHelper) -- cgit v1.2.3-59-g8ed1b