fix(video): hide the ffmpeg console window on Windows by dmitgush · Pull Request #43520 · microsoft/playwright · GitHub
Skip to content

fix(video): hide the ffmpeg console window on Windows - #43520

Open
Daniel (dmitgush) wants to merge 1 commit into
microsoft:mainfrom
dmitgush:fix-43515-ffmpeg-windows-console
Open

Daniel (dmitgush) wants to merge 1 commit into
microsoft:mainfrom
dmitgush:fix-43515-ffmpeg-windows-console

Conversation

@dmitgush

Copy link
Copy Markdown

Summary

Fixes #43515.

On Windows, the ffmpeg process that Playwright starts for video recording gets a visible console window of its own. launchProcess() never passed windowsHide to child_process.spawn(), so ffmpeg inherits (or creates) a console - since #42155 the CLI session daemon runs detached with windowsHide: true and has no console of its own, any console program it starts (ffmpeg) gets a brand new window, which steals focus every time a recording starts.

#41630 asked for windowsHide: true on every launchProcess call, and was closed as not planned: an earlier attempt at exactly that (#38776) was reverted in #39994 after it broke Inspector, codegen and UI mode (#39990) - those child processes have real windows of their own that windowsHide would also hide.

This PR makes windowsHide an opt-in field on LaunchProcessOptions (default unset, so behavior elsewhere is unchanged) and sets it only for the ffmpeg launch in videoRecorder.ts, since ffmpeg has no GUI and nothing to hide incorrectly.

// packages/utils/processLauncher.ts
const spawnOptions: childProcess.SpawnOptions = {
  detached: process.platform !== 'win32',
  env: options.env,
  cwd: options.cwd,
  shell: options.shell,
  windowsHide: options.windowsHide,   // new, opt-in
  stdio,
};
// packages/playwright-core/src/server/videoRecorder.ts
const { launchedProcess, gracefullyClose } = await launchProcess({
  command: this._ffmpegPath,
  args,
  stdio: 'stdin',
  windowsHide: true,                  // new
  ...

Test plan

  • The reporter validated this exact change on real Windows 11 hardware: polled every visible top-level window every 250ms during a recording with the patch applied, confirmed no window appeared, and confirmed the recorded webm was still written correctly.
  • windowsHide is a Windows-only child_process option (no-op elsewhere per Node docs), so there's nothing to assert about window visibility in CI on Linux/macOS, and the prior related fix for the same file (fix(windows): hide console window when spawning browser processes #38776) shipped the same way, with manual Windows verification only, no automated test.
  • Ran the full video.spec.ts suite (31 tests) on macOS with the change - all pass, confirming the new field doesn't change ffmpeg's behavior off Windows.
  • npx eslint and npx tsc -p . on the changed files - clean.

🤖 Generated with Claude Code

launchProcess() builds its spawn() options without windowsHide, so on
Windows the ffmpeg process started for video recording gets a console
window of its own (inherited from the terminal, or newly created when
the parent has none - e.g. the CLI session daemon, which has run
detached with windowsHide: true since microsoft#42155). One window appears per
recording and steals focus.

microsoft#41630 asked for windowsHide on every launchProcess call, but that was
closed as not planned: an earlier attempt (microsoft#38776) was reverted in
microsoft#39994 after it broke Inspector, codegen and UI mode (microsoft#39990), since
those processes do have real windows of their own. ffmpeg has none, so
make windowsHide an opt-in LaunchProcessOptions field and set it only
for the ffmpeg launch in videoRecorder.ts, leaving every other
launchProcess call unaffected.

Fixes microsoft#43515
@dmitgush

Copy link
Copy Markdown
Author

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Video recording on Windows opens a visible console window for ffmpeg

1 participant