From 084f9f98904c00e776a02b3768342daddb3e51a8 Mon Sep 17 00:00:00 2001 From: Chavi Weingarten Date: Tue, 24 Jan 2023 21:14:11 +0000 Subject: [PATCH] Remove crop for Windowless Window leash The crop creates interference with syncing an embedded window because the crop doesn't happen in sync. Since the crop is really not needed, it's simpler to just remove it. Additionally, GL Surfaces were not setting scaling mode to NATIVE_WINDOW_SCALING_MODE_FREEZE which prevents the sync from working properly since the content would scale to the new size before a buffer was sent. Since HWUI expects NATIVE_WINDOW_SCALING_MODE_FREEZE, this CL also changes the scaling mode in CanvasContext for the surface used by HWUI. Added SurfaceSyncGroupContinuousTest presubmit test Test: SurfaceSyncGroupContinuousTest Bug: 237804605 Change-Id: I84c60c2a6fd6a88a1927138a0a93fbd0c16dfb6d --- .../android/view/WindowlessWindowManager.java | 1 - libs/hwui/renderthread/CanvasContext.cpp | 2 ++ .../wm/SurfaceSyncGroupContinuousTest.java | 17 +++++++++++++++-- .../wm/scvh/SyncValidatorSCVHTestCase.java | 11 +++++++++-- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/core/java/android/view/WindowlessWindowManager.java b/core/java/android/view/WindowlessWindowManager.java index 021193e8d9184..751141bf3728f 100644 --- a/core/java/android/view/WindowlessWindowManager.java +++ b/core/java/android/view/WindowlessWindowManager.java @@ -361,7 +361,6 @@ public class WindowlessWindowManager implements IWindowSession { } t.setPosition(leash, frames.frame.left, frames.frame.top); - t.setWindowCrop(leash, frames.frame.width(), frames.frame.height()); if (viewFlags == View.VISIBLE) { // TODO(b/262892794) ViewRootImpl modifies the app's rendering SurfaceControl diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp index b769f8d15044a..c8dcf094a35a4 100644 --- a/libs/hwui/renderthread/CanvasContext.cpp +++ b/libs/hwui/renderthread/CanvasContext.cpp @@ -248,6 +248,8 @@ void CanvasContext::setupPipelineSurface() { // Order is important when new and old surfaces are the same, because old surface has // its frame stats disabled automatically. native_window_enable_frame_timestamps(mNativeSurface->getNativeWindow(), true); + native_window_set_scaling_mode(mNativeSurface->getNativeWindow(), + NATIVE_WINDOW_SCALING_MODE_FREEZE); } else { mRenderThread.removeFrameCallback(this); mGenerationID++; diff --git a/services/tests/wmtests/src/com/android/server/wm/SurfaceSyncGroupContinuousTest.java b/services/tests/wmtests/src/com/android/server/wm/SurfaceSyncGroupContinuousTest.java index e6f47a1a493e5..eef7cc25eee7b 100644 --- a/services/tests/wmtests/src/com/android/server/wm/SurfaceSyncGroupContinuousTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/SurfaceSyncGroupContinuousTest.java @@ -22,6 +22,7 @@ import static android.server.wm.WindowManagerState.getLogicalDisplaySize; import android.app.KeyguardManager; import android.os.PowerManager; +import android.platform.test.annotations.Presubmit; import android.view.SurfaceControl; import android.view.cts.surfacevalidator.CapturedActivity; import android.window.SurfaceSyncGroup; @@ -68,11 +69,23 @@ public class SurfaceSyncGroupContinuousTest { @Test public void testSurfaceControlViewHostIPCSync_Fast() throws Throwable { - mCapturedActivity.verifyTest(new SyncValidatorSCVHTestCase(0 /* delayMs */), mName); + mCapturedActivity.verifyTest( + new SyncValidatorSCVHTestCase(0 /* delayMs */, false /* overrideDefaultDuration */), + mName); } @Test public void testSurfaceControlViewHostIPCSync_Slow() throws Throwable { - mCapturedActivity.verifyTest(new SyncValidatorSCVHTestCase(100 /* delayMs */), mName); + mCapturedActivity.verifyTest(new SyncValidatorSCVHTestCase(100 /* delayMs */, + false /* overrideDefaultDuration */), mName); + } + + @Test + @Presubmit + public void testSurfaceControlViewHostIPCSync_Short() throws Throwable { + mCapturedActivity.setMinimumCaptureDurationMs(5000); + mCapturedActivity.verifyTest( + new SyncValidatorSCVHTestCase(0 /* delayMs */, true /* overrideDefaultDuration */), + mName); } } diff --git a/services/tests/wmtests/src/com/android/server/wm/scvh/SyncValidatorSCVHTestCase.java b/services/tests/wmtests/src/com/android/server/wm/scvh/SyncValidatorSCVHTestCase.java index af4c683ca5e6b..07dac8d7fcc39 100644 --- a/services/tests/wmtests/src/com/android/server/wm/scvh/SyncValidatorSCVHTestCase.java +++ b/services/tests/wmtests/src/com/android/server/wm/scvh/SyncValidatorSCVHTestCase.java @@ -54,10 +54,12 @@ public class SyncValidatorSCVHTestCase implements ISurfaceValidatorTestCase { new Point(300, 800), new Point(200, 200)}; private int mLastSizeIndex = 1; - private long mDelayMs; + private final long mDelayMs; + private final boolean mOverrideDefaultDuration; - public SyncValidatorSCVHTestCase(long delayMs) { + public SyncValidatorSCVHTestCase(long delayMs, boolean overrideDefaultDuration) { mDelayMs = delayMs; + mOverrideDefaultDuration = overrideDefaultDuration; } private final Runnable mRunnable = new Runnable() { @@ -231,4 +233,9 @@ public class SyncValidatorSCVHTestCase implements ISurfaceValidatorTestCase { public void end() { mHandler.removeCallbacks(mRunnable); } + + @Override + public boolean hasAnimation() { + return !mOverrideDefaultDuration; + } }