---
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://framesfield.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
title: "Fix Remotion delayRender Timeouts and Chromium OOM Crashes"
description: "Replace <Video> with <OffthreadVideo> on local public/ plates, cap --concurrency to 1 tab per 2 GB RAM, mount --shm-size=2g in Docker with --gl=swangle on headless Linux, and wrap every manual delayRender() in try/catch with cancelRender()."
canonical: "https://framesfield.com/fixes/remotion-headless-chromium-timeout-and-memory-crash-fix"
---

# Fix Remotion delayRender Timeouts and Chromium OOM Crashes

> Replace <Video> with <OffthreadVideo> on local public/ plates, cap --concurrency to 1 tab per 2 GB RAM, mount --shm-size=2g in Docker with --gl=swangle on headless Linux, and wrap every manual delayRender() in try/catch with cancelRender().

- **Canonical URL:** https://framesfield.com/fixes/remotion-headless-chromium-timeout-and-memory-crash-fix
- **Category:** API & Batch Pipelines
- **Error Signature:** `Error: A delayRender() "Waiting for <Video> / media" was called but not cleared after 28000ms | ProtocolError: Page crashed / Target closed | Process exited with SIGKILL (exit code 137) in Docker or CI`
- **Last Verified:** 2026-12-01

## Observed Symptom

Your Remotion composition previews smoothly in Remotion Studio on your laptop, then hangs at frame 0 or frame 140 during npx remotion render with 28000ms/30000ms delayRender timeouts—or crashes midway through a 50-variant ad batch inside Docker/GitHub Actions with Target closed or Exit Code 137.

## Technical Root Cause

Four resource bottlenecks collide under parallel headless rendering: using HTML5 <Video> instead of C++ <OffthreadVideo> stalls Chromium video decoders across concurrent tabs; default Remotion concurrency oversubscribes RAM and Docker’s tiny 64 MB /dev/shm partition; unawaited or leaked delayRender() handles hang forever on slow external URLs; and missing swangle/GPU flags crash headless Linux workers.

## Under the Hood

When you invoke npx remotion render without specifying --concurrency, Remotion defaults to spawning browser tabs equal to half of the host’s logical CPU threads. On a modern 8- or 16-vCPU CI runner with limited RAM—or inside a Linux Docker container whose default /dev/shm shared-memory mount is capped at just 64 MB—opening 6 to 8 concurrent headless Chromium instances compositing 1080×1920 frames rapidly exhausts shared memory. Chromium’s renderer process aborts immediately with Target closed or Page crashed, or the Linux OOM killer terminates the entire render with SIGKILL (exit code 137).

A second frequent culprit in AI video pipelines is mounting high-bitrate Gemini Omni 1.2 Flash, Kling 4.0, or Wan 2.2 MP4 plates via Remotion’s standard HTML5 <Video> tag instead of <OffthreadVideo>. Standard <Video> forces Chromium to seek an asynchronous HTML5 media buffer on every individual frame across every open tab; when 4 tabs seek expiring remote CDN URLs simultaneously, decoder stalls exceed Remotion’s 30,000 ms timeout and throw the classic 28,000 ms delayRender warning. <OffthreadVideo> bypasses Chromium’s video element completely by extracting exact frame images natively in C++ via FFmpeg.

Finally, dynamic React compositions often leak delayRender() locks inside useEffect hooks when an external font, JSON feed, or signed video URL returns HTTP 403/504 without executing continueRender() or cancelRender() in a catch block. Pre-downloading every AI video plate and self-hosted font into public/, transcoding oversized 4K plates down to target 1080p CFR H.264 before batching, capping concurrency strictly to available RAM (roughly 1 tab per 2–2.5 GB of free memory), mounting --shm-size=2g in Docker, and setting --gl=swangle on GPU-less Linux runners makes 50-variant batch renders rock-solid.

## Before vs. After

### Broken (Fragile Render (HTML5 <Video> Remote URL + Uncapped Concurrency + 64MB shm))

