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

Commit 86b8389a authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Skip surface placement if the given insets will not change

This reduces the amount of surface placement:
 2~3 times when notification shade expands or collapses.
 7 times when display rotates.
 6~9 times when fold state changes.

Currently even if the client knows the insets are not changed, it still
need to tell server side to clear a pending state:
1. Client performs relayout with RELAYOUT_INSETS_PENDING if there has a
   insets listener. That sets WindowState#mGivenInsetsPending to true.
2. The listener assigns the insets according to the result of relayout.
3. Client calls WindowSession#setInsets to send the insets and consume
   the pending state mGivenInsetsPending (set to false).

Besides, by combing the conditions of mGivenInsetsPending to client
side, it can reduce IPC calls such as 3 times setInsets from nav bar.

Bug: 294796470
Test: atest WindowInsetsControllerTests

Change-Id: Ice3320a4b694c771332107e4d8c77927e0260c8b
parent 17f39ef0
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -3444,7 +3444,10 @@ public final class ViewRootImpl implements ViewParent,
            // other windows to resize/move based on the raw frame of the window, waiting until we
            // can finish laying out this window and get back to the window manager with the
            // ultimately computed insets.
            insetsPending = computesInternalInsets;
            insetsPending = computesInternalInsets
                    // If this window provides insets via params, its insets source frame can be
                    // updated directly without waiting for WindowSession#setInsets.
                    && mWindowAttributes.providedInsets == null;
            if (mSurfaceHolder != null) {
                mSurfaceHolder.mSurfaceLock.lock();
+1 −1
Original line number Diff line number Diff line
@@ -311,7 +311,7 @@ class InsetsSourceProvider {
            return mInsetsHint;
        }
        final WindowState win = mWindowContainer.asWindowState();
        if (win != null && win.mGivenInsetsPending && win.mAttrs.providedInsets == null) {
        if (win != null && win.mGivenInsetsPending) {
            return mInsetsHint;
        }
        if (mInsetsHintStale) {
+8 −0
Original line number Diff line number Diff line
@@ -2109,7 +2109,15 @@ public class WindowManagerService extends IWindowManager.Stub
                        + ", touchableRegion=" + w.mGivenTouchableRegion + " -> " + touchableRegion
                        + ", touchableInsets " + w.mTouchableInsets + " -> " + touchableInsets);
                if (w != null) {
                    final boolean wasGivenInsetsPending = w.mGivenInsetsPending;
                    w.mGivenInsetsPending = false;
                    if ((!wasGivenInsetsPending || !w.hasInsetsSourceProvider())
                            && w.mTouchableInsets == touchableInsets
                            && w.mGivenContentInsets.equals(contentInsets)
                            && w.mGivenVisibleInsets.equals(visibleInsets)
                            && w.mGivenTouchableRegion.equals(touchableRegion)) {
                        return;
                    }
                    w.mGivenContentInsets.set(contentInsets);
                    w.mGivenVisibleInsets.set(visibleInsets);
                    w.mGivenTouchableRegion.set(touchableRegion);
+1 −1
Original line number Diff line number Diff line
@@ -1342,7 +1342,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
            // This window doesn't provide any insets.
            return;
        }
        if (mGivenInsetsPending && mAttrs.providedInsets == null) {
        if (mGivenInsetsPending) {
            // The given insets are pending, and they are not reliable for now. The source frame
            // should be updated after the new given insets are sent to window manager.
            return;