From ddd8f4174f9cf2c34ffa121472fa02457aebdfdf Mon Sep 17 00:00:00 2001 From: hschlueter Date: Fri, 10 Jun 2022 11:03:38 +0000 Subject: [PATCH] Combine all native GL errors in a GlException instead of logging. The native GL errors are in an arbitrary order according to https://www.khronos.org/registry/OpenGL-Refpages/es2.0/xhtml/glGetError.xml This means any of them could contain the most useful message so it's better to use all for the GlException's message rather than picking the last message and logging all others. PiperOrigin-RevId: 454130460 (cherry picked from commit 92c2a304e10d0da968cf341080de47566ce551ed) --- .../google/android/exoplayer2/util/GlUtil.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/library/common/src/main/java/com/google/android/exoplayer2/util/GlUtil.java b/library/common/src/main/java/com/google/android/exoplayer2/util/GlUtil.java index 83bd545117..0a6478f6cd 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/util/GlUtil.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/util/GlUtil.java @@ -301,18 +301,22 @@ public final class GlUtil { } /** - * Logs all OpenGL errors that occurred since this method was last called and throws a {@link - * GlException} for the last error. + * Collects all OpenGL errors that occurred since this method was last called and throws a {@link + * GlException} with the combined error message. */ public static void checkGlError() throws GlException { - int lastError = GLES20.GL_NO_ERROR; + StringBuilder errorMessageBuilder = new StringBuilder(); + boolean foundError = false; int error; while ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR) { - Log.e(TAG, "glError: " + gluErrorString(error)); - lastError = error; + if (foundError) { + errorMessageBuilder.append('\n'); + } + errorMessageBuilder.append("glError: ").append(gluErrorString(error)); + foundError = true; } - if (lastError != GLES20.GL_NO_ERROR) { - throw new GlException("glError: " + gluErrorString(lastError)); + if (foundError) { + throw new GlException(errorMessageBuilder.toString()); } }