From 6b94a960c0310454eb3f06206bca2e66dc1ba4d9 Mon Sep 17 00:00:00 2001 From: Schneider Victor-tulias Date: Wed, 22 Feb 2023 12:08:21 -0800 Subject: [PATCH] Add debug logs to debug flaky workspace binding Bug: 270216650 Test: ReorderWidgets Change-Id: I6fa2eab98c0268000ef4c44980c2917d5ef1bc89 --- src/com/android/launcher3/Launcher.java | 9 +++++++++ .../android/launcher3/model/BaseLauncherBinder.java | 6 ++++++ .../android/launcher3/testing/shared/TestProtocol.java | 1 + .../android/launcher3/celllayout/ReorderWidgets.java | 10 +++++++++- 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 8e5310172c..7dffd33052 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -1877,6 +1877,9 @@ public class Launcher extends StatefulActivity } private void setWorkspaceLoading(boolean value) { + if (TestProtocol.sDebugTracing) { + Log.d(TestProtocol.FLAKY_BINDING, "running: setWorkspaceLoading=" + value); + } mWorkspaceLoading = value; } @@ -2323,6 +2326,9 @@ public class Launcher extends StatefulActivity */ public void startBinding() { Object traceToken = TraceHelper.INSTANCE.beginSection("startBinding"); + if (TestProtocol.sDebugTracing) { + Log.d(TestProtocol.FLAKY_BINDING, "running: startBinding"); + } // Floating panels (except the full widget sheet) are associated with individual icons. If // we are starting a fresh bind, close all such panels as all the icons are about // to go away. @@ -2795,6 +2801,9 @@ public class Launcher extends StatefulActivity */ public void finishBindingItems(IntSet pagesBoundFirst) { Object traceToken = TraceHelper.INSTANCE.beginSection("finishBindingItems"); + if (TestProtocol.sDebugTracing) { + Log.d(TestProtocol.FLAKY_BINDING, "running: finishBindingItems"); + } mWorkspace.restoreInstanceStateForRemainingPages(); setWorkspaceLoading(false); diff --git a/src/com/android/launcher3/model/BaseLauncherBinder.java b/src/com/android/launcher3/model/BaseLauncherBinder.java index 9f8db51629..8519a3ef52 100644 --- a/src/com/android/launcher3/model/BaseLauncherBinder.java +++ b/src/com/android/launcher3/model/BaseLauncherBinder.java @@ -246,6 +246,9 @@ public abstract class BaseLauncherBinder { sortWorkspaceItemsSpatially(idp, otherWorkspaceItems); // Tell the workspace that we're about to start binding items + if (TestProtocol.sDebugTracing) { + Log.d(TestProtocol.FLAKY_BINDING, "scheduling: startBinding"); + } executeCallbacksTask(c -> { c.clearPendingBinds(); c.startBinding(); @@ -264,6 +267,9 @@ public abstract class BaseLauncherBinder { Executor pendingExecutor = pendingTasks::add; bindWorkspaceItems(otherWorkspaceItems, pendingExecutor); bindAppWidgets(otherAppWidgets, pendingExecutor); + if (TestProtocol.sDebugTracing) { + Log.d(TestProtocol.FLAKY_BINDING, "scheduling: finishBindingItems"); + } executeCallbacksTask(c -> c.finishBindingItems(currentScreenIds), pendingExecutor); pendingExecutor.execute( () -> { diff --git a/tests/shared/com/android/launcher3/testing/shared/TestProtocol.java b/tests/shared/com/android/launcher3/testing/shared/TestProtocol.java index 65873f199e..cc6fa33609 100644 --- a/tests/shared/com/android/launcher3/testing/shared/TestProtocol.java +++ b/tests/shared/com/android/launcher3/testing/shared/TestProtocol.java @@ -154,6 +154,7 @@ public final class TestProtocol { public static final String MISSING_PROMISE_ICON = "b/202985412"; public static final String TASKBAR_IN_APP_STATE = "b/227657604"; public static final String NPE_TRANSIENT_TASKBAR = "b/257549303"; + public static final String FLAKY_BINDING = "b/270216650"; public static final String REQUEST_EMULATE_DISPLAY = "emulate-display"; public static final String REQUEST_STOP_EMULATE_DISPLAY = "stop-emulate-display"; diff --git a/tests/src/com/android/launcher3/celllayout/ReorderWidgets.java b/tests/src/com/android/launcher3/celllayout/ReorderWidgets.java index 77fca96f04..c2fe3de407 100644 --- a/tests/src/com/android/launcher3/celllayout/ReorderWidgets.java +++ b/tests/src/com/android/launcher3/celllayout/ReorderWidgets.java @@ -33,6 +33,7 @@ import com.android.launcher3.celllayout.testcases.ReorderTestCase; import com.android.launcher3.celllayout.testcases.SimpleReorderCase; import com.android.launcher3.tapl.Widget; import com.android.launcher3.tapl.WidgetResizeFrame; +import com.android.launcher3.testing.shared.TestProtocol; import com.android.launcher3.ui.AbstractLauncherUiTest; import com.android.launcher3.ui.TaplTestsLauncher3; import com.android.launcher3.util.rule.ShellCommandRule; @@ -118,7 +119,14 @@ public class ReorderWidgets extends AbstractLauncherUiTest { // waitForLauncherCondition to wait for that condition, otherwise the condition would // always be true and it wouldn't wait for the changes to be applied. resetLoaderState(); - waitForLauncherCondition("Workspace didn't finish loading", l -> !l.isWorkspaceLoading()); + Log.d(TestProtocol.FLAKY_BINDING, "waiting for: isWorkspaceLoading=false"); + waitForLauncherCondition("Workspace didn't finish loading", l -> { + boolean isWorkspaceLoading = l.isWorkspaceLoading(); + + Log.d(TestProtocol.FLAKY_BINDING, "checking: isWorkspaceLoading=" + isWorkspaceLoading); + + return !isWorkspaceLoading; + }); Widget widget = mLauncher.getWorkspace().getWidgetAtCell(mainWidgetCellPos.getCellX(), mainWidgetCellPos.getCellY()); assertNotNull(widget);