{"record":{"id":"bf67477399d503e0","repo":"remotion-dev/remotion","slug":"failed-to-create-exposure-shader","errorCode":null,"errorMessage":"Failed to create exposure shader","messagePattern":"Failed to create exposure shader","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/effects/src/exposure.ts","lineNumber":115,"sourceCode":"\t}\n\n\tvec3 unpremultiplied = sourceColor.rgb / alpha;\n\tvec3 linear = srgbToLinear(unpremultiplied);\n\tvec3 exposed = linear * exp2(uStops);\n\tvec3 corrected = linearToSrgb(exposed);\n\n\tfragColor = vec4(corrected * alpha, alpha);\n}\n`;\n\nconst compileShader = (\n\tgl: WebGL2RenderingContext,\n\ttype: number,\n\tsource: string,\n): WebGLShader => {\n\tconst shader = gl.createShader(type);\n\tif (!shader) {\n\t\tthrow new Error('Failed to create exposure shader');\n\t}\n\n\tgl.shaderSource(shader, source);\n\tgl.compileShader(shader);\n\tif (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n\t\tconst log = gl.getShaderInfoLog(shader);\n\t\tgl.deleteShader(shader);\n\t\tthrow new Error(`Exposure shader compile failed: ${log ?? '(no log)'}`);\n\t}\n\n\treturn shader;\n};\n\nconst createProgram = (gl: WebGL2RenderingContext): WebGLProgram => {\n\tconst vertexShader = compileShader(gl, gl.VERTEX_SHADER, VERTEX_SHADER);\n\tconst fragmentShader = compileShader(gl, gl.FRAGMENT_SHADER, FRAGMENT_SHADER);\n\tconst program = gl.createProgram();\n\tif (!program) {","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/exposure.ts#L97-L133","documentation":"Thrown inside compileShader() in exposure.ts when gl.createShader(type) returns null (exposure.ts:114-116). A null shader object means the GL driver would not allocate a shader handle — almost always a lost context or an exhausted shader-object pool. Without a shader handle, neither the vertex nor fragment stage can be built, so exposure setup aborts.","triggerScenarios":"setupExposure() -> createProgram() -> compileShader() runs while the WebGL2 context is lost (createShader must return null per spec) or after the driver's shader-object limit is reached. Because VERTEX_SHADER/FRAGMENT_SHADER are fixed strings, source content is not the cause here — allocation is.","commonSituations":"Rendering on a host where the GPU process crashed and the context is lost; long-running Studio with leaked shader objects from un-cleaned effect canvases; CI with software GL and a low shader-object ceiling; many concurrent exposure() instances.","solutions":["Render with the Angle backend (--gl=angle CLI / chromiumOptions.gl='angle' SSR / Angle in Studio) for stable shader allocation.","Ensure effect cleanup() runs (it deletes the program and its shaders transitively); don't hold stale exposure states.","Reduce simultaneous WebGL2 effects and reuse identical exposure() params so calculateKey collapses setups.","Check gl.isContextLost() and restore the context before retrying the render.","Update GPU drivers or move to a host with adequate GL resources."],"exampleFix":"// before\nconst shader = gl.createShader(type);\nif (!shader) {\n  throw new Error('Failed to create exposure shader');\n}\n\n// after (caller guard)\nif (gl.isContextLost()) {\n  // skip exposure setup until webglcontextrestored\n}","handlingStrategy":"try-catch","validationCode":"const canAllocateShader = (gl: WebGL2RenderingContext): boolean => {\n  if (gl.isContextLost()) return false;\n  const probe = gl.createShader(gl.VERTEX_SHADER);\n  if (!probe) return false;\n  gl.deleteShader(probe);\n  return true;\n};","typeGuard":null,"tryCatchPattern":"try {\n  // apply exposure(); for a custom canvas: const state = setupExposure(canvas);\n} catch (err) {\n  if (err instanceof Error && err.message === 'Failed to create exposure shader') {\n    // context likely lost or shader pool exhausted: free effects, retry on Angle\n    throw err;\n  }\n  throw err;\n}","preventionTips":["Render with Angle (--gl=angle / chromiumOptions.gl='angle').","Ensure cleanup() runs so programs/shaders are freed.","Limit simultaneous WebGL2 effects; reuse identical exposure() params.","Handle webglcontextlost and restore before retrying."],"tags":["webgl","shader","resource-allocation","gpu","exposure","setup"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}