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

Commit 7dd9577c authored by Jorge Gil's avatar Jorge Gil
Browse files

Defer loading decoration app icon/name until it's needed

To avoid jank during an app launch, defer loading the app info used in
the veil/handle menu/window header until it's actually about to be
shown.

Bug: 335975211
Test: in perfetto trace - check loadAppInfo trace isn't present during
split launch

Change-Id: I2277a4c5034fdf1ec31bba79091ca89e1f9b090a
parent 73cf528d
Loading
Loading
Loading
Loading
+27 −20
Original line number Diff line number Diff line
@@ -154,15 +154,10 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
                surfaceControlBuilderSupplier, surfaceControlTransactionSupplier,
                windowContainerTransactionSupplier, surfaceControlSupplier,
                surfaceControlViewHostFactory);

        mHandler = handler;
        mChoreographer = choreographer;
        mSyncQueue = syncQueue;
        mRootTaskDisplayAreaOrganizer = rootTaskDisplayAreaOrganizer;

        Trace.beginSection("DesktopModeWindowDecoration#loadAppInfo");
        loadAppInfo();
        Trace.endSection();
    }

    void setCaptionListeners(
@@ -245,6 +240,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
                );
            } else if (mRelayoutParams.mLayoutResId
                    == R.layout.desktop_mode_app_controls_window_decor) {
                loadAppInfoIfNeeded();
                mWindowDecorViewHolder = new DesktopModeAppControlsWindowDecorationViewHolder(
                        mResult.mRootView,
                        mOnCaptionTouchListener,
@@ -457,7 +453,13 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
        return mDragResizeListener != null && mDragResizeListener.isHandlingDragResize();
    }

    private void loadAppInfo() {
    private void loadAppInfoIfNeeded() {
        // TODO(b/337370277): move this to another thread.
        try {
            Trace.beginSection("DesktopModeWindowDecoration#loadAppInfoIfNeeded");
            if (mAppIconBitmap != null && mAppName != null) {
                return;
            }
            final ActivityInfo activityInfo = mTaskInfo.topActivityInfo;
            if (activityInfo == null) {
                Log.e(TAG, "Top activity info not found in task");
@@ -473,6 +475,9 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
            mAppIconBitmap = factory.createScaledBitmap(appIconDrawable, MODE_DEFAULT);
            final ApplicationInfo applicationInfo = activityInfo.applicationInfo;
            mAppName = pm.getApplicationLabel(applicationInfo);
        } finally {
            Trace.endSection();
        }
    }

    private void closeDragResizeListener() {
@@ -489,6 +494,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
     */
    private void createResizeVeilIfNeeded() {
        if (mResizeVeil != null) return;
        loadAppInfoIfNeeded();
        mResizeVeil = new ResizeVeil(mContext, mDisplayController, mAppIconBitmap, mTaskInfo,
                mTaskSurface, mSurfaceControlTransactionSupplier);
    }
@@ -625,6 +631,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
     * Create and display handle menu window.
     */
    void createHandleMenu() {
        loadAppInfoIfNeeded();
        mHandleMenu = new HandleMenu.Builder(this)
                .setAppIcon(mAppIconBitmap)
                .setAppName(mAppName)