Loading apct-tests/perftests/windowmanager/src/android/wm/RelayoutPerfTest.java +3 −1 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentat import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.os.RemoteException; import android.perftests.utils.BenchmarkState; import android.perftests.utils.PerfStatusReporter; Loading Loading @@ -153,7 +154,8 @@ public class RelayoutPerfTest extends WindowManagerPerfTestBase while (state.keepRunning()) { session.relayout(mWindow, mParams, mWidth, mHeight, mViewVisibility.getAsInt(), mFlags, mOutFrames, mOutMergedConfiguration, mOutSurfaceControl, mOutInsetsState, mOutControls); mOutMergedConfiguration, mOutSurfaceControl, mOutInsetsState, mOutControls, new Bundle()); } } } Loading core/java/android/service/wallpaper/WallpaperService.java +5 −3 Original line number Diff line number Diff line Loading @@ -252,6 +252,7 @@ public abstract class WallpaperService extends Service { final InsetsVisibilities mRequestedVisibilities = new InsetsVisibilities(); final InsetsSourceControl[] mTempControls = new InsetsSourceControl[0]; final MergedConfiguration mMergedConfiguration = new MergedConfiguration(); final Bundle mSyncSeqIdBundle = new Bundle(); private final Point mSurfaceSize = new Point(); private final Point mLastSurfaceSize = new Point(); private final Matrix mTmpMatrix = new Matrix(); Loading Loading @@ -391,7 +392,7 @@ public abstract class WallpaperService extends Service { @Override public void resized(ClientWindowFrames frames, boolean reportDraw, MergedConfiguration mergedConfiguration, boolean forceLayout, boolean alwaysConsumeSystemBars, int displayId) { boolean alwaysConsumeSystemBars, int displayId, int syncSeqId) { Message msg = mCaller.obtainMessageIO(MSG_WINDOW_RESIZED, reportDraw ? 1 : 0, mergedConfiguration); Loading Loading @@ -1151,7 +1152,7 @@ public abstract class WallpaperService extends Service { final int relayoutResult = mSession.relayout( mWindow, mLayout, mWidth, mHeight, View.VISIBLE, 0, mWinFrames, mMergedConfiguration, mSurfaceControl, mInsetsState, mTempControls); mInsetsState, mTempControls, mSyncSeqIdBundle); final int transformHint = SurfaceControl.rotationToBufferTransform( (mDisplayInstallOrientation + mDisplay.getRotation()) % 4); Loading Loading @@ -1338,7 +1339,8 @@ public abstract class WallpaperService extends Service { mSurfaceCreated = true; if (redrawNeeded) { resetWindowPages(); mSession.finishDrawing(mWindow, null /* postDrawTransaction */); mSession.finishDrawing(mWindow, null /* postDrawTransaction */, Integer.MAX_VALUE); processLocalColors(mPendingXOffset, mPendingXOffsetStep); notifyColorsChanged(); } Loading core/java/android/view/IWindow.aidl +2 −1 Original line number Diff line number Diff line Loading @@ -55,7 +55,8 @@ oneway interface IWindow { void resized(in ClientWindowFrames frames, boolean reportDraw, in MergedConfiguration newMergedConfiguration, boolean forceLayout, boolean alwaysConsumeSystemBars, int displayId); boolean forceLayout, boolean alwaysConsumeSystemBars, int displayId, int syncSeqId); /** * Called when the window insets configuration has changed. Loading core/java/android/view/IWindowSession.aidl +4 −2 Original line number Diff line number Diff line Loading @@ -104,7 +104,8 @@ interface IWindowSession { int requestedWidth, int requestedHeight, int viewVisibility, int flags, out ClientWindowFrames outFrames, out MergedConfiguration outMergedConfiguration, out SurfaceControl outSurfaceControl, out InsetsState insetsState, out InsetsSourceControl[] activeControls); out InsetsState insetsState, out InsetsSourceControl[] activeControls, out Bundle bundle); /* * Notify the window manager that an application is relaunching and Loading Loading @@ -142,7 +143,8 @@ interface IWindowSession { * is null if there is no sync required. */ @UnsupportedAppUsage oneway void finishDrawing(IWindow window, in SurfaceControl.Transaction postDrawTransaction); oneway void finishDrawing(IWindow window, in SurfaceControl.Transaction postDrawTransaction, int seqId); @UnsupportedAppUsage oneway void setInTouchMode(boolean showFocus); Loading core/java/android/view/ViewRootImpl.java +26 −6 Original line number Diff line number Diff line Loading @@ -830,6 +830,24 @@ public final class ViewRootImpl implements ViewParent, private int mLastTransformHint = Integer.MIN_VALUE; /** * A temporary object used so relayoutWindow can return the latest SyncSeqId * system. The SyncSeqId system was designed to work without synchronous relayout * window, and actually synchronous relayout window presents a problem. We could have * a sequence like this: * 1. We send MSG_RESIZED to the client with a new syncSeqId to begin a new sync * 2. Due to scheduling the client executes performTraversals before calling MSG_RESIZED * 3. Coincidentally for some random reason it also calls relayout * 4. It observes the new state from relayout, and so the next frame will contain the state * However it hasn't received the seqId yet, and so under the designed operation of * seqId flowing through MSG_RESIZED, the next frame wouldn't be synced. Since it * contains our target sync state, we need to sync it! This problem won't come up once * we get rid of synchronous relayout, until then, we use this bundle to channel the * integer back over relayout. */ private Bundle mRelayoutBundle = new Bundle(); private int mSyncSeqId; private String mTag = TAG; public ViewRootImpl(Context context, Display display) { Loading Loading @@ -1711,6 +1729,7 @@ public final class ViewRootImpl implements ViewParent, mPendingBackDropFrame.set(backdropFrame); mForceNextWindowRelayout = forceNextWindowRelayout; mPendingAlwaysConsumeSystemBars = args.argi2 != 0; mSyncSeqId = args.argi4; if (msg == MSG_RESIZED_REPORT) { reportNextDraw(); Loading Loading @@ -4128,7 +4147,7 @@ public final class ViewRootImpl implements ViewParent, mDrawsNeededToReport = 0; try { mWindowSession.finishDrawing(mWindow, mSurfaceChangedTransaction); mWindowSession.finishDrawing(mWindow, mSurfaceChangedTransaction, Integer.MAX_VALUE); } catch (RemoteException e) { Log.e(mTag, "Unable to report draw finished", e); mSurfaceChangedTransaction.apply(); Loading Loading @@ -8071,7 +8090,7 @@ public final class ViewRootImpl implements ViewParent, requestedWidth, requestedHeight, viewVisibility, insetsPending ? WindowManagerGlobal.RELAYOUT_INSETS_PENDING : 0, mTmpFrames, mPendingMergedConfiguration, mSurfaceControl, mTempInsets, mTempControls); mTempControls, mRelayoutBundle); final int transformHint = SurfaceControl.rotationToBufferTransform( (mDisplayInstallOrientation + mDisplay.getRotation()) % 4); Loading Loading @@ -8497,7 +8516,7 @@ public final class ViewRootImpl implements ViewParent, if ((relayoutWindow(mWindowAttributes, viewVisibility, false) & WindowManagerGlobal.RELAYOUT_RES_FIRST_TIME) != 0) { mWindowSession.finishDrawing( mWindow, null /* postDrawTransaction */); mWindow, null /* postDrawTransaction */, Integer.MAX_VALUE); } } catch (RemoteException e) { } Loading Loading @@ -8571,7 +8590,7 @@ public final class ViewRootImpl implements ViewParent, @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) private void dispatchResized(ClientWindowFrames frames, boolean reportDraw, MergedConfiguration mergedConfiguration, boolean forceLayout, boolean alwaysConsumeSystemBars, int displayId) { boolean alwaysConsumeSystemBars, int displayId, int seqId) { final Rect frame = frames.frame; final Rect backDropFrame = frames.backdropFrame; if (DEBUG_LAYOUT) Log.v(mTag, "Resizing " + this + ": frame=" + frame.toShortString() Loading Loading @@ -8602,6 +8621,7 @@ public final class ViewRootImpl implements ViewParent, args.argi1 = forceLayout ? 1 : 0; args.argi2 = alwaysConsumeSystemBars ? 1 : 0; args.argi3 = displayId; args.argi4 = seqId; msg.obj = args; mHandler.sendMessage(msg); } Loading Loading @@ -9986,11 +10006,11 @@ public final class ViewRootImpl implements ViewParent, @Override public void resized(ClientWindowFrames frames, boolean reportDraw, MergedConfiguration mergedConfiguration, boolean forceLayout, boolean alwaysConsumeSystemBars, int displayId) { boolean alwaysConsumeSystemBars, int displayId, int seqId) { final ViewRootImpl viewAncestor = mViewAncestor.get(); if (viewAncestor != null) { viewAncestor.dispatchResized(frames, reportDraw, mergedConfiguration, forceLayout, alwaysConsumeSystemBars, displayId); alwaysConsumeSystemBars, displayId, seqId); } } Loading Loading
apct-tests/perftests/windowmanager/src/android/wm/RelayoutPerfTest.java +3 −1 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentat import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.os.RemoteException; import android.perftests.utils.BenchmarkState; import android.perftests.utils.PerfStatusReporter; Loading Loading @@ -153,7 +154,8 @@ public class RelayoutPerfTest extends WindowManagerPerfTestBase while (state.keepRunning()) { session.relayout(mWindow, mParams, mWidth, mHeight, mViewVisibility.getAsInt(), mFlags, mOutFrames, mOutMergedConfiguration, mOutSurfaceControl, mOutInsetsState, mOutControls); mOutMergedConfiguration, mOutSurfaceControl, mOutInsetsState, mOutControls, new Bundle()); } } } Loading
core/java/android/service/wallpaper/WallpaperService.java +5 −3 Original line number Diff line number Diff line Loading @@ -252,6 +252,7 @@ public abstract class WallpaperService extends Service { final InsetsVisibilities mRequestedVisibilities = new InsetsVisibilities(); final InsetsSourceControl[] mTempControls = new InsetsSourceControl[0]; final MergedConfiguration mMergedConfiguration = new MergedConfiguration(); final Bundle mSyncSeqIdBundle = new Bundle(); private final Point mSurfaceSize = new Point(); private final Point mLastSurfaceSize = new Point(); private final Matrix mTmpMatrix = new Matrix(); Loading Loading @@ -391,7 +392,7 @@ public abstract class WallpaperService extends Service { @Override public void resized(ClientWindowFrames frames, boolean reportDraw, MergedConfiguration mergedConfiguration, boolean forceLayout, boolean alwaysConsumeSystemBars, int displayId) { boolean alwaysConsumeSystemBars, int displayId, int syncSeqId) { Message msg = mCaller.obtainMessageIO(MSG_WINDOW_RESIZED, reportDraw ? 1 : 0, mergedConfiguration); Loading Loading @@ -1151,7 +1152,7 @@ public abstract class WallpaperService extends Service { final int relayoutResult = mSession.relayout( mWindow, mLayout, mWidth, mHeight, View.VISIBLE, 0, mWinFrames, mMergedConfiguration, mSurfaceControl, mInsetsState, mTempControls); mInsetsState, mTempControls, mSyncSeqIdBundle); final int transformHint = SurfaceControl.rotationToBufferTransform( (mDisplayInstallOrientation + mDisplay.getRotation()) % 4); Loading Loading @@ -1338,7 +1339,8 @@ public abstract class WallpaperService extends Service { mSurfaceCreated = true; if (redrawNeeded) { resetWindowPages(); mSession.finishDrawing(mWindow, null /* postDrawTransaction */); mSession.finishDrawing(mWindow, null /* postDrawTransaction */, Integer.MAX_VALUE); processLocalColors(mPendingXOffset, mPendingXOffsetStep); notifyColorsChanged(); } Loading
core/java/android/view/IWindow.aidl +2 −1 Original line number Diff line number Diff line Loading @@ -55,7 +55,8 @@ oneway interface IWindow { void resized(in ClientWindowFrames frames, boolean reportDraw, in MergedConfiguration newMergedConfiguration, boolean forceLayout, boolean alwaysConsumeSystemBars, int displayId); boolean forceLayout, boolean alwaysConsumeSystemBars, int displayId, int syncSeqId); /** * Called when the window insets configuration has changed. Loading
core/java/android/view/IWindowSession.aidl +4 −2 Original line number Diff line number Diff line Loading @@ -104,7 +104,8 @@ interface IWindowSession { int requestedWidth, int requestedHeight, int viewVisibility, int flags, out ClientWindowFrames outFrames, out MergedConfiguration outMergedConfiguration, out SurfaceControl outSurfaceControl, out InsetsState insetsState, out InsetsSourceControl[] activeControls); out InsetsState insetsState, out InsetsSourceControl[] activeControls, out Bundle bundle); /* * Notify the window manager that an application is relaunching and Loading Loading @@ -142,7 +143,8 @@ interface IWindowSession { * is null if there is no sync required. */ @UnsupportedAppUsage oneway void finishDrawing(IWindow window, in SurfaceControl.Transaction postDrawTransaction); oneway void finishDrawing(IWindow window, in SurfaceControl.Transaction postDrawTransaction, int seqId); @UnsupportedAppUsage oneway void setInTouchMode(boolean showFocus); Loading
core/java/android/view/ViewRootImpl.java +26 −6 Original line number Diff line number Diff line Loading @@ -830,6 +830,24 @@ public final class ViewRootImpl implements ViewParent, private int mLastTransformHint = Integer.MIN_VALUE; /** * A temporary object used so relayoutWindow can return the latest SyncSeqId * system. The SyncSeqId system was designed to work without synchronous relayout * window, and actually synchronous relayout window presents a problem. We could have * a sequence like this: * 1. We send MSG_RESIZED to the client with a new syncSeqId to begin a new sync * 2. Due to scheduling the client executes performTraversals before calling MSG_RESIZED * 3. Coincidentally for some random reason it also calls relayout * 4. It observes the new state from relayout, and so the next frame will contain the state * However it hasn't received the seqId yet, and so under the designed operation of * seqId flowing through MSG_RESIZED, the next frame wouldn't be synced. Since it * contains our target sync state, we need to sync it! This problem won't come up once * we get rid of synchronous relayout, until then, we use this bundle to channel the * integer back over relayout. */ private Bundle mRelayoutBundle = new Bundle(); private int mSyncSeqId; private String mTag = TAG; public ViewRootImpl(Context context, Display display) { Loading Loading @@ -1711,6 +1729,7 @@ public final class ViewRootImpl implements ViewParent, mPendingBackDropFrame.set(backdropFrame); mForceNextWindowRelayout = forceNextWindowRelayout; mPendingAlwaysConsumeSystemBars = args.argi2 != 0; mSyncSeqId = args.argi4; if (msg == MSG_RESIZED_REPORT) { reportNextDraw(); Loading Loading @@ -4128,7 +4147,7 @@ public final class ViewRootImpl implements ViewParent, mDrawsNeededToReport = 0; try { mWindowSession.finishDrawing(mWindow, mSurfaceChangedTransaction); mWindowSession.finishDrawing(mWindow, mSurfaceChangedTransaction, Integer.MAX_VALUE); } catch (RemoteException e) { Log.e(mTag, "Unable to report draw finished", e); mSurfaceChangedTransaction.apply(); Loading Loading @@ -8071,7 +8090,7 @@ public final class ViewRootImpl implements ViewParent, requestedWidth, requestedHeight, viewVisibility, insetsPending ? WindowManagerGlobal.RELAYOUT_INSETS_PENDING : 0, mTmpFrames, mPendingMergedConfiguration, mSurfaceControl, mTempInsets, mTempControls); mTempControls, mRelayoutBundle); final int transformHint = SurfaceControl.rotationToBufferTransform( (mDisplayInstallOrientation + mDisplay.getRotation()) % 4); Loading Loading @@ -8497,7 +8516,7 @@ public final class ViewRootImpl implements ViewParent, if ((relayoutWindow(mWindowAttributes, viewVisibility, false) & WindowManagerGlobal.RELAYOUT_RES_FIRST_TIME) != 0) { mWindowSession.finishDrawing( mWindow, null /* postDrawTransaction */); mWindow, null /* postDrawTransaction */, Integer.MAX_VALUE); } } catch (RemoteException e) { } Loading Loading @@ -8571,7 +8590,7 @@ public final class ViewRootImpl implements ViewParent, @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) private void dispatchResized(ClientWindowFrames frames, boolean reportDraw, MergedConfiguration mergedConfiguration, boolean forceLayout, boolean alwaysConsumeSystemBars, int displayId) { boolean alwaysConsumeSystemBars, int displayId, int seqId) { final Rect frame = frames.frame; final Rect backDropFrame = frames.backdropFrame; if (DEBUG_LAYOUT) Log.v(mTag, "Resizing " + this + ": frame=" + frame.toShortString() Loading Loading @@ -8602,6 +8621,7 @@ public final class ViewRootImpl implements ViewParent, args.argi1 = forceLayout ? 1 : 0; args.argi2 = alwaysConsumeSystemBars ? 1 : 0; args.argi3 = displayId; args.argi4 = seqId; msg.obj = args; mHandler.sendMessage(msg); } Loading Loading @@ -9986,11 +10006,11 @@ public final class ViewRootImpl implements ViewParent, @Override public void resized(ClientWindowFrames frames, boolean reportDraw, MergedConfiguration mergedConfiguration, boolean forceLayout, boolean alwaysConsumeSystemBars, int displayId) { boolean alwaysConsumeSystemBars, int displayId, int seqId) { final ViewRootImpl viewAncestor = mViewAncestor.get(); if (viewAncestor != null) { viewAncestor.dispatchResized(frames, reportDraw, mergedConfiguration, forceLayout, alwaysConsumeSystemBars, displayId); alwaysConsumeSystemBars, displayId, seqId); } } Loading