remotion-dev/remotion · error · Error

Failed to create WebGL shader

Error message

Failed to create WebGL shader

What it means

Internal error from the `roughenEdges()` effect's WebGL2 setup: `gl.createShader()` returned `null`. The WebGL2 context was created, but the driver refused to allocate a shader object. Environment-level failure (context loss, GPU resource exhaustion, unstable software GL), not a param error. The vertex/fragment shader sources (`ROUGHEN_EDGES_VS` / `ROUGHEN_EDGES_FS`) are static literals, so no user input reaches this path.

Source

Thrown at packages/effects/src/roughen-edges.ts:301

	vec2 offset = direction * scalar * uBorder / uResolution;
	vec4 roughened = texture(
		uSource,
		clamp(vUv + offset, vec2(0.0), vec2(1.0))
	);
	float blend = clamp(proximity * uAmount, 0.0, 1.0);

	fragColor = mix(source, roughened, blend);
}
`;

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(
			`Roughen edges shader compile failed: ${log ?? '(no log)'}`,
		);
	}

	return shader;
};

const linkProgram = (
	gl: WebGL2RenderingContext,
	vs: WebGLShader,

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Reload the page or restart the render for a fresh context.
  2. Reduce the number of concurrently active effects.
  3. Update GPU drivers or switch to hardware acceleration.
  4. Handle `webglcontextlost` to tear down and rebuild the effect.
Defensive patterns

Strategy: try-catch

Validate before calling

const supportsWebGL2 = (): boolean => {
  try {
    const c = document.createElement('canvas');
    return !!c.getContext('webgl2');
  } catch {
    return false;
  }
};

if (!supportsWebGL2()) {
  // fall back to a non-effect composition
}

Try / catch

try {
  roughenEdges()({...});
} catch (err) {
  if (err instanceof Error && /Failed to create WebGL shader/.test(err.message)) {
    // surface a 'GPU context unavailable' message and offer a reload
  } else {
    throw err;
  }
}

Prevention

When it happens

Trigger: Mounting `roughenEdges()` on a context that was just lost; running many effects until the driver's shader-object limit is hit; CI on a software GL backend under memory pressure.

Common situations: Long Studio sessions leaking contexts; render farms on SwiftShader/llvmpipe; systems resuming from sleep with a stale GPU context.

Related errors


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