{"record":{"id":"e1fec713b8c129f1","repo":"DrKLO/Telegram","slug":"could-not-store-the-lut-as-a-texture","errorCode":null,"errorMessage":"Could not store the LUT as a texture.","messagePattern":"Could not store the LUT as a texture\\.","errorType":"exception","errorClass":"FrameProcessingException","httpStatus":null,"severity":"error","filePath":"TMessagesProj/src/main/java/com/google/android/exoplayer2/effect/SingleColorLut.java","lineNumber":157,"sourceCode":"  @Override\n  public int getLength(long presentationTimeUs) {\n    return lut.getWidth();\n  }\n\n  @Override\n  public void release() throws GlUtil.GlException {\n    GlUtil.deleteTexture(lutTextureId);\n  }\n\n  @Override\n  public SingleFrameGlTextureProcessor toGlTextureProcessor(Context context, boolean useHdr)\n      throws FrameProcessingException {\n    checkState(!useHdr, \"HDR is currently not supported.\");\n\n    try {\n      lutTextureId = storeLutAsTexture(lut);\n    } catch (GlUtil.GlException e) {\n      throw new FrameProcessingException(\"Could not store the LUT as a texture.\", e);\n    }\n\n    return new ColorLutProcessor(context, /* colorLut= */ this, useHdr);\n  }\n\n  private static int storeLutAsTexture(Bitmap bitmap) throws GlUtil.GlException {\n    int lutTextureId =\n        GlUtil.createTexture(\n            bitmap.getWidth(), bitmap.getHeight(), /* useHighPrecisionColorComponents= */ false);\n    GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, /* level= */ 0, bitmap, /* border= */ 0);\n    GlUtil.checkGlError();\n    return lutTextureId;\n  }\n}\n","sourceCodeStart":139,"sourceCodeEnd":172,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/src/main/java/com/google/android/exoplayer2/effect/SingleColorLut.java#L139-L172","documentation":"SingleColorLut.toGlTextureProcessor wraps any GlUtil.GlException thrown by storeLutAsTexture(lut) into FrameProcessingException('Could not store the LUT as a texture.'). storeLutAsTexture creates an OpenGL 2D texture and uploads the LUT bitmap via GLUtils.texImage2D; a GL error during creation or upload surfaces here.","triggerScenarios":"Calling toGlTextureProcessor(context, useHdr) — note it first asserts useHdr is false — when GlUtil.createTexture or GLUtils.texImage2D/GlUtil.checkGlError() raises a GlException (e.g. no current GL context, texture allocation failure, unsupported bitmap format).","commonSituations":"Invoking the LUT pipeline off the GL thread / without a bound EGL context; a recycled or non-ARGB_8888 LUT bitmap; GPU out of memory for the LUT dimensions; GL state left in an error state by a prior operation.","solutions":["Ensure toGlTextureProcessor runs on the GL/effects thread with a valid current EGL context.","Pass a valid, non-recycled ARGB bitmap of reasonable dimensions as the LUT.","Catch FrameProcessingException around the effects pipeline and surface a user-facing fallback rather than crashing."],"exampleFix":"// before\nlut.toGlTextureProcessor(ctx, false); // called off the GL thread\n\n// after\nglThread.invoke(() -> lut.toGlTextureProcessor(ctx, false)); // run on the GL thread","handlingStrategy":"try-catch","validationCode":"// ensure LUT bitmap is valid and a GL context is current before calling\nif (lutBitmap != null && !lutBitmap.isRecycled() && GlUtil.hasValidContext()) {\n  lut.toGlTextureProcessor(ctx, /* useHdr= */ false);\n}","typeGuard":null,"tryCatchPattern":"try { lut.toGlTextureProcessor(ctx, false); }\ncatch (FrameProcessingException e) { /* skip LUT effect, surface error to user */ }","preventionTips":["Call toGlTextureProcessor on the GL/effects thread with a current context.","Use a valid, non-recycled ARGB bitmap for the LUT.","Never pass useHdr=true (the method asserts false)."],"tags":["video","exoplayer","effect","lut","gles","texture","frame-processing"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}