From 113ebbb29697620bf2749bcde5906852685502dc Mon Sep 17 00:00:00 2001 From: act262 Date: Tue, 2 Jun 2020 14:07:39 +0800 Subject: [PATCH] Fix native crash #495 --- .../co/cyberagent/android/gpuimage/GPUImageRenderer.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/library/src/main/java/jp/co/cyberagent/android/gpuimage/GPUImageRenderer.java b/library/src/main/java/jp/co/cyberagent/android/gpuimage/GPUImageRenderer.java index e8cd690b7..298cb028b 100644 --- a/library/src/main/java/jp/co/cyberagent/android/gpuimage/GPUImageRenderer.java +++ b/library/src/main/java/jp/co/cyberagent/android/gpuimage/GPUImageRenderer.java @@ -161,10 +161,16 @@ public void onPreviewFrame(final byte[] data, final int width, final int height) runOnDraw(new Runnable() { @Override public void run() { + if (imageWidth != width || imageHeight != height) { + glRgbBuffer = null; + glRgbBuffer = IntBuffer.allocate(width * height); + GLES20.glDeleteTextures(1, new int[]{glTextureId}, 0); + glTextureId = NO_IMAGE; + } GPUImageNativeLibrary.YUVtoRBGA(data, width, height, glRgbBuffer.array()); glTextureId = OpenGlUtils.loadTexture(glRgbBuffer, width, height, glTextureId); - if (imageWidth != width) { + if (imageWidth != width || imageHeight != height) { imageWidth = width; imageHeight = height; adjustImageScaling();