Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c4edf383 authored by Gustav Sennton's avatar Gustav Sennton
Browse files

Use longer timeout for Desktop drag/resize CUJs

Before this CL, when measuring a Desktop drag or resize jank CUJ we
would often accidentally hit the default timeout (2 seconds) when the
user drags or resizes a window. When we hit the timeout for a CUJ that
CUJ would not be recorded.

With this CL we increase the timeout to 10 seconds for the following
CUJs, so that we're less likely to hit the timeout:
- CUJ_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG_HOLD
- CUJ_DESKTOP_MODE_RESIZE_WINDOW
- CUJ_DESKTOP_MODE_DRAG_WINDOW

Test: manual; perfetto, ensure long drag/resize events are recorded
Bug: 381025128
Flag: com.android.window.flags.enable_desktop_windowing_mode
Change-Id: Ia9a79c8d4014845c4176c344f01695ae5f60c9be
parent 3cf71b7e
Loading
Loading
Loading
Loading
+14 −6
Original line number Diff line number Diff line
@@ -136,6 +136,7 @@ import com.android.wm.shell.windowdecor.tiling.DesktopTilingDecorViewModel
import java.io.PrintWriter
import java.util.Optional
import java.util.concurrent.Executor
import java.util.concurrent.TimeUnit
import java.util.function.Consumer

/** Handles moving tasks in and out of desktop */
@@ -465,12 +466,15 @@ class DesktopTasksController(
        taskSurface: SurfaceControl,
    ) {
        logV("startDragToDesktop taskId=%d", taskInfo.taskId)
        interactionJankMonitor.begin(
            taskSurface,
        val jankConfigBuilder =
            InteractionJankMonitor.Configuration.Builder.withSurface(
                    CUJ_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG_HOLD,
                    context,
                    taskSurface,
                    handler,
            CUJ_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG_HOLD,
                )
                .setTimeout(APP_HANDLE_DRAG_HOLD_CUJ_TIMEOUT_MS)
        interactionJankMonitor.begin(jankConfigBuilder)
        dragToDesktopTransitionHandler.startDragToDesktopTransition(
            taskInfo.taskId,
            dragToDesktopValueAnimator,
@@ -2635,6 +2639,10 @@ class DesktopTasksController(
        val DESKTOP_MODE_INITIAL_BOUNDS_SCALE =
            SystemProperties.getInt("persist.wm.debug.desktop_mode_initial_bounds_scale", 75) / 100f

        // Timeout used for CUJ_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG_HOLD, this is longer than the
        // default timeout to avoid timing out in the middle of a drag action.
        private val APP_HANDLE_DRAG_HOLD_CUJ_TIMEOUT_MS: Long = TimeUnit.SECONDS.toMillis(10L)

        private const val TAG = "DesktopTasksController"
    }

+17 −4
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.window.WindowContainerTransaction;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.android.internal.jank.Cuj;
import com.android.internal.jank.InteractionJankMonitor;
import com.android.wm.shell.ShellTaskOrganizer;
import com.android.wm.shell.common.DisplayController;
@@ -44,6 +45,7 @@ import com.android.wm.shell.shared.annotations.ShellMainThread;
import com.android.wm.shell.transition.Transitions;

import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;

/**
@@ -53,6 +55,9 @@ import java.util.function.Supplier;
 * If the drag is repositioning, we update in the typical manner.
 */
public class VeiledResizeTaskPositioner implements TaskPositioner, Transitions.TransitionHandler {
    // Timeout used for resize and drag CUJs, this is longer than the default timeout to avoid
    // timing out in the middle of a resize or drag action.
    private static final long LONG_CUJ_TIMEOUT_MS = TimeUnit.SECONDS.toMillis(10L);

    private DesktopModeWindowDecoration mDesktopWindowDecoration;
    private ShellTaskOrganizer mTaskOrganizer;
@@ -106,8 +111,8 @@ public class VeiledResizeTaskPositioner implements TaskPositioner, Transitions.T
        mRepositionStartPoint.set(x, y);
        if (isResizing()) {
            // Capture CUJ for re-sizing window in DW mode.
            mInteractionJankMonitor.begin(mDesktopWindowDecoration.mTaskSurface,
                    mDesktopWindowDecoration.mContext, mHandler, CUJ_DESKTOP_MODE_RESIZE_WINDOW);
            mInteractionJankMonitor.begin(
                    createLongTimeoutJankConfigBuilder(CUJ_DESKTOP_MODE_RESIZE_WINDOW));
            if (!mDesktopWindowDecoration.mHasGlobalFocus) {
                WindowContainerTransaction wct = new WindowContainerTransaction();
                wct.reorder(mDesktopWindowDecoration.mTaskInfo.token, true /* onTop */,
@@ -153,8 +158,8 @@ public class VeiledResizeTaskPositioner implements TaskPositioner, Transitions.T
            }
        } else if (mCtrlType == CTRL_TYPE_UNDEFINED) {
            // Begin window drag CUJ instrumentation only when drag position moves.
            mInteractionJankMonitor.begin(mDesktopWindowDecoration.mTaskSurface,
                    mDesktopWindowDecoration.mContext, mHandler, CUJ_DESKTOP_MODE_DRAG_WINDOW);
            mInteractionJankMonitor.begin(
                    createLongTimeoutJankConfigBuilder(CUJ_DESKTOP_MODE_DRAG_WINDOW));
            final SurfaceControl.Transaction t = mTransactionSupplier.get();
            DragPositioningCallbackUtility.setPositionOnDrag(mDesktopWindowDecoration,
                    mRepositionTaskBounds, mTaskBoundsAtDragStart, mRepositionStartPoint, t, x, y);
@@ -207,6 +212,14 @@ public class VeiledResizeTaskPositioner implements TaskPositioner, Transitions.T
        }
    }

    private InteractionJankMonitor.Configuration.Builder createLongTimeoutJankConfigBuilder(
            @Cuj.CujType int cujType) {
        return InteractionJankMonitor.Configuration.Builder
                .withSurface(cujType, mDesktopWindowDecoration.mContext,
                        mDesktopWindowDecoration.mTaskSurface, mHandler)
                .setTimeout(LONG_CUJ_TIMEOUT_MS);
    }

    @Override
    public boolean startAnimation(@NonNull IBinder transition, @NonNull TransitionInfo info,
            @NonNull SurfaceControl.Transaction startTransaction,