{"record":{"id":"f955172027890e63","repo":"remotion-dev/remotion","slug":"failed-to-create-webgl-shader-f95517","errorCode":null,"errorMessage":"Failed to create WebGL shader","messagePattern":"Failed to create WebGL shader","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/effects/src/paper.ts","lineNumber":657,"sourceCode":"\tvec3 paperTone = mix(backRgb, frontRgb, clamp(res, 0.0, 1.0));\n\tvec3 texturedRgb = displacedRgb * (0.72 + 0.42 * res);\n\ttexturedRgb = mix(texturedRgb, texturedRgb * paperTone, 0.65);\n\ttexturedRgb -= 0.007 * dropPattern;\n\ttexturedRgb = mix(sourceRgb, texturedRgb, frame);\n\n\tvec3 finalRgb = mix(sourceRgb, clamp(texturedRgb, 0.0, 1.0), uAmount);\n\tfragColor = vec4(finalRgb * sourceAlpha, sourceAlpha);\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 WebGL 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(`Paper shader compile failed: ${log ?? '(no log)'}`);\n\t}\n\n\treturn shader;\n};\n\nconst linkProgram = (\n\tgl: WebGL2RenderingContext,\n\tvs: WebGLShader,\n\tfs: WebGLShader,\n): WebGLProgram => {","sourceCodeStart":639,"sourceCodeEnd":675,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/paper.ts#L639-L675","documentation":"Thrown by compileShader (packages/effects/src/paper.ts:657) when gl.createShader(type) returns null while compiling PAPER_VS or PAPER_FS. As with the other null GL-object returns, it indicates a lost WebGL2 context or exhausted shader-object budget; the shader source is not the cause at this line.","triggerScenarios":"setupPaper compiling shaders on a lost context or after too many live shaders; running the paper effect after a context loss that was not handled.","commonSituations":"GPU process crash mid-render; render host without usable WebGL2; heavy parallel renders exhausting GL objects.","solutions":["Render on a GPU host with WebGL enabled in headless Chrome.","Handle 'webglcontextlost' and re-run setup after 'webglcontextrestored'.","Reduce concurrent WebGL2 effects so the shader budget is not exhausted."],"exampleFix":"// before\nconst fs = compileShader(gl, gl.FRAGMENT_SHADER, PAPER_FS); // createShader() returned null\n\n// after\nif (gl.isContextLost()) {\n  throw new Error('WebGL2 context lost before paper setup');\n}","handlingStrategy":"try-catch","validationCode":"function canCompilePaperShader(): boolean {\n  try {\n    const c = document.createElement('canvas');\n    const gl = c.getContext('webgl2');\n    if (!gl || gl.isContextLost()) return false;\n    const s = gl.createShader(gl.VERTEX_SHADER);\n    const ok = !!s;\n    if (s) gl.deleteShader(s);\n    return ok;\n  } catch {\n    return false;\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  scene.push(paper({amount: 1}));\n} catch (err) {\n  if (/Failed to create WebGL shader/.test(String(err?.message))) {\n    // context unhealthy: skip paper and retry after restore\n  } else throw err;\n}","preventionTips":["Render on a GPU host with WebGL enabled in headless Chrome.","Handle webglcontextlost and re-run setup after webglcontextrestored.","Do not reuse a context after a loss without re-running setup."],"tags":["webgl","gpu","paper","effects","shader","context-loss"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}