{"record":{"id":"8dced0407239aac9","repo":"remotion-dev/remotion","slug":"failed-to-create-color-correction-shader","errorCode":null,"errorMessage":"Failed to create color correction shader","messagePattern":"Failed to create color correction shader","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/effects/src/color-correction.ts","lineNumber":311,"sourceCode":"\tcolor = clamp(\n\t\tvec3(luminance) + (color - vec3(luminance)) * uSaturation,\n\t\t0.0,\n\t\t1.0\n\t);\n\tcolor = applyVibrance(color, uVibrance);\n\n\tfragColor = vec4(color * 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 color correction 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(\n\t\t\t`Color correction shader compile failed: ${log ?? '(no log)'}`,\n\t\t);\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);","sourceCodeStart":293,"sourceCodeEnd":329,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/color-correction.ts#L293-L329","documentation":"Thrown by compileShader in the color correction effect when gl.createShader() returns null. The GL context exists but cannot allocate a new shader object, indicating resource exhaustion or context loss. The effect cannot build its vertex/fragment shaders, so setup fails before any drawing.","triggerScenarios":"Reached during createProgram() inside setupColorCorrection at color-correction.ts:310 when GL cannot produce a shader object for either VERTEX_SHADER or FRAGMENT_SHADER. Triggered by GL object-limit/memory exhaustion or a lost context, not by colorCorrection() params.","commonSituations":"Many concurrent WebGL2 contexts in headless Chrome, CI with software GL (SwiftShader) and low shader-object limits, a long render that suffers context loss, or a GPU/driver under memory pressure.","solutions":["Reduce render concurrency so fewer GL contexts/shaders coexist (--concurrency=1 or lower).","Render on a GPU-enabled environment (GPU Lambda layer / --enable-gpu headless Chrome) instead of software GL.","Update GPU drivers and the Chrome build; retry the render if context loss was transient.","Fewer stacked WebGL effects per frame reduces per-context shader allocation."],"exampleFix":"// before\nremotion render main --concurrency=8\n\n// after: fewer simultaneous GL contexts avoids shader allocation failure\nremotion render main --concurrency=1","handlingStrategy":"retry","validationCode":"function webgl2ShaderAvailable(): boolean {\n  try {\n    const c = document.createElement('canvas');\n    const gl = c.getContext('webgl2');\n    if (!gl) return false;\n    const s = gl.createShader(gl.VERTEX_SHADER);\n    const ok = s !== null;\n    if (s) gl.deleteShader(s);\n    return ok;\n  } catch {\n    return false;\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await renderMedia({...});\n} catch (err) {\n  if (/Failed to create color correction shader/i.test(String(err))) {\n    await renderMedia({...opts, concurrency: 1});\n  } else {\n    throw err;\n  }\n}","preventionTips":["Limit render concurrency to keep live GL shader objects low.","Prefer GPU-accelerated render environments over software GL.","Update GPU drivers and Chromium regularly.","Minimize the number of WebGL effects stacked per frame."],"tags":["webgl","gpu-resource-exhaustion","color-correction","shader","rendering","environment"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}