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

Commit 4967156

Browse files
Reverts "Migrate Android scenario_app to the SurfaceProducer API (#50993)" (#50995)
Reverts #50993 Initiated by: matanlurey Reason for reverting: The digests will come back negative, as this change shows bugs in the `ImageTexture` implementation. Original PR Author: matanlurey Reviewed By: {jonahwilliams, johnmccutchan} This change reverts the following previous change: Original Description: Part of testing flutter/flutter#139702. Without this PR, the Impeller + Vulkan Scenario App will draw nothing/potentially crash, because there is no way to draw the (current) `SurfaceTexture`-based textures in Vulkan (and never will be). This change does the following: - Skia -> Nothing - Impeller + OpenGLES -> On newer Android devices, uses `ImageReader` instead - Impeller + Vulkan -> Always uses `ImageReader` See also: https://api.flutter.dev/javadoc/io/flutter/view/TextureRegistry.SurfaceProducer.html.
1 parent 7e1c44b commit 4967156

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

testing/scenario_app/android/app/src/main/java/dev/flutter/scenarios/ExternalTextureFlutterActivity.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import android.graphics.Paint;
1212
import android.graphics.Rect;
1313
import android.graphics.Shader.TileMode;
14+
import android.graphics.SurfaceTexture;
1415
import android.hardware.HardwareBuffer;
1516
import android.media.Image;
1617
import android.media.ImageReader;
@@ -35,7 +36,7 @@
3536
import androidx.annotation.Nullable;
3637
import androidx.annotation.RequiresApi;
3738
import androidx.core.util.Supplier;
38-
import io.flutter.view.TextureRegistry;
39+
import io.flutter.view.TextureRegistry.SurfaceTextureEntry;
3940
import java.io.IOException;
4041
import java.nio.ByteBuffer;
4142
import java.util.Map;
@@ -53,7 +54,7 @@ public class ExternalTextureFlutterActivity extends TestActivity {
5354
private final CountDownLatch firstFrameLatch = new CountDownLatch(2);
5455

5556
private long textureId = 0;
56-
private TextureRegistry.SurfaceProducer surfaceProducer;
57+
private SurfaceTextureEntry surfaceTextureEntry;
5758

5859
@Override
5960
protected void onCreate(@Nullable Bundle savedInstanceState) {
@@ -142,18 +143,19 @@ private MediaExtractor createMediaExtractor() {
142143
public void onPause() {
143144
surfaceViewRenderer.destroy();
144145
flutterRenderer.destroy();
145-
surfaceProducer.release();
146+
surfaceTextureEntry.release();
146147
super.onPause();
147148
}
148149

149150
@Override
150151
public void onFlutterUiDisplayed() {
151-
surfaceProducer =
152-
Objects.requireNonNull(getFlutterEngine()).getRenderer().createSurfaceProducer();
153-
surfaceProducer.setSize(SURFACE_WIDTH, SURFACE_HEIGHT);
154-
flutterRenderer.attach(surfaceProducer.getSurface(), firstFrameLatch);
152+
surfaceTextureEntry =
153+
Objects.requireNonNull(getFlutterEngine()).getRenderer().createSurfaceTexture();
154+
SurfaceTexture surfaceTexture = surfaceTextureEntry.surfaceTexture();
155+
surfaceTexture.setDefaultBufferSize(SURFACE_WIDTH, SURFACE_HEIGHT);
156+
flutterRenderer.attach(new Surface(surfaceTexture), firstFrameLatch);
155157
flutterRenderer.repaint();
156-
textureId = surfaceProducer.id();
158+
textureId = surfaceTextureEntry.id();
157159

158160
super.onFlutterUiDisplayed();
159161
}

0 commit comments

Comments
 (0)