Skip to content

video-start/video-stop produces 0-byte files when navigations occur during recording #321

@kenwang-coursera

Description

@kenwang-coursera

Version

  • @playwright/cli: 0.1.1
  • bundled playwright: 1.59.0-alpha-1771104257000
  • Node: v20.12.2
  • OS: macOS 26.3.1 (Darwin arm64)

Repro

playwright-cli open
playwright-cli goto https://news.ycombinator.com
playwright-cli video-start
playwright-cli goto https://news.ycombinator.com/newest
playwright-cli snapshot
playwright-cli goto https://news.ycombinator.com/ask
playwright-cli snapshot
playwright-cli goto https://news.ycombinator.com/show
playwright-cli snapshot
playwright-cli goto https://news.ycombinator.com
playwright-cli snapshot
playwright-cli video-stop --filename=output.webm
ls -lh output.webm
# => output.webm is 0 bytes

Expected

output.webm contains a valid video recording of the browser session.

Actual

output.webm is 0 bytes (empty file).

Reproduction Rate

5/5 — tested with 5 independent parallel sessions (-s=repro1 through -s=repro5), all produced 0-byte files.

Additional Observations

  • Works with a single navigation: video-start → one gotovideo-stop produces a valid video
  • Not site-specific: reproduces with any website (tested with Hacker News, Coursera, example.com)
  • Adding sleep before video-stop does NOT help: even sleep 10 before stop still produces 0 bytes after multiple navigations
  • Headless and headed both affected
  • Chrome (system) and Chromium (bundled) both affected
  • Closing and reopening the browser resets the issue: after close + open, the first video cycle works again
  • Progressive degradation on static pages: with repeated video-start/video-stop cycles on a static page (no navigations between), video file sizes degrade progressively (25K → 14K → 1.9K) before stabilizing at 1.9K (white fallback frame only)

Secondary Issue: --filename flag

Separately, video-stop defines filename as an --option but documentation and intuitive usage suggest it should be a positional arg:

# Fails: "error: too many arguments: expected 0, received 1"
playwright-cli video-stop output.webm

# Works
playwright-cli video-stop --filename=output.webm

Possible Root Cause (AI-assisted — may not be accurate)

The following analysis was performed by Claude (AI) by reading the source code. It has not been verified by the maintainers and may be incorrect:

  • video-start calls Page.startScreencast via CDP, and sets up a ScreencastFrame event listener that feeds frames to an ffmpeg process via stdin
  • Multiple rapid navigations appear to cause Chrome to stop emitting Page.screencastFrame CDP events entirely — the screencast becomes permanently dead for that browser instance
  • When video-stop is called with 0 frames received, VideoRecorder.stop() creates a white fallback frame and writes it to ffmpeg. However, the output file ends up 0 bytes — possibly because saveAs() copies the file before ffmpeg has fully flushed/closed the output
  • The startScreencast method in screencast.js only sends the CDP Page.startScreencast command once (when the first client registers) and does not re-issue it after navigations, which may be why Chrome stops delivering frames

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions