Merge "Fix for failing tests on API level 33" into androidx-main am: a1d67c64c4

Original change: https://android-review.googlesource.com/c/platform/frameworks/support/+/2576532

Change-Id: Icf23bcc1c9dec88bd604296474f0cf697ee30a59
Signed-off-by: Automerger Merge Worker <[email protected]>
diff --git a/graphics/graphics-core/src/androidTest/java/androidx/graphics/lowlatency/SingleBufferedCanvasRendererV29Test.kt b/graphics/graphics-core/src/androidTest/java/androidx/graphics/lowlatency/SingleBufferedCanvasRendererV29Test.kt
index 5ecc43e..60cf00d 100644
--- a/graphics/graphics-core/src/androidTest/java/androidx/graphics/lowlatency/SingleBufferedCanvasRendererV29Test.kt
+++ b/graphics/graphics-core/src/androidTest/java/androidx/graphics/lowlatency/SingleBufferedCanvasRendererV29Test.kt
@@ -41,7 +41,6 @@
 import org.junit.Assert.assertFalse
 import org.junit.Assert.assertNotNull
 import org.junit.Assert.assertTrue
-import org.junit.Ignore
 import org.junit.Test
 import org.junit.runner.RunWith
 
@@ -229,7 +228,11 @@
                     bufferReadyLatch.countDown()
                     drawCancelledRequestLatch?.countDown()
                 }
-            })
+            }).apply {
+                // See: b/236394768 Workaround for ANGLE issue where FBOs with HardwareBuffer
+                // attachments are not executed until a glReadPixels call is made
+                forceFlush.set(true)
+            }
         try {
             renderer.render(Color.RED)
             assertTrue(initialDrawLatch.await(3000, TimeUnit.MILLISECONDS))
@@ -280,7 +283,11 @@
                 ) {
                     // NO-OP
                 }
-            })
+            }).apply {
+                // See: b/236394768 Workaround for ANGLE issue where FBOs with HardwareBuffer
+                // attachments are not executed until a glReadPixels call is made
+                forceFlush.set(true)
+            }
         try {
             val latch = CountDownLatch(1)
             renderer.release(true) {
@@ -330,7 +337,11 @@
                     syncFenceCompat?.awaitForever()
                     drawLatch?.countDown()
                 }
-            })
+            }).apply {
+                // See: b/236394768 Workaround for ANGLE issue where FBOs with HardwareBuffer
+                // attachments are not executed until a glReadPixels call is made
+                forceFlush.set(true)
+            }
         try {
             renderer.isVisible = false
             drawLatch = CountDownLatch(1)
@@ -353,7 +364,6 @@
         }
     }
 
-    @Ignore("b/274099885")
     @SdkSuppress(minSdkVersion = Build.VERSION_CODES.Q)
     @Test
     fun testBatchedRenders() {
@@ -378,7 +388,11 @@
                 ) {
                     // NO-OP
                 }
-            })
+            }).apply {
+                // See: b/236394768 Workaround for ANGLE issue where FBOs with HardwareBuffer
+                // attachments are not executed until a glReadPixels call is made
+                forceFlush.set(true)
+            }
         try {
             renderer.render(Color.RED)
             renderer.render(Color.BLUE)
@@ -431,7 +445,11 @@
                     buffer = hardwareBuffer
                     renderLatch.countDown()
                 }
-            })
+            }).apply {
+                // See: b/236394768 Workaround for ANGLE issue where FBOs with HardwareBuffer
+                // attachments are not executed until a glReadPixels call is made
+                forceFlush.set(true)
+            }
         try {
             renderer.render(0)
             assertTrue(renderLatch.await(3000, TimeUnit.MILLISECONDS))
diff --git a/graphics/graphics-core/src/androidTest/java/androidx/graphics/opengl/GLRendererTest.kt b/graphics/graphics-core/src/androidTest/java/androidx/graphics/opengl/GLRendererTest.kt
index a03d42d..43f1de6 100644
--- a/graphics/graphics-core/src/androidTest/java/androidx/graphics/opengl/GLRendererTest.kt
+++ b/graphics/graphics-core/src/androidTest/java/androidx/graphics/opengl/GLRendererTest.kt
@@ -987,6 +987,8 @@
                     width.toFloat(),
                     height.toFloat()
                 )
+                // See: b/236394768 Workaround for ANGLE issue where FBOs with HardwareBuffer
+                GLES20.glFinish()
                 supportsFence = eglManager.supportsNativeAndroidFence()
                 quadRenderer.release()
                 surface.release()
@@ -1125,6 +1127,8 @@
                     width.toFloat(),
                     height.toFloat()
                 )
+                // See: b/236394768 Workaround for ANGLE issue where FBOs with HardwareBuffer
+                GLES20.glFinish()
                 supportsFence = eglManager.supportsNativeAndroidFence()
                 quadRenderer.release()
                 deleteTexture(texId)