remotion-dev/remotion · error · Error
Failed to create WebGL shader
Error message
Failed to create WebGL shader
What it means
The skew() effect's WebGL2 backend could not allocate a shader object: gl.createShader() returned null inside compileShader() in packages/effects/src/skew.ts. A null return means the WebGL2 context is lost, resource-exhausted, or backed by a non-conformant driver, so the library cannot compile the vertex/fragment shaders it needs and throws before setup completes. This is an environment failure, not a parameter error — the context was acquired moments earlier (otherwise createWebGL2ContextError would have fired first).
Source
Thrown at packages/effects/src/skew.ts:164
vec2 sourceUv = vec2(sourceX, sourceY) / uResolution + uOrigin;
if (any(lessThan(sourceUv, vec2(0.0))) || any(greaterThan(sourceUv, vec2(1.0)))) {
fragColor = vec4(0.0);
return;
}
fragColor = texture(uSource, sourceUv);
}
`;
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(`Skew shader compile failed: ${log ?? '(no log)'}`);
}
return shader;
};
const setupSkew = (target: HTMLCanvasElement): SkewState => {
const gl = target.getContext('webgl2', {
premultipliedAlpha: true,
alpha: true,
preserveDrawingBuffer: true,View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Render with the ANGLE backend: add --gl=angle to the CLI, set chromiumOptions.gl='angle' in renderMediaOnLambda()/renderMedia(), or pick 'angle' in Studio Advanced > OpenGL render backend.
- Lower concurrency (CLI --concurrency, or concurrency in SSR options) and/or reduce the number of WebGL2 effects stacked on a single frame so the active-context cap is not exceeded.
- Make sure every effect's cleanup path runs so contexts/textures are released before new ones are allocated; avoid leaking offscreen canvases.
- Verify the environment actually supports WebGL2 (driver installed, not blacklisted); update GPU drivers or run on a host with a working GPU/ANGLE setup.
Example fix
// before
await renderMedia({ composition, serveUrl, codec: 'h264' });
// npx remotion render main MyComp out.mp4
// after
await renderMedia({
composition,
serveUrl,
codec: 'h264',
chromiumOptions: { gl: 'angle' },
});
// npx remotion render main MyComp out.mp4 --gl=angle Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-flight: confirm WebGL2 is usable before relying on skew().
// Note: this only catches 'no WebGL2 at all' — a createShader() null
// typically means context LOSS after acquisition, which is not detectable up front.
function supportsWebGL2Effect(): boolean {
try {
const c = document.createElement('canvas');
const gl = c.getContext('webgl2');
return !!gl;
} catch {
return false;
}
}
if (!supportsWebGL2Effect()) {
throw new Error('skew() requires WebGL2, which is unavailable in this environment');
} Try / catch
try {
// using skew() in a render or component
await renderMedia({ composition, codec: 'h264', chromiumOptions: { gl: 'angle' } });
} catch (err) {
if (err instanceof Error && /Failed to create WebGL shader/.test(err.message)) {
// context was acquired but a shader could not be allocated: treat as env failure
console.error('WebGL2 resource allocation failed for skew(). Retry with --gl=angle or lower concurrency.', err);
throw err;
}
throw err;
} Prevention
- Always render WebGL2 effects with the ANGLE backend (--gl=angle / chromiumOptions.gl='angle').
- Keep render concurrency and the number of stacked WebGL2 effects low enough to stay under the browser's live-context cap (~16).
- Run an integration render of effects-heavy compositions in CI on a known-good GPU host before shipping.
- Treat any 'Failed to create WebGL *' message as an environment problem, not a code problem — investigate drivers/GPU before the effect code.
When it happens
Trigger: Calling skew({...}) in a render where the WebGL2 context acquired in setupSkew() has entered a lost state, or where the process already holds too many live WebGL contexts (browsers cap active contexts, commonly ~16) so a freshly-acquired context is immediately unusable. Also reproducible under GPU memory pressure or a driver reset between getContext() and createShader().
Common situations: Headless Chromium rendering without --gl=angle; many parallel frames each stacking multiple WebGL2 effects; SwiftShader/llvmpipe software fallback under load; a machine whose GPU driver crashed and the context was not recovered; CI runners with no real GPU.
Related errors
- Failed to create WebGL program
- Failed to create WebGL buffer
- Failed to create WebGL geometry
- Failed to create WebGL texture
- Failed to create WebGL shader
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/92dbc7a08673b2ce.
Report an issue: GitHub.