```
// Component: HTML5 <Video> seeking remote CDN MP4 stalls headless tabs
import { Video } from 'remotion';
export const Scene = () => <Video src="https://cdn.example.com/signed-veo-4k.mp4" />;

# Docker / CI CLI: defaults to 8 tabs on 64MB /dev/shm -> Target closed / Exit 137
docker run --rm my-remotion-app npx remotion render src/index.ts AdComp out/ad.mp4
```

### Verified Fix (Hardened Render (<OffthreadVideo> Local Plate + Capped Tabs + 2GB /dev/shm))

```
// Component: deterministic C++ FFmpeg frame extraction from local public/ plate
import { OffthreadVideo, staticFile } from 'remotion';
export const Scene = () => (
  <OffthreadVideo src={staticFile('plates/veo_1080p_cfr.mp4')} pauseWhenBuffering />
);

# Docker / CI CLI: 2GB shared memory, RAM-safe concurrency=2, swangle software GL
docker run --rm --shm-size=2g my-remotion-app \
  npx remotion render src/index.ts AdComp out/ad.mp4 \
  --concurrency=2 --timeout=60000 --gl=swangle \
  --codec=h264 --pixel-format=yuv420p
```

Offloading video frame decoding to C++ FFmpeg via <OffthreadVideo>, eliminating network jitter with staticFile(), allocating 2 GB of /dev/shm, and capping parallel Chromium tabs prevents both delayRender stalls and kernel OOM kills.

## Copy-Paste Fix (render-remotion-safe.sh)

```bash
#!/usr/bin/env bash
set -euo pipefail

# Usage: ./render-remotion-safe.sh AdVariant out/variant_01.mp4 '{"headline":"Spring Drop"}'
COMP_ID="${1:?Provide Remotion Composition ID}"
OUT_MP4="${2:?Provide output MP4 path}"
PROPS_JSON="${3:-{}}"
CONCURRENCY="${REMOTION_CONCURRENCY:-2}"
TIMEOUT_MS="${REMOTION_TIMEOUT_MS:-60000}"

# 1. Check /dev/shm size on Linux/Docker (warn if stuck at Docker's 64MB default)
if [[ -d /dev/shm ]]; then
  SHM_MB=$(df -m /dev/shm | awk 'NR==2 {print $2}')
  echo "Detected /dev/shm capacity: ${SHM_MB} MB"
  if [[ "$SHM_MB" -lt 512 ]]; then
    echo "WARNING: /dev/shm is under 512 MB. Re-run Docker with --shm-size=2g to prevent Page crashed!"
  fi
fi

# 2. Detect OS and select safe Chromium OpenGL renderer (swangle on headless Linux, angle on macOS)
GL_FLAG="angle"
if [[ "$(uname -s)" == "Linux" ]]; then
  GL_FLAG="swangle"
fi

# 3. Write deterministic remotion.config.ts defaults if missing
if [[ ! -f remotion.config.ts ]]; then
  cat > remotion.config.ts <<'TS'
import { Config } from '@remotion/cli/config';

Config.setConcurrency(2);
Config.setTimeoutInMilliseconds(60000);
Config.setVideoImageFormat('jpeg');
Config.setJpegQuality(90);
Config.setOverwriteOutput(true);
TS
  echo "Created hardened remotion.config.ts"
fi

# 4. Pre-flight 1-frame canary check (exposes broken fonts/media in 3s before full render)
mkdir -p "$(dirname "$OUT_MP4")"
npx remotion still src/index.ts "$COMP_ID" "/tmp/${COMP_ID}_canary.png" \
  --frame=15 --props="$PROPS_JSON" --gl="$GL_FLAG" --timeout="$TIMEOUT_MS"

# 5. Full memory-bounded H.264 yuv420p render
npx remotion render src/index.ts "$COMP_ID" "$OUT_MP4" \
  --props="$PROPS_JSON" \
  --concurrency="$CONCURRENCY" \
  --timeout="$TIMEOUT_MS" \
  --gl="$GL_FLAG" \
  --codec=h264 \
  --pixel-format=yuv420p \
  --log=info
```

## Step-by-Step Resolution

