{"record":{"id":"ffec9e8e528bcc55","repo":"remotion-dev/remotion","slug":"failed-to-create-webgl-texture-ffec9e","errorCode":null,"errorMessage":"Failed to create WebGL texture","messagePattern":"Failed to create WebGL texture","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/effects/src/halftone-linear-gradient.ts","lineNumber":482,"sourceCode":"\t\tif (!vbo) {\n\t\t\tthrow new Error('Failed to create WebGL buffer');\n\t\t}\n\n\t\tgl.bindBuffer(gl.ARRAY_BUFFER, vbo);\n\t\tgl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);\n\n\t\tconst aPos = gl.getAttribLocation(program, 'aPos');\n\t\tconst aUv = gl.getAttribLocation(program, 'aUv');\n\t\tgl.enableVertexAttribArray(aPos);\n\t\tgl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 16, 0);\n\t\tgl.enableVertexAttribArray(aUv);\n\t\tgl.vertexAttribPointer(aUv, 2, gl.FLOAT, false, 16, 8);\n\n\t\tgl.bindVertexArray(null);\n\n\t\tconst texture = gl.createTexture();\n\t\tif (!texture) {\n\t\t\tthrow new Error('Failed to create WebGL texture');\n\t\t}\n\n\t\tgl.bindTexture(gl.TEXTURE_2D, texture);\n\t\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n\t\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n\t\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n\t\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n\t\tgl.bindTexture(gl.TEXTURE_2D, null);\n\n\t\tconst colorCanvas = document.createElement('canvas');\n\t\tcolorCanvas.width = 1;\n\t\tcolorCanvas.height = 1;\n\t\tconst colorCtx = colorCanvas.getContext('2d', {willReadFrequently: true});\n\t\tif (!colorCtx) {\n\t\t\tthrow new Error('Failed to acquire 2D context for color parsing');\n\t\t}\n\n\t\treturn {","sourceCodeStart":464,"sourceCodeEnd":500,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/halftone-linear-gradient.ts#L464-L500","documentation":"Thrown in setup() of the halftone-linear-gradient effect when gl.createTexture() returns null. The effect allocates one source texture used to sample the incoming frame; a null texture means the GL implementation would not hand out another texture object, normally because of texture-budget limits or context loss.","triggerScenarios":"Allocating the effect's source texture after many other effects/textures already hold GPU memory; rendering very large frame textures on a GPU with a low MAX_TEXTURE_IMAGE_UNITS or low total texture memory; context-lost state.","commonSituations":"Compositions with many image/video layers each feeding a WebGL2 effect; headless rendering against a software GL with stingy texture limits; rendering after a GPU crash.","solutions":["Check gl.isContextLost(); restart the render if the context is lost.","Reduce the number of media layers feeding WebGL2 effects, or lower the output resolution to shrink per-texture memory.","Render on hardware with adequate texture memory; avoid pure-software GL for large frames.","Update the GPU driver to one that respects the real hardware texture limits."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Probe whether the context will hand out a texture at the size you need.\nfunction canCreateTexture(canvas: HTMLCanvasElement, width: number, height: number): boolean {\n  const gl = canvas.getContext('webgl2');\n  if (!gl) return false;\n  const tex = gl.createTexture();\n  if (!tex) return false;\n  gl.bindTexture(gl.TEXTURE_2D, tex);\n  try {\n    gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);\n  } catch {\n    gl.deleteTexture(tex);\n    return false;\n  }\n  gl.deleteTexture(tex);\n  return true;\n}","typeGuard":null,"tryCatchPattern":"try {\n  // ...use halftoneLinearGradient()\n} catch (e) {\n  if (e instanceof Error && /Failed to create WebGL texture/.test(e.message)) {\n    // reduce output resolution, fewer media layers, or restart on context loss\n  } else throw e;\n}","preventionTips":["Keep total media-layer count feeding WebGL2 effects within GPU texture memory.","Lower output resolution when rendering on low-memory GPUs.","Restart the render after a context-lost event."],"tags":["webgl","halftone-linear-gradient","gpu-resources","texture","context-loss"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}