Skip to content

Commit

Permalink
[scenarios] test disabling surface clear. (flutter#52128)
Browse files Browse the repository at this point in the history
I suspect that the change to clear the surface is the result of the
scenario app instability. just a guess: the screenshots looks like we're
missing the platform view. maybe the clearing of the surface is causing
an extra frame to be pushed. That frame is getting picked up in the
golden due to a race condition that is hard to hit locally


Testing disabling of this functionality in the golden test. If this pass
a real fix involves some sort of hook into the rendering to verify it
has fully completed before screenshotting.
  • Loading branch information
jonahwilliams authored Apr 15, 2024
1 parent a6acfa4 commit 84238c4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public class FlutterRenderer implements TextureRegistry {
*/
@VisibleForTesting public static boolean debugForceSurfaceProducerGlTextures = false;

/** Whether to disable clearing of the Surface used to render platform views. */
@VisibleForTesting public static boolean debugDisableSurfaceClear = false;

private static final String TAG = "FlutterRenderer";

@NonNull private final FlutterJNI flutterJNI;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import androidx.annotation.VisibleForTesting;
import io.flutter.Log;
import io.flutter.embedding.android.AndroidTouchProcessor;
import io.flutter.embedding.engine.renderer.FlutterRenderer;
import io.flutter.util.ViewUtils;

/**
Expand Down Expand Up @@ -63,7 +64,7 @@ public PlatformViewWrapper(
this.renderTarget = renderTarget;

Surface surface = renderTarget.getSurface();
if (surface != null) {
if (surface != null && !FlutterRenderer.debugDisableSurfaceClear) {
final Canvas canvas = surface.lockHardwareCanvas();
try {
canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public void onCreate(@Nullable Bundle arguments) {
"--impeller-backend=" + arguments.getString("impeller-backend", "vulkan")
};
}
FlutterRenderer.debugDisableSurfaceClear = true;
if ("true".equals(arguments.getString("force-surface-producer-surface-texture"))) {
// Set a test flag to force the SurfaceProducer to use SurfaceTexture.
FlutterRenderer.debugForceSurfaceProducerGlTextures = true;
Expand Down

0 comments on commit 84238c4

Please sign in to comment.