1. **Audit every composition for <Video>, remote URLs, and unguarded delayRender() calls:** Search src/ for <Video and delayRender(. Swap every <Video> playing AI clips to <OffthreadVideo src={staticFile(...)} /> backed by locally downloaded plates, and ensure every custom delayRender() calls continueRender(handle) on success and cancelRender(err) on error.
2. **Bound concurrency to RAM and expand Docker /dev/shm to at least 2 GB:** Set --concurrency=2 (or 1 on 4 GB workers), pass --shm-size=2g on every docker run invocation, use --gl=swangle on GPU-less Linux containers, and switch frame capture format to jpeg (quality 90) instead of uncompressed png when compositing opaque video.
3. **Pre-conform 4K AI plates to target resolution and gate batches with a Frame-15 canary:** Downscale 4K source plates to exact composition dimensions (1080×1920 or 1920×1080 CFR) once with FFmpeg before looping 50 Remotion variants, and render one canary still first to verify zero hanging assets.

## Verification Check (Confirm Zero Timeout Warnings, Clean Exit 0 & Valid yuv420p Delivery MP4)

```bash
npx remotion render src/index.ts AdVariant out/test_safe.mp4 --concurrency=2 --timeout=60000 --codec=h264 --pixel-format=yuv420p && ffprobe -v error -select_streams v:0 -show_entries stream=codec_name,pix_fmt,width,height,nb_frames -of csv=p=0 out/test_safe.mp4
```

**Expected healthy output:**

```text
Rendered 360/360 frames cleanly (exit code 0, zero delayRender timeout warnings)
h264,yuv420p,1080,1920,360
```

## Prevention Guardrails

1. **Size concurrency by available RAM (floor(RAM_GB / 2.5)), never by CPU core count:** A 16-vCPU CI runner with only 7 GB RAM will OOM-kill 8 Chromium tabs instantly; capping concurrency at 2 renders faster overall with zero retries.
2. **Never stream expiring signed API URLs directly into Remotion <OffthreadVideo>:** Download Gemini Omni 1.2 Flash, Kling 4.0, or ElevenLabs assets to local disk once before starting a render matrix so a mid-batch 403 or CDN hiccup cannot abort frame 290.
3. **Inspect browser memory flags and set cancelRender(err) on every async fetch:** Calling cancelRender(err) fails fast in 500 ms with the exact stack trace instead of sitting silently for 60 seconds behind a generic delayRender timeout.

## FAQs

### Why does Remotion say 28000ms when the default timeout is 30000ms?

Remotion prints an early warning at 28,000 ms (two seconds before the 30,000 ms hard cutoff) identifying the exact label passed to delayRender() so you can see which component, font, or video stream blocked Chromium.

### Should I just raise --timeout=300000 to make delayRender errors disappear?

No. Raising timeout from 30s to 60s is reasonable for heavy 4K frames or slow cold starts, but masking a leaked delayRender() handle or deadlocked HTML5 <Video> tag with a 5-minute timeout only wastes CI billing minutes before failing anyway.

### Why does switching videoImageFormat from png to jpeg reduce memory crashes?

Unless you are exporting transparent alpha-channel ProRes 4444 or WebM overlays, writing intermediate frame buffers as quality-90 JPEG cuts IPC memory bandwidth and temporary disk usage by 70–85% compared to lossless PNG.

### What causes Target closed in GitHub Actions ubuntu-latest runners specifically?

Standard GitHub Actions runners provide 2–4 vCPUs and ~7–16 GB RAM without a hardware GPU. Leaving --gl at default GPU probing or launching too many concurrent Chromium tabs overloads shared memory—passing --gl=swangle and --concurrency=2 resolves it cleanly.

### Can OffthreadVideo still stall if my input MP4 has huge GOP keyframe intervals?

Yes. AI or screen-recorded MP4s with 10-second keyframe gaps force FFmpeg to decode hundreds of inter-frames per seek. Re-encoding heavy plates once with -g 24 (1-second keyframes) and CFR makes random-access frame extraction near-instant.
