Skip to content

Commit

Permalink
Release TextureView surface within FlutterTextureView when disconnect…
Browse files Browse the repository at this point in the history
…ed. (#48535) (#15899)
  • Loading branch information
matthew-carroll authored Jan 23, 2020
1 parent 5c9c627 commit 29e857c
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public class FlutterTextureView extends TextureView implements RenderSurface {
private boolean isAttachedToFlutterRenderer = false;
@Nullable
private FlutterRenderer flutterRenderer;
@Nullable
private Surface renderSurface;

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

flutterRenderer.startRenderingToSurface(new Surface(getSurfaceTexture()));
renderSurface = new Surface(getSurfaceTexture());
flutterRenderer.startRenderingToSurface(renderSurface);
}

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

flutterRenderer.stopRenderingToSurface();
renderSurface.release();
renderSurface = null;
}
}

0 comments on commit 29e857c

Please sign in to comment.