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

Commit ad62bda3 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Do not set report-orientation-changed for window without surface

Otherwise the state may remain to the next new surface when
the window becomes visible, and it will get ViewRootImpl
#mForceNextWindowRelayout=true from WindowState#resize. And then
its pre-allocated buffers from ThreadedRenderer#allocateBuffers
will be dropped by ThreadedRenderer#updateSurface. And then
allocate again in each frame, which is very wasteful.

Bug: 228223340
Test: 1. Launch a landscape app from portrait launcher.
      2. Use command "record_android_trace sched view wm am gfx".
      3. Swipe up to return to launcher.
      4. The trace of launcher should not show "setSurface".
         And there should not have "allocateHelper" in "DrawFrames".
Change-Id: If66cde35837b0362ca51eee018d8828416d118ec
parent 7b0f4e57
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1992,7 +1992,8 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        scheduleAnimation();

        forAllWindows(w -> {
            if (w.mHasSurface && !rotateSeamlessly) {
            if (!w.mHasSurface) return;
            if (!rotateSeamlessly) {
                ProtoLog.v(WM_DEBUG_ORIENTATION, "Set mOrientationChanging of %s", w);
                w.setOrientationChanging(true);
            }
+4 −0
Original line number Diff line number Diff line
@@ -3602,6 +3602,10 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        mAnimatingExit = false;
        ProtoLog.d(WM_DEBUG_ANIM, "Clear animatingExit: reason=destroySurface win=%s", this);

        // Clear the flag so the buffer requested for the next new surface won't be dropped by
        // mistaking the surface size needs to update.
        mReportOrientationChanged = false;

        if (useBLASTSync()) {
            immediatelyNotifyBlastSync();
        }