fix(engine): hide ffmpeg console windows on Windows - #3381
Conversation
ffmpeg and ffprobe are console-subsystem binaries and Node defaults windowsHide to false, so every spawn opened a visible console window on Windows. A render shells out dozens of times across parallel workers, which flashed a burst of windows across the user's desktop. Applied at every production spawn site rather than only the two named in the report, since they all share the cause: runFfmpeg, both gpuEncoder probes, ffprobe, streamingEncoder, audioExtractor and the distributed version check. windowsHide is a no-op on macOS and Linux. The dev-only parity and regression harnesses are left alone; they never run on a user's desktop. Closes #3379
|
Scope note, from a second Windows report that landed after this PR was opened. This PR closes the ffmpeg/ffprobe half. It does not close the browser half, and I want
Those windows come from Puppeteer's own launcher, not from any spawn in this repo. this.#browserProcess = childProcess.spawn(this.#executablePath, this.#args, {
detached: opts.detached,
env,
stdio,
});No So the remaining half needs one of:
Worth deciding which before closing the original issue, since a Windows user with this PR |
What
Pass
windowsHide: trueat every production ffmpeg/ffprobe spawn site.Closes #3379.
Why
ffmpegandffprobeare console-subsystem binaries, and Node'schild_process.spawndefaults
windowsHidetofalse. Every spawn therefore opens a visible console window onWindows. A render shells out dozens of times across parallel workers, so the reporter saw a
burst of windows appear and disappear across their desktop, ~11 at once with 6 capture
workers.
Cosmetic, but it is the first impression of a render on Windows.
How
The report named two call sites. Seven production sites share the cause, so all seven
are fixed rather than the two mentioned:
engine/src/utils/runFfmpeg.tsengine/src/utils/gpuEncoder.ts-encodersprobeengine/src/utils/gpuEncoder.tsengine/src/utils/ffprobe.tsengine/src/services/streamingEncoder.tsproducer/src/services/audioExtractor.tsproducer/src/services/distributed/shared.tsffmpeg -versioncheckwindowsHideis a no-op on macOS and Linux, so it is applied unconditionally.Left alone deliberately:
parity-harness.ts,regression-harness.tsandmediaTypeTestFixtures.tsall spawn ffmpeg too, but they are dev-only tooling that neverruns on a user's desktop. Changing them would widen the diff without changing the reported
behaviour.
Test plan
Regression test
runFfmpeg.windowsHide.test.tsmockschild_processand asserts on the options objectactually handed to
spawn:Asserted on behaviour rather than on source text, so a future call site that drops the flag
is caught by what it does, not by how it is written.
Verified it fails without the fix:
Other checks
vitest packages/engine/src/utils/— 651 passed, 20 filesoxlint+oxfmton all 7 touched files — cleanBefore / after
I do not have a Windows machine, so I cannot capture the desktop screenshots this one
really wants. The observable change is at the spawn boundary, and that is what the test
pins:
The reporter's repro repo is linked in #3379 and is the right way to confirm the desktop
behaviour on a real Windows box before merge.