Growing memory usage during screencast recording if the host machine is not able to encode video using ffmpeg fast enough
Summary
A long-lived chrome-devtools-mcp server (spawned by an AI coding-agent CLI via npm exec chrome-devtools-mcp@latest) attached to an existing Chrome with --browserUrl steadily grows its JS heap until it hits the default ~4GB V8 heap limit and aborts. The npm exec wrapper process dies alongside it (unhandled-rejection path → uv_kill), so each event leaves a pair of crashed node processes.
This looks distinct from #1192 / #1214: those were --autoConnect-mode collector leaks fixed in March/April — and indeed we saw ~3 months of clean operation after those fixes. The leak reported here reappeared with 1.2.0+ in --browserUrl mode.
Environment
- chrome-devtools-mcp: crashes observed on 1.2.0 and 1.4.0 (resolved fresh via
npm exec chrome-devtools-mcp@lateston each start) - Invocation:
npm exec chrome-devtools-mcp@latest -- --browserUrl=http://127.0.0.1:<port> --experimentalScreencast - node v23.6.0 (Homebrew), macOS 15.7.2 (Apple Silicon)
- Chrome: current stable, attached via CDP (
--browserUrl), long-lived instance
Workload profile
The server runs for hours-to-days under an agent that repeatedly: takes snapshots, runs frequent evaluate_script polling, and records repeated screencast_start / screencast_stop cycles against a canvas/WebGL-heavy page.
Observed behavior
Seven crash events over 19 days (2026-06-13 → 2026-07-01), all with the identical signature. Time-to-crash shrinks as automation load increases — process lifetime went 2.7 days → 12.7 h → 3.9 h across the last three events, consistent with a load-proportional leak rather than a fixed-rate one.
Faulting thread (named chrome-devtools-mcp), from the macOS crash report:
libsystem_c.dylib abort
node node::OOMErrorHandler(char const*, v8::OOMDetails const&)
node v8::internal::V8::FatalProcessOutOfMemory(...)
node v8::internal::Heap::FatalProcessOutOfMemory(char const*)
node v8::internal::Heap::CollectGarbage(AllocationSpace, GarbageCollectionReason, ...)
node v8::internal::IncrementalMarkingJob::Task::RunInternal()
node node::PerIsolatePlatformData::RunForegroundTask(...)
libuv uv__async_io → uv__io_poll → uv_run
(Other events show the same FatalProcessOutOfMemory via MinorGCJob / mark-compact — i.e., GC can no longer reclaim; the heap is genuinely retained, not fragmentation.)
Secondary: when the server aborts, the parent npm exec wrapper crashes too, inside PromiseRejectReactionJob → node::Kill/uv_kill — a crash-on-crash in the wrapper's rejection handling that might be worth a defensive fix on its own.
What I've ruled out
- Not system memory pressure: no jetsam kill; the stack is V8's internal heap-limit abort.
- Not the screencast temp-file path: frames are written to disk (
fs.mkdtemp→ mp4), so suspicion falls on CDP session/protocol-object retention under sustainedevaluate_script+ screencast churn. - 1.5.0 changelog contains no related fix, so filing this.
Happy to provide
Full (redacted) .ips crash reports for all seven events, Crashpad minidumps, or a run with --heapsnapshot-near-heap-limit instrumentation if that helps pinpoint the retained objects.
Thanks for reporting! What website does it happen with? Does the mcp server operate on a single page app the whole time or are there navigations/reloads involved? Does it require a canvas/WebGL-heavy page or does it happen for other pages for you? Do polling evaluate_script return a lot of data?
I think I can reproduce a similar issue with the screencast, I do not need to use evaluate_script, recording a screencast at https://webglsamples.org/aquarium/aquarium.html is enough. I think the issue might be that one WebGL pages the frames are produced much more frequently and if the encoding takes longer the frames are buffered in the server heap. Stopping the screencast seems to release the memory.
Which ffmpeg version do you use and which video format do you output?
Thanks for the fast triage, and good that the aquarium demo already reproduces it. Your buffering hypothesis matches what we see.
Answers to your questions:
-
Page / website: a Godot 3.x game compiled to WebAssembly, rendering to a WebGL canvas continuously (a live game world, not a static page). So yes, it is a canvas/WebGL-heavy page that produces frames at a high, sustained rate, very much like the aquarium sample.
-
SPA vs navigations: effectively a single long-lived page. The game canvas stays mounted for the whole session. There are occasional navigations between test runs, but the heap growth accumulates during one sustained screencast on the game page, not across navigations/reloads.
-
Does it require WebGL: it correlates strongly with screencast activity on that WebGL page. The growth rate tracks how heavy and continuous the screencast workload is; lighter screencast load gives a much longer time to crash. We have not isolated whether a non-WebGL page under equally continuous screencasting would grow as fast, but the WebGL game page is by far our worst case.
-
evaluate_script data volume: we do run periodic evaluate_script to poll game state, but the payloads are small JSON (a handful of fields), not large. Consistent with your repro, screencast alone appears sufficient to see the growth; evaluate_script is not required to trigger it. It may accelerate things but it is not the driver.
-
ffmpeg and output format: ffmpeg 7.1 (Homebrew build on Apple Silicon macOS, with videotoolbox and libx264). Output is mp4 (we do not pass filePath, so it uses the default mkdtemp screencast.mp4).
Two more data points that support "encoding cannot keep up, frames buffer in the server heap":
- The crash signature is always a V8 OOM abort:
node::OOMErrorHandler -> v8::FatalProcessOutOfMemory -> abort()at the ~4GB heap ceiling (SIGABRT), not an OS OOM kill. - Time-to-crash shrinks as screencast load increases (we have seen roughly 2.7 days down to ~4 hours on the same setup). The machine is also under heavy memory pressure (32GB, swap near full), which would slow ffmpeg throughput and widen the gap between frame production and encoding. Stopping the screencast releases the memory for us too.
Happy to run a targeted repro or capture a heap snapshot mid-growth if that would help.
Thanks for the details, so it is very likely we see the same issue with screencast. So chrome-devtools-mcp records at 30 fps and currently you would need to ensure that your machine can encode without buffering if you do not have enough memory. This is one of the reasons why the feature is experimental. You could also try to reduce the FPS by modifying the code in your local installation here https://github.com/ChromeDevTools/chrome-devtools-mcp/blob/main/src/tools/screencast.ts#L86 (all options https://pptr.dev/api/puppeteer.screencastoptions). If it helps for your use case, maybe we could add an option to control fps to the MCP server parameters. The other alternative would be to drop frames automatically on Puppeteer side but I am not sure if it is a good idea because that would violate the requested fps. I have a draft https://github.com/puppeteer/puppeteer/pull/15211 which solves the memory usage but degrades the quality of the recording.
Note that I think this is technically not a leak as the memory is released if the recording is stop or if ffmpeg becomes fast. You can also increase the heap size via NODE_OPTIONS=--max-old-space-size=8192 or other ways Node allows you to configure the memory. Please let me know if any of this helped!
Yes, an fps option on the MCP server parameters would solve it for us. We run the server via npm exec chrome-devtools-mcp@latest, so patching the local installation does not persist across restarts, and raising the heap ceiling only delays the abort under sustained WebGL load. Our use case is agent-driven test evidence capture, where 10-15 fps is entirely sufficient, so being able to request a lower fps removes the encoding backlog at the source.
For what it is worth, automatic frame dropping (your puppeteer draft) would also be acceptable for our use case: for evidence recordings, a degraded-but-bounded recording beats a server abort. But an explicit fps option is the cleaner contract.
We hit this same failure profile in long-running agent-driven capture sessions on Windows, so I tried to reproduce it and measure whether an fps option actually fixes it.
Setup: Windows 11, node v24.12.0, puppeteer 25.3.0, Chrome for Testing 150, ffmpeg 8.1, headless. I drove page.screencast() directly (the same pipeline screencast_start wraps) against the aquarium sample at 1920x1080, recording for 10 minutes per run and sampling process.memoryUsage() every 10 seconds with a forced GC right before each sample, so the numbers below are retained memory rather than GC noise.
At the default 30 fps, memory grew in a dead-straight line: roughly 1.3 GB/min, from ~670 MB shortly after start to 12.9 GB at the 10-minute mark. At 10 fps, the exact same page and pipeline stayed flat for the entire run, bouncing between ~130 and ~168 MB with no trend at all.
Two things stood out that might be useful for deciding direction:
-
On this platform the growth is almost entirely in
external/arrayBuffers(12.8 GB by the end) while the V8 heap stayed under 25 MB. So unlike the macOS crash reports above, this configuration never hits the 4 GB V8 ceiling — it just keeps growing, presumably until the OS runs out of memory, which seems like the worse failure mode. -
The threshold is clearly workload-dependent: at 1280x720 the same machine kept up fine at 30 fps (shorter runs, but zero sign of accumulation, and ffprobe confirmed full-rate output). That feels like an argument for an optional fps parameter rather than changing the default for everyone.
For our use case an explicit fps option like #2312 would fully solve it — 10-15 fps is plenty for capture work, matching what was said above. Frame dropping on the Puppeteer side would work too. Happy to re-run the same measurement against any candidate implementation if that helps.
— Ayrton R. Goodman
Following up on my earlier measurement with one detail I should have called out initially, because it changes which mitigation is effective.
In this Windows repro, the growth was almost entirely in external and arrayBuffers, reaching approximately 12.8 GB by the 10 minute mark at 1920×1080 and 30 fps, while heapUsed remained below 25 MB throughout the run.
The practical implication is that NODE_OPTIONS=--max-old-space-size is not an effective mitigation for this case. That option raises V8's old space ceiling, while the accumulating bytes here are primarily Buffer and ArrayBuffer backing stores reported as external memory. Raising the ceiling might delay the V8 out of memory failure observed in the macOS report, but it does not correct the producer and consumer imbalance or place a useful bound on this external memory growth. In this Windows configuration, RSS can continue increasing until an allocation or system memory limit intervenes.
This also supports OrKoN's framing that this is not a permanent unreachable memory leak. At 10 fps, the same page and pipeline stayed between approximately 130 and 168 MB without a sustained trend, and stopping the recording released the accumulated memory.
More precisely, the behavior appears to be unbounded queue growth caused by the absence of effective backpressure when frame production exceeds ffmpeg's encoding throughput. Produced but not yet encoded frames remain referenced as pending Node Buffers. Most of their storage appears under external and arrayBuffers, while only the comparatively small JavaScript wrappers reside in the V8 heap. Forced GC cannot release the buffers while the pending encoding work still references them, which is why increasing the old space limit does not address the underlying problem.
Two additional notes:
-
For the 1080p and 30 fps run, the linear memory growth is consistent with an encoding backlog. I will compare the output frame count, duration, and effective frame rate from ffprobe with the wall clock capture duration and recording finalization time. That should help distinguish frames that were buffered and drained later from frames that were dropped, although direct queue or frame acknowledgement instrumentation would provide the strongest confirmation.
-
Two relevant open PRs target the source rather than the memory ceiling. ChromeDevTools PR #2312 exposes the screencast frame rate so the producer rate can be reduced, while
puppeteer/puppeteer#15211introduces backpressure by delaying frame acknowledgements when encoding cannot keep up. The fps option is a workload dependent mitigation, while the Puppeteer change is intended to prevent the pending frame queue from growing without bound.
Happy to repeat the same forced GC sampling against a candidate build or a revised Puppeteer implementation if that would be useful.
— Ayrton R. Goodman
Thank for the the report, we are actively moving away from the FFMPEG implementation and will not be accepting changes for this feature.