Skip to content
This repository has been archived by the owner on Feb 25, 2025. It is now read-only.

Commit

Permalink
Clear the surface to transparent black when creating a PlatformViewWr…
Browse files Browse the repository at this point in the history
…apper (#52047)

Without this, an opaque black surface may briefly flash onscreen when the platform view is shown (see internal issue b/332379081)

This matches the behavior used before to the introduction of PlatformViewRenderTarget in 2046254

That commit moved the clearing of the surface into SurfaceTexturePlatformViewRenderTarget.  But that caused surface clearing to happen in scenarios where there was no PlatformViewWrapper, resulting in the issue seen in flutter/flutter#141068

Later the surface clearing was removed from SurfaceTexturePlatformViewRenderTarget, causing the flashing black screen.
  • Loading branch information
jason-simmons authored Apr 11, 2024
1 parent 2d85d12 commit 6b37b17
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ public PlatformViewWrapper(
@NonNull Context context, @NonNull PlatformViewRenderTarget renderTarget) {
this(context);
this.renderTarget = renderTarget;

Surface surface = renderTarget.getSurface();
if (surface != null) {
final Canvas canvas = surface.lockHardwareCanvas();
try {
canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
} finally {
surface.unlockCanvasAndPost(canvas);
}
}
}

/**
Expand Down

0 comments on commit 6b37b17

Please sign in to comment.