Ensure that releaseGl() is called if prepapreGl throws

Without this logic, we might have resources created within prepareGl() leaking, since they will never be released.

PiperOrigin-RevId: 583491569
This commit is contained in:
MediaPipe Team 2023-11-17 14:44:35 -08:00 committed by Copybara-Service
parent d29ea119ff
commit 42d42a5ea1

View File

@ -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.