Skip to content

Commit 29e857c

Browse files
Release TextureView surface within FlutterTextureView when disconnected. (flutter#48535) (flutter#15899)
1 parent 5c9c627 commit 29e857c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

shell/platform/android/io/flutter/embedding/android/FlutterTextureView.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public class FlutterTextureView extends TextureView implements RenderSurface {
3838
private boolean isAttachedToFlutterRenderer = false;
3939
@Nullable
4040
private FlutterRenderer flutterRenderer;
41+
@Nullable
42+
private Surface renderSurface;
4143

4244
// Connects the {@code SurfaceTexture} beneath this {@code TextureView} with Flutter's native code.
4345
// Callbacks are received by this Object and then those messages are forwarded to our
@@ -172,7 +174,8 @@ private void connectSurfaceToRenderer() {
172174
throw new IllegalStateException("connectSurfaceToRenderer() should only be called when flutterRenderer and getSurfaceTexture() are non-null.");
173175
}
174176

175-
flutterRenderer.startRenderingToSurface(new Surface(getSurfaceTexture()));
177+
renderSurface = new Surface(getSurfaceTexture());
178+
flutterRenderer.startRenderingToSurface(renderSurface);
176179
}
177180

178181
// FlutterRenderer must be non-null.
@@ -192,5 +195,7 @@ private void disconnectSurfaceFromRenderer() {
192195
}
193196

194197
flutterRenderer.stopRenderingToSurface();
198+
renderSurface.release();
199+
renderSurface = null;
195200
}
196201
}

0 commit comments

Comments
 (0)