diff --git a/mediapipe/java/com/google/mediapipe/glutil/GlThread.java b/mediapipe/java/com/google/mediapipe/glutil/GlThread.java index 24b8ca094..b8d4fa636 100644 --- a/mediapipe/java/com/google/mediapipe/glutil/GlThread.java +++ b/mediapipe/java/com/google/mediapipe/glutil/GlThread.java @@ -128,6 +128,10 @@ public class GlThread extends Thread { prepareGl(); startedSuccessfully = true; + } catch (RuntimeException e) { + releaseGl(); + eglManager.release(); + throw e; } finally { // Always stop waitUntilReady here, even if we got an exception. // Otherwise the main thread may be stuck waiting.