Recording aborts with encoder backlog at 1920x1080 and leaves zero-byte output

Author: gumi-bdCreated Sep 22, 2026Updated Sep 26, 2026

Summary

agent-browser 0.38.1 aborts recordings at large viewport sizes because the live ffmpeg encoder falls behind Chrome capture. The failed take is left missing or zero bytes, so the entire recording is lost.

We reproduced both fatal overload paths:

Recording encoder fell behind by more than 16 buffered frames
Recording encoder fell more than 500 ms behind capture

This affects ordinary browser-test recordings started with a maximized browser or a 1920x1080 viewport. The same workflows recorded successfully with agent-browser 0.27.x.

Environment

  • agent-browser: 0.38.1
  • Chrome for Testing: 152.0.7977.64
  • OS: Linux x86_64
  • CPU: 8 vCPUs
  • Memory available during reproduction: approximately 28 GiB
  • Display: 1920x1080
  • ffmpeg: 6.1.1
  • libvpx and libx264: available
  • agent-browser doctor --offline --quick: 0 failures

Reproduction

bash
SESSION=recording-repro
OUTPUT=/tmp/recording-repro.webm

DISPLAY=:1 AGENT_BROWSER_HEADED=true \
  agent-browser --session "$SESSION" open https://example.com \
  --args '--no-sandbox,--disable-gpu,--start-maximized'

agent-browser --session "$SESSION" set viewport 1920 1080
agent-browser --session "$SESSION" record start "$OUTPUT" --fps 10
agent-browser --session "$SESSION" wait 8000
agent-browser --session "$SESSION" record stop

Observed result:

Recording encoder fell more than 500 ms behind capture

The WebM file is zero bytes or absent after the failure.

A default/maximized 30 fps recording also reproduced:

Recording encoder fell behind by more than 16 buffered frames

Controlled comparison

Viewport FPS Format Result
Maximized / approximately 1920x1080 30 WebM Fails: 16-frame buffer exceeded
Maximized / approximately 1920x1080 10 WebM Fails: encoder exceeds 500 ms lag
1280x720 10 WebM Passes
1280x720 10 MP4 Passes

Removing --cursor and --contact-sheet did not fix the maximized recording. Changing the codec did not appear to be the controlling factor.

Suspected regression area

PR #1763 moved recording from screenshot polling to Page.startScreencast.

PR #1806 changed the pipeline to lossless PNG frames and introduced these fatal overload limits:

  • ENCODER_FRAME_BUFFER = 16
  • MAX_ENCODER_LAG = 500 ms
  • ENCODER_WRITE_TIMEOUT = 2 s

The previous pipeline dropped old pending frames to keep the picture current. The current pipeline aborts the take when capture outpaces PNG processing and ffmpeg input.

Expected behavior

Encoder pressure should not destroy the entire recording. The recorder should preserve wall-clock timing and produce a playable file, even if some captured frames must be dropped.

Suggested improvements

  1. Use latest-frame-wins behavior when the encoder queue is full.
  2. Drop stale pending frames instead of aborting the recording.
  3. Report capturedFrames, encodedFrames, and droppedFrames from record stop --json.
  4. Preserve and finalize a playable partial recording when overload remains fatal.
  5. Make the encoder-lag and queue thresholds configurable.
  6. Add a --frame-format jpeg|png option, or select JPEG automatically for high-resolution viewports.
  7. Include viewport, FPS, queue depth, frame size, codec, and ffmpeg timing in overload diagnostics.
  8. Document the viewport/FPS trade-off for the new lossless screencast pipeline.

Current workaround

bash
agent-browser --session "$SESSION" set viewport 1280 720
agent-browser --session "$SESSION" record start "$OUTPUT" --fps 10

This workaround passed repeatedly in the same environment.

Source: vercel-labs/agent-browser