{"record":{"id":"339e220d316c5955","repo":"google/ExoPlayer","slug":"unexpected-uniform-type-type","errorCode":null,"errorMessage":"Unexpected uniform type: {type}","messagePattern":"Unexpected uniform type: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"library/common/src/main/java/com/google/android/exoplayer2/util/GlProgram.java","lineNumber":440,"sourceCode":"          break;\n        case GLES20.GL_SAMPLER_2D:\n        case GLES11Ext.GL_SAMPLER_EXTERNAL_OES:\n        case GL_SAMPLER_EXTERNAL_2D_Y2Y_EXT:\n          if (texIdValue == 0) {\n            throw new IllegalStateException(\"No call to setSamplerTexId() before bind.\");\n          }\n          GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + texUnitIndex);\n          GlUtil.checkGlError();\n          GlUtil.bindTexture(\n              type == GLES20.GL_SAMPLER_2D\n                  ? GLES20.GL_TEXTURE_2D\n                  : GLES11Ext.GL_TEXTURE_EXTERNAL_OES,\n              texIdValue);\n          GLES20.glUniform1i(location, texUnitIndex);\n          GlUtil.checkGlError();\n          break;\n        default:\n          throw new IllegalStateException(\"Unexpected uniform type: \" + type);\n      }\n    }\n  }\n}\n","sourceCodeStart":422,"sourceCodeEnd":445,"githubUrl":"https://github.com/google/ExoPlayer/blob/dd430f7053a1a3958deea3ead6a0565150c06bfc/library/common/src/main/java/com/google/android/exoplayer2/util/GlProgram.java#L422-L445","documentation":"Thrown from the default branch of GlProgram's uniform-binding switch when an active uniform in the linked program has a GL type the class does not know how to upload. Supported types are floats, ints/bools, vec2-4, matrices (MAT3/MAT4), and 2D samplers; anything else (e.g. GL_SAMPLER_CUBE, GL_IMAGE2D, arrays/half-float types, or a driver-reported exotic type) reaches the default case and throws IllegalStateException.","triggerScenarios":"A shader declares an unsupported uniform kind — samplerCube, sampler3D, image2D, or an arrayed uniform — and setUniformsAndBindTextures() iterates all active uniforms and hits the unknown type. Also possible on drivers that report unexpected types for half-precision uniforms.","commonSituations":"Porting a generic shader library to GlProgram (which only supports flat per-draw uniforms), using cubemaps for environment maps in an effects pipeline, or adding compute-style uniforms to a vertex/fragment shader consumed by ExoPlayer's GlProgram.","solutions":["Remove the unsupported uniform from the shader, or split it into a second, standalone GLES20 program managed outside GlProgram","Replace unsupported types with supported equivalents: samplerCube -> six 2D faces or pre-baked lookup; use setFloat/setFloats/setMat4 for data instead of exotic types","Update to the latest media3 release where new uniform types have been added over time (check release notes for GlProgram changes)","If the uniform is unused/dead code in GLSL, the compiler usually eliminates it — make sure it is actually referenced so it does not appear as active with a stray type"],"exampleFix":"// before\n// fragment shader: uniform samplerCube uEnvMap; -> IllegalStateException on bind\n// after\n// fragment shader: uniform sampler2D uEnvMapFace; (upload one face as a 2D texture)\nprogram.setSamplerTexId(\"uEnvMapFace\", envFaceTexId, 0);","handlingStrategy":"validation","validationCode":"// After linking, verify every active uniform type is one GlProgram supports\n// (GL_FLOAT..GL_FLOAT_MAT4, GL_SAMPLER_2D, GL_SAMPLER_EXTERNAL_OES) before drawing; reject the shader early otherwise.","typeGuard":null,"tryCatchPattern":"Catch IllegalStateException around draw() only to log which shader failed, then disable that effect — never continue rendering with a half-bound program.","preventionTips":["Limit shaders used with GlProgram to plain float/int/vec/mat uniforms and 2D/external-OES samplers","Run a shader smoke-test (compile, link, bind once) at app start or in CI with a GL context (e.g. Robolectric/Rotopeca or instrumentation)"],"tags":["opengl","gl","glprogram","shader","uniforms"],"backgroundTag":null,"analyzedSha":"dd430f7053a1a3958deea3ead6a0565150c06bfc","analyzedAt":"2026-08-14T12:22:02.982Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}