{"record":{"id":"cee86330dafc725a","repo":"remotion-dev/remotion","slug":"failed-to-create-webgl-shader-cee863","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/thermal-vision.ts","lineNumber":156,"sourceCode":"\t}\n\n\tvec3 rgb = texColor.rgb / alpha;\n\tfloat luminance = dot(rgb, vec3(0.299, 0.587, 0.114));\n\tvec3 thermalRgb = paletteColor(luminance);\n\tvec3 mixedRgb = mix(rgb, thermalRgb, clamp(uAmount, 0.0, 1.0));\n\n\tfragColor = vec4(mixedRgb * 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 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(\n\t\t\t`Thermal vision shader compile failed: ${log ?? '(no log)'}`,\n\t\t);\n\t}\n\n\treturn shader;\n};\n\nconst linkProgram = (\n\tgl: WebGL2RenderingContext,\n\tvs: WebGLShader,","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/thermal-vision.ts#L138-L174","documentation":"During thermal vision effect `setup` (`setupThermalVision`), via `createProgram` -> `compileShader`, `gl.createShader()` returned `null`. The WebGL2 context could not allocate a shader object, indicating context loss, resource exhaustion, or a degraded context. The error fires before shader source is uploaded.","triggerScenarios":"WebGL2 context lost before setup; too many shader objects in the page; headless browser with incomplete WebGL2; destroyed GL context.","commonSituations":"Many concurrent webgl2 effects; long Studio sessions after a driver crash/reset; CI with software WebGL2 and low caps; mobile under memory pressure.","solutions":["Reduce concurrent webgl2 effect instances in the composition.","Restart the render/session for a fresh context.","Launch headless Chrome with WebGL2-capable flags (`--use-gl=angle --use-angle=swiftshader`).","Handle `webglcontextlost` to recreate contexts."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// Probe WebGL2 shader creation on a scratch canvas before relying on the effect.\nconst supportsWebGL2Shaders = (): boolean => {\n  try {\n    const gl = document.createElement('canvas').getContext('webgl2');\n    return !!gl?.createShader(gl.VERTEX_SHADER);\n  } catch {\n    return false;\n  }\n};\nif (!supportsWebGL2Shaders()) { /* use fallback */ }","typeGuard":null,"tryCatchPattern":"try {\n  thermalVision({...params});\n} catch (e) {\n  if (/Failed to create WebGL/.test((e as Error).message)) {\n    renderFallbackFrame();\n  } else throw e;\n}","preventionTips":["Bound concurrent webgl2 effects to keep shader allocation within driver limits.","Handle `webglcontextlost` and reinitialize effect state on restore.","In headless/CI, launch Chrome with WebGL2 enabled."],"tags":["thermal-vision","webgl2","gpu","resource-exhaustion","context-lost","setup"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}