remotion-dev/remotion · error · Error

Failed to create WebGL shader

Error message

Failed to create WebGL shader

What it means

Thrown by compileShader() in the chromatic aberration runtime when gl.createShader(type) returns null. A null shader object means the WebGL2 context is lost/destroyed or its shader object budget is exhausted, so compilation cannot begin and effect setup aborts before linking.

Source

Thrown at packages/effects/src/chromatic-aberration/chromatic-aberration-runtime.ts:28

	gl: WebGL2RenderingContext;
	program: WebGLProgram;
	vao: WebGLVertexArrayObject;
	vbo: WebGLBuffer;
	textureSource: WebGLTexture;
	uniforms: {
		uSource: WebGLUniformLocation | null;
		uOffset: WebGLUniformLocation | null;
	};
};

const compileShader = (
	gl: WebGL2RenderingContext,
	type: number,
	source: string,
): WebGLShader => {
	const shader = gl.createShader(type);
	if (!shader) {
		throw new Error('Failed to create WebGL shader');
	}

	gl.shaderSource(shader, source);
	gl.compileShader(shader);
	if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
		const log = gl.getShaderInfoLog(shader);
		gl.deleteShader(shader);
		throw new Error(`Shader compile failed: ${log ?? '(no log)'}`);
	}

	return shader;
};

const linkProgram = (
	gl: WebGL2RenderingContext,
	vs: WebGLShader,
	fs: WebGLShader,
): WebGLProgram => {

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Reduce concurrent WebGL-using effects/compositions.
  2. Enable real GPU acceleration in the render browser.
  3. Handle 'webglcontextlost'/'webglcontextrestored' and recreate the effect.
  4. Update GPU drivers; verify WebGL2 support.
  5. Use a GPU-enabled/higher-memory instance server-side.
Defensive patterns

Strategy: try-catch

Validate before calling

function probeWebGL2(): boolean {
  try {
    const c = document.createElement('canvas');
    const gl = c.getContext('webgl2');
    return !!gl && !gl.isContextLost();
  } catch {
    return false;
  }
}
if (!probeWebGL2()) skipOrFallback();

Try / catch

try {
  return <ChromaticAberration {...props} />;
} catch (err) {
  if (/Failed to create WebGL shader/.test(String(err))) return <FallbackFrame />;
  throw err;
}

Prevention

When it happens

Trigger: setupChromaticAberration() -> createProgram() -> compileShader() calls gl.createShader() at chromatic-aberration-runtime.ts:26; it returns null and the guard at :27 throws.

Common situations: Many concurrent compositions, --disable-gpu / SwiftShader overload, blacklisted GPU, context loss during tab throttling, or a VM/lambda without GPU acceleration.

Related errors


AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12). Data as JSON: /api/errors/b6a0cc13e9fb14e0. Report an issue: GitHub.