Skip to content

fix(diagnostics): Windows samples the backend's memory and FFmpeg children without ps - #1661

Draft
petercr wants to merge 1 commit into
mainfrom
fix/windows-diagnostics-process-sampler
Draft

petercr wants to merge 1 commit into
mainfrom
fix/windows-diagnostics-process-sampler

Conversation

@petercr

@petercr petercr commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator

What a tester's bundle showed

A 0.36.0 Windows tester's support bundle (the same one behind #1639) reported 0 FFmpeg processes and no backend memory for the whole run.

The runtime resource sampler forks ps -axo pid=,ppid=,rss=,comm= every second on every platform except macOS. Windows has no ps, so every sample failed into an empty snapshot:

  • Diagnostics showed "FFmpeg processes 0" and no "Engine memory".
  • Health's Memory check sat on "—", so its 1 GB warning and 2 GB error never fired on Windows.
  • The metrics journal recorded no RSS and no FFmpeg count.

Even with rows, the name check compared ffmpeg against ffmpeg.exe, so it would have missed FFmpeg anyway.

Change (diagnostics.rs)

Windows now reads one Toolhelp process snapshot per second and never forks.

  • Memory: the backend's own row carries its working set (K32GetProcessMemoryInfo). This adds the Win32_System_ProcessStatus feature to windows, which only this backend and the WER helper use.
  • Tree: a process joins the backend's tree only if it is still running (zero-timeout wait) and started no earlier than the parent it names. Windows never clears a parent pid and can reuse it, so without this an unrelated process could count as ours.
  • Names: match without a Windows .exe suffix (executable_stem). The capture worker ffmpeg-capture.exe is still not counted as an FFmpeg process.
  • Testability: the walk is a pure function (windows_tree_rows) so its rules run in tests on every platform.

Linux keeps ps. macOS keeps libproc with ps as its fallback.

Tests

  • windows_executable_names_count_as_ffmpeg_and_ffprobe (every platform)
  • windows_tree_rows_leave_out_reused_parent_pids_and_exited_processes (every platform)
  • windows_process_rows_read_own_working_set_and_count_an_ffmpeg_exe_child (Windows): copies the test binary to a scratch ffmpeg.exe, runs its fixture as a real child, and reads back the child and the backend's working set. It kills, reaps and cleans up on drop.

Run on the Windows laptop (Intel UHD 620, PowerShell 7, debug test binary):

  • diagnostics:: 45 passed, 0 failed
  • the new Windows filter 25 of 25 passed
  • the full backend suite 3 of 3 passed (5,365 passed, 0 failed, 29 ignored, ~84 s each)
  • no scratch folders left behind
  • cargo fmt --check and the pre-push hook are clean

Not yet run

  • Local cargo clippy (debug and release). CI runs both.
  • A packaged-app check that Diagnostics and Health show the numbers. The backend change is unit-covered, and the UI fields were already wired.

🤖 Generated with Claude Code

…ldren without `ps`

A 0.36.0 Windows tester's support bundle reported 0 FFmpeg processes and no
backend memory for its whole run. The runtime resource sampler forks
`ps -axo` every second on every platform but macOS, and Windows has no `ps`,
so every sample failed into an empty snapshot: Diagnostics showed
"FFmpeg processes 0" and no engine memory, and Health's Memory check sat on
"—" so its 1 GB warn and 2 GB error never fired there. Even with rows, the
name check compared `ffmpeg` against `ffmpeg.exe`.

Windows now reads one Toolhelp snapshot a second and never forks:
- the backend's own row carries its working set (K32GetProcessMemoryInfo,
  `Win32_System_ProcessStatus`, used only by this backend and the WER helper)
- a process joins the backend's tree only while it runs and when it started
  no earlier than the parent it names: a Windows parent pid is never cleared
  and can be reused
- names match without a Windows `.exe` suffix (`executable_stem`); the
  capture worker `ffmpeg-capture.exe` is still not an FFmpeg process

Linux keeps `ps`; macOS keeps libproc with `ps` as its fallback.

Tests: `.exe` names and their counts, and the reused-pid and exited-process
rules (every platform); a Windows test runs this binary's fixture as a real
`ffmpeg.exe` child and reads it and the backend's working set back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@petercr
petercr marked this pull request as draft November 22, 2026 03:24
@coderabbitai

coderabbitai Bot commented Nov 22, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

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.

1 participant