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

Commit 08b2373d authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Revert^2 "Explicitly release all surfaces after transition completed"

This reverts commit 57e14c67.
The original reason to revert was fixed in commit c152918c.

Also skip InteractionJankMonitor if there are no animations to run.
Otherwise it may throw exception for a released surface.

Reason for revert: reland

Bug: 407719374
Bug: 403036597
Bug: 300499147
Flag: com.android.window.flags.release_surface_on_transition_finish
Test: Dump offscreen layer after removing Task from Recents
      adb shell dumpsys SurfaceFlinger | grep Offscreen -A50

Change-Id: I32dee21f90f72b9e9efe101af40c731d0141a5e9
parent a65d9063
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -18,6 +18,17 @@ flag {
    }
}

flag {
  name: "release_surface_on_transition_finish"
  namespace: "windowing_frontend"
  description: "Reduce offscreen layers which rely on GC to release"
  bug: "407719374"
  is_fixed_read_only: true
  metadata {
    purpose: PURPOSE_BUGFIX
  }
}

flag {
  name: "cache_window_style"
  namespace: "windowing_frontend"
+18 −10
Original line number Diff line number Diff line
@@ -359,6 +359,9 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
                mInteractionJankMonitor.end(CUJ_DEFAULT_TASK_TO_TASK_ANIMATION);
            }
            mAnimations.remove(transition);
            if (Flags.releaseSurfaceOnTransitionFinish()) {
                info.releaseAllSurfaces();
            }
            finishCallback.onTransitionFinished(null /* wct */);
        };

@@ -638,8 +641,10 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
        }
        startTransaction.apply();

        final boolean hasAnimations = !animations.isEmpty();
        // now start animations. they are started on another thread, so we have to post them
        // *after* applying the startTransaction
        if (hasAnimations) {
            mAnimExecutor.execute(() -> {
                if (isTaskTransition) {
                    mInteractionJankMonitor.begin(info.getRoot(0).getLeash(), mContext,
@@ -649,11 +654,14 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
                    animations.get(i).start();
                }
            });
        }

        mRotator.cleanUp(finishTransaction);
        TransitionMetrics.getInstance().reportAnimationStart(transition);
        // run finish now in-case there are no animations
        if (!hasAnimations) {
            onAnimFinish.run();
        }
        return true;
    }