Recording aborts with encoder backlog at 1920x1080 and leaves zero-byte output
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 framesRecording encoder fell more than 500 ms behind captureThis 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 libvpxandlibx264: availableagent-browser doctor --offline --quick: 0 failures
Reproduction
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 stopObserved result:
Recording encoder fell more than 500 ms behind captureThe 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 framesControlled 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 = 16MAX_ENCODER_LAG = 500 msENCODER_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
- Use latest-frame-wins behavior when the encoder queue is full.
- Drop stale pending frames instead of aborting the recording.
- Report
capturedFrames,encodedFrames, anddroppedFramesfromrecord stop --json. - Preserve and finalize a playable partial recording when overload remains fatal.
- Make the encoder-lag and queue thresholds configurable.
- Add a
--frame-format jpeg|pngoption, or select JPEG automatically for high-resolution viewports. - Include viewport, FPS, queue depth, frame size, codec, and ffmpeg timing in overload diagnostics.
- Document the viewport/FPS trade-off for the new lossless screencast pipeline.
Current workaround
agent-browser --session "$SESSION" set viewport 1280 720
agent-browser --session "$SESSION" record start "$OUTPUT" --fps 10This workaround passed repeatedly in the same environment.
Source: vercel-labs/agent-browser