Closed lovehuanhuan closed 3 years ago
Related to #1060
Could you help verify if the following fixes the problem?
--- a/mediapipe/java/com/google/mediapipe/components/ExternalTextureConverter.java
+++ b/mediapipe/java/com/google/mediapipe/components/ExternalTextureConverter.java
@@ -363,6 +363,7 @@ public class ExternalTextureConverter implements TextureFrameProducer {
private static void teardownFrame(AppTextureFrame frame) {
GLES20.glDeleteTextures(1, new int[] {frame.getTextureName()}, 0);
+ frame.release();
}
private PoolTextureFrame createFrame() {
@@ -372,7 +373,6 @@ public class ExternalTextureConverter implements TextureFrameProducer {
String.format(
"Created output texture: %d width: %d height: %d",
destinationTextureId, destinationWidth, destinationHeight));
- bindFramebuffer(destinationTextureId, destinationWidth, destinationHeight);
return new PoolTextureFrame(destinationTextureId, destinationWidth, destinationHeight);
}
@@ -431,6 +431,7 @@ public class ExternalTextureConverter implements TextureFrameProducer {
// Copy surface texture's pixels to output frame
bindFramebuffer(outputFrame.getTextureName(), destinationWidth, destinationHeight);
renderer.render(surfaceTexture);
+ unbindFramebuffer();
// Populate frame timestamp with surface texture timestamp after render() as renderer
// ensures that surface texture has the up-to-date timestamp. (Also adjust
diff --git a/mediapipe/java/com/google/mediapipe/glutil/GlThread.java b/mediapipe/java/com/google/mediapipe/glutil/GlThread.java
index 24b8ca09..107fb669 100644
--- a/mediapipe/java/com/google/mediapipe/glutil/GlThread.java
+++ b/mediapipe/java/com/google/mediapipe/glutil/GlThread.java
@@ -117,6 +117,16 @@ public class GlThread extends Thread {
ShaderUtil.checkGlError("glViewport");
}
+ public void unbindFramebuffer() {
+ GLES20.glFramebufferTexture2D(
+ GLES20.GL_FRAMEBUFFER,
+ GLES20.GL_COLOR_ATTACHMENT0,
+ GLES20.GL_TEXTURE_2D,
+ 0,
+ 0);
+ GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
+ }
+
@Override
public void run() {
try {
Assuming the above comments resolved your query we are closing this issue now.
I doubt that function"teardownFrame" has memory leaking problem on rk3399,so I build a surfacetexture pool,then the memory leaking prolbem disappears.