Repository navigation
slice 4 of 4: Windows capture stack + native Windows client - #86
KooshaPari wants to merge 19 commits into
Conversation
…hat blocked all video The WGC and DXGI capture backends created their device with pAdapter = NULL and DriverType = D3D_DRIVER_TYPE_UNKNOWN. That pairing is invalid: D3D_DRIVER_TYPE_UNKNOWN is only meaningful when an explicit adapter is supplied, so with a NULL adapter it is always E_INVALIDARG (0x80070057). On Windows every capture-backed session therefore failed at device creation, the video pipeline never built, and the host shipped audio with zero video frames (host log: "pipeline build failed ... wgc: D3D11CreateDevice: The parameter is incorrect. (0x80070057)", retried 7 times per session). A NULL adapter means "default adapter", which requires D3D_DRIVER_TYPE_HARDWARE; it is the explicit-adapter case whose only legal value is D3D_DRIVER_TYPE_UNKNOWN. Corroboration that this is the call and not the driver: nvenc_d3d11.rs:406 pairs Some(&adapter) with UNKNOWN (legal) and its capability probe succeeds in the same process on the same GPUs (h264=true h265=true hevc_444=true ten_bit=true). Fixes wgc.rs:224 and dxgi.rs:207 (one token each); the import and comments were updated to record the contract so the pairing does not regress. tx-agent: jcode tx-validated: cargo-check (cargo check -p ss-capture with CMAKE_GENERATOR="Visual Studio 17 2022" and CMAKE_POLICY_VERSION_MINIMUM=3.5, finished clean) (cherry picked from commit a91e14a)
…rer's lifetime
The Windows branch of `capture_virtual_output` consumed the `VirtualOutput` and returned a
capturer that did not take its `keepalive`, so the display backend's RAII mode-restore
(`ModeRestore`, ss-vdisplay/src/display/windows.rs:182-205) dropped the moment the function
returned. Observed live: the head was set to the client mode at :27, WGC attached at :29, the
mode was restored at :31 - roughly 1 ms later, before the encoder even opened - and the
capture surface went back to 2560x1440 while the encoder session had been opened for
1920x1080. NVENC then refused every frame:
error=NVENC (Windows) frame 2560x1440 does not match the open session 1920x1080 resets=1
session ended with error ... error=encoder submit: NVENC (Windows) frame 2560x1440 does not
match the open session 1920x1080
No frames were shipped as a result: the session aborted ~1.5 s into a 20 s probe with
frames=0.
This mirrors the Linux contract rather than inventing one: ss_capture::open_virtual_output
already takes `keepalive: Box<dyn Send>` and the capturer owns it ("the capturer takes
`keepalive`, so dropping it releases the output", ss-capture/src/lib.rs:602-635). WgcCapturer
now does the same via `open_for_monitor_with_keepalive`, exposed as
`ss_capture::open_wgc_desktop_for_monitor_keepalive`, and capture.rs passes `vout.keepalive`.
`open_for_monitor` keeps its signature and passes None, so desktop/other callers are unchanged.
Effect measured on a binary carrying this change but not the D3D11 pairing fix: the session
ran the full 20 s instead of aborting at 1.5 s and the frame-size mismatch no longer appears -
i.e. the lifetime fix is independently effective.
tx-agent: jcode
tx-validated: cargo-check (cargo check -p ss-capture and cargo check -p slipstream-host, both exit 0 with CMAKE_GENERATOR="Visual Studio 17 2022" CMAKE_POLICY_VERSION_MINIMUM=3.5), cargo test -p slipstream-host --bins (374 tests: 368 passed, 6 failed - all pre-existing Windows failures unrelated to capture: library::art::tests::{local_art_path_detection,proxy_local_art_rewrites_only_local_paths}, mgmt::tests::compositors_lists_all_backends_with_flags, ops::store::catalog::tests::ureq_returns_304_as_ok, ops::store::sources::tests::published_index_signature_verifies, session::gamelease::tests::a_launch_always_gets_a_reference_instant_to_adopt_against)
(cherry picked from commit ee16999)
…nterval experiment
Windows capture saturates at ~48 fps (~144/3) across idle, a WinForms animation, and a WPF
per-present animation verified at 133 presents/s. The existing telemetry fused "the source
offered few frames" with "we took few of many": published and overwritten alone cannot tell
those apart. This separates them.
New per-sample counters, surfaced as StatsSample fields so
`/api/v1/stats/capture/live` carries them:
- `capture_frames_arrived` — `FrameArrived` handler invocations (wgc.rs:103-117 area). Bumped via
`FrameSlot::note_frame_arrived`, kept separate from `note_arrival` so the wakeup path is
untouched.
- `capture_try_next_ok` / `capture_try_next_empty` — outcomes of every `pool.TryGetNextFrame()`
in the drain loop, counted by `FrameSlot::note_try_next`.
Carried through `CaptureTelemetry::{frames_arrived, try_next_ok, try_next_empty}` and wired into
both samplers (native slipstream1 loop and the GameStream loop). Other backends fill zeros via
the existing `..Default::default()`.
Also adds the reversible experiment knob `SLIPSTREAM_WGC_MIN_UPDATE_HZ`. Unset (the default)
keeps today's change-driven behaviour exactly. Set, it calls
`GraphicsCaptureSession::SetMinUpdateInterval(TimeSpan)` with `10_000_000 / hz` (100 ns units),
the windows-rs projection of `IGraphicsCaptureSession2::SetMinUpdateInterval`, and logs
`wgc: minimum update interval requested`. Measured verdict from the counters: `arrived`,
`try_next_ok` and `published` all sit at ~48/s (idle: 645 arrivals / 645 publishes over the
session; animated: 654/652) while the presented content changed ~133x/s, i.e. the ceiling is
upstream of the host loop and the ~15 ms queue is our own cycle fed back.
tx-agent: jcode
tx-validated: cargo-check (CMAKE_GENERATOR="Visual Studio 17 2022" CMAKE_POLICY_VERSION_MINIMUM=3.5, cargo check -p ss-capture exit 0 and cargo check -p slipstream-host exit 0), cargo build --release -p slipstream-host exit 0, plus a live 1080p144 HEVC probe on the rebuilt host with the new counters read back from /api/v1/stats/capture/live
(cherry picked from commit 72e7952)
…tion The drain loop materialised each frame (staging map + row copies) before returning to TryGetNextFrame, so the pool's consumer looked slow to the capture session while a copy was in flight. Split into a drain thread that only takes/releases frames (one-deep replace-newest handoff) and a single materialisation thread that owns the immediate context. tx-agent: jcode tx-validated: cargo build --release -p slipstream-host (exit 0); live WGC counters on the host (idle 2 fps/static desktop, 48.0-48.4 fps animated; arrived==try_next_ok==published, overwritten<=3) (cherry picked from commit 773c21b)
…ut path Same divergence fix as fix/capture-method-divergence, carried here because this branch already owns the virtual-output keepalive contract: the opener now opens WGC or DXGI as the plan resolved instead of always WGC, and DXGI gains the keepalive constructor (open_for_monitor_with_keepalive / open_dxgi_desktop_for_monitor_keepalive) so a DXGI session holds the display backend's mode-set for the capturer's lifetime exactly as WGC does. tx-agent: jcode tx-validated: cargo build --release -p slipstream-host (exit 0); regression test opener_agrees_with_the_resolved_plan_for_every_spelling passes on fix/capture-method-divergence (4001c6f), same test text (cherry picked from commit 66b4878)
WGC delivers ~21-26 new frames/s while the desktop presents 143.85/s, our per-frame cost is 2.0-4.9 ms and nothing overflows the slot. That leaves WGC's own production as the gate, and the two things we never looked at were which DXGI adapter the capture device sits on and how deep the frame pool is. (cherry picked from commit 23a628a)
…ission + present seam) Adds clients/windows, the first native Windows client. It is a complete transport client today: `_slipstream._udp` discovery, manual ip:port entry, shared identity persistence, the PIN pairing ceremony, QUIC Hello/Welcome negotiation, the full video-plane receive loop, and `--record` to a playable elementary stream. The window and the D3D11VA/NVDEC decode backend attach at the Decoder/Presenter traits in src/present.rs; they are not in this change because this box has no FFmpeg dev SDK and ss-presenter is Vulkan/Linux-only (every module is cfg(target_os = "linux"), so it compiles to an empty crate here). Reuses slipstream-core (endpoint, NativeClient::pair, Session, UdpTransport) and mirrors clients/probe's proven receive loop rather than reinventing it. Pure-logic seams mirror clients/apple: HostAdvert (fail-closed pair=optional rule), the Admission table, ConnectOutcome classification, and a phase Machine. Verified: cargo build --release -p slipstream-windows -> Finished; cargo test -p slipstream-windows -> 30 passed, 0 failed. Live attempt against 100.112.143.99:9777: host pings but the QUIC handshake did not complete in ~120s (known wedged-host state); zero frames, attempted once. tx-agent: jcode tx-validated: cargo build --release -p slipstream-windows; cargo test -p slipstream-windows (30 passed) (cherry picked from commit 40f9812)
tx-agent: jcode tx-validated: cargo build --release -p slipstream-windows (cherry picked from commit 576fedf)
The present seam now has real backends: - ff.rs: ffmpeg.exe child process (Annex-B AUs on stdin, raw RGBA on stdout) with a stdout reader thread so the pipe cannot deadlock in either direction. The probe has no video decoder to reuse (it only decodes Opus and dumps the HEVC bitstream), and crates/ss-presenter is Linux/Vulkan-only. - window.rs: Win32 window + 32-bpp DIB + StretchDIBits per frame, aspect preserved, closes on X/Esc; logs frames/fps every 2 s. - mf.rs: Media Foundation MFT decoder, opt-in via SLIPSTREAM_WINDOWS_DECODER_MF=1. It enumerates the installed HEVC MFT and accepts every AU but emits no frame: the Microsoft HEVC decoder is an async DXVA MFT and needs a D3D11 device manager. Kept as groundwork for that path. - --play FILE: decode an Annex-B stream into the window with no network, which is how the decode+present stack is proven independently of host state. - Welcome read is bounded to 15 s so a host that handshakes and then stalls fails with that message instead of hanging the client. tx-agent: jcode tx-validated: cargo build --release -p slipstream-windows; cargo test -p slipstream-windows (33 passed); slipstream-windows --play test-1080p144.h265 --mode 1920x1080x144 --seconds 20 -> 720 frames presented in 18.8 s (38.4 fps); live 192.168.1.138:9777 1080p144 8Mbit -> 0 frames, host sent no Welcome (retried twice, probe also stalls) (cherry picked from commit 34b1f44)
The Windows client now streams a real session from the nixos host: 1893 AUs in, 801 frames presented, 31.9 fps over 25.1 s at 1920x1080@144, 8 Mbit/s. What unblocked it: the host was never wedged. It logged "unpaired device knocked — parking connection for delegated approval in the console name=KOOSHAPARI-DESK" and the client's 15 s Welcome bound fired. Approving the pending device on the host (POST /api/v1/native/pending/0/approve -> 200) made the same binary stream. Host bringup for the session: NVENC 1920x1080@144 bit_depth=8 mbps=8, trace first_frame+3575 first_au+4072 first_packet+4085 ms. Known gaps recorded in PR.md and the pixel report: ~16 s to the first presented frame (ffmpeg probe buffering), decode-bound at software HEVC (~55 fps ceiling), no audio, no input, no vsync, no dropped-frame accounting. tx-agent: jcode tx-validated: cargo build --release -p slipstream-windows; cargo test -p slipstream-windows (33 passed); live 192.168.1.138:9777 --mode 1920x1080x144 --bitrate 8000 --seconds 25 -> 1893 AUs, 801 frames presented, 31.9 fps (host bringup first_frame+3575 first_packet+4085) (cherry picked from commit 2abfe99)
…r to 32k, one frame per AU Measured 20 s at 1080p144 against nixos: received 1705, decoded 1630, presented 1630, 81.4 fps, ivl p50 8-12 ms p95 11-14 ms. received-decoded is a constant 75 (pipeline depth, not loss). -probesize 32k/-analyzeduration 0 removes the 5 MB probe stall that cost 8-16 s of black at startup; newest-wins frame delivery was discarding decoded frames and is replaced by one-per-AU. -hwaccel d3d11va/dxva2 measured 3.7 fps on a live stream (pathological), so hwaccel stays opt-in. tx-agent: jcode tx-validated: cargo build --release -p slipstream-windows; live 192.168.1.138:9777 --mode 1920x1080x144 --bitrate 8000 --seconds 20 -> received 1705 decoded 1630 presented 1630, 81.4 fps; hwaccel d3d11va same host -> 95 frames, 3.7 fps (cherry picked from commit 6b84b50)
… control) The 75-frame standing depth was our own unbounded frame channel plus ffmpeg running ahead, not an unavoidable reorder window. sync_channel(3) makes the reader thread block on send when full, which stops ffmpeg reading stdin, which stops us writing AUs; decode_one now pops before writing so freeing a slot never depends on a blocked write. No timer, no dropped frames. 20 s at 1080p144 8 Mbit vs nixos: received 1956, decoded 1936, presented 1936, 96.7 fps (was 1705/1630/1630, 81.4 fps), ivl p50 7.2-9.5 ms p95 8.8-12.0 ms max 10.6-14.8 ms (334 ms spike gone), queue_max 4, blocked writing 39 ms total, first frame unchanged ~1 s, presented == decoded every window. tx-agent: jcode tx-validated: cargo build --release -p slipstream-windows; live 192.168.1.138:9777 --mode 1920x1080x144 --bitrate 8000 --seconds 20 -> received 1956 decoded 1936 presented 1936, 96.7 fps, queue_max 4, blocked_ms 39, ivl p50 7.2-9.5 p95 8.8-12.0 max 14.8 (cherry picked from commit 413db2c)
…stage timings The presenter blitted every frame with StretchDIBits even when the destination was already frame-sized, because the window was created with a frame-sized OUTER rectangle - so the client area was always slightly smaller than the DIB and GDI took its software-resampling path on 8.3 MB of pixels. Create the window with AdjustWindowRect so the CLIENT area is exactly the frame, and blit with SetDIBitsToDevice (a plain copy) whenever dest and source agree, falling back to StretchDIBits only when the user has resized the window away from 1:1. Add the instrumentation that found this and keeps it honest: the presenter now reports cumulative (convert_ns, blit_ns) via Presenter::stage_ns, and the session loop folds poll/decode/present/convert/blit into one per-frame log line. A SLIPSTREAM_PLAY_UNPACED=1 hatch runs the recorded-play path without the pacer so the stack's own cost can be measured instead of the pacer's. Measured against the live desk host with the known-rate generator running (1080p144 session, software ffmpeg decode): blit_ms 0.87 - 3.47 (was the suspected bottleneck; no longer) convert_ms 5.0 - 9.2 (now the dominant cost: CPU RGBA->BGRA of 8.3 MB) present_ms 7.0 - 16.1 decode_ms 0.05 - 1.8 Client present ceiling is therefore ~120 fps and the client is no longer the limiter; the 31.5 fps presented in that run tracks the generator's own 39.8 fps output. The obvious next win is asking ffmpeg for bgra so the channel swap disappears entirely. Work inherited from an agent killed by a server reload before it could commit; built and measured by the coordinator. tx-agent: jcode tx-validated: cargo-build (cherry picked from commit 01b1291)
…e copy per frame The presenter used to swizzle every pixel of every frame: ffmpeg emitted RGBA, `copy_rgba_to_dib` walked 2 M pixels swapping R and B into an 8 MB scratch buffer, and then copied that buffer into the DIB. That is two full passes over 8.3 MB per frame at 1080p plus a per-pixel loop. Ask ffmpeg for `bgra` instead. GDI's 32-bpp BI_RGB DIB is blue-first, so the decoded frame already matches the destination: the presenter's convert step is now a single `copy_nonoverlapping` from the frame into the DIB bits, and the scratch buffer is gone. `DecodedFrame.rgba` becomes `DecodedFrame.pixels` with the byte order spelled out, and the Media Foundation path converts NV12 to the same order so both decoders honour one contract. Measured on this box (1080p, in-process, back-to-back, 200 iterations): old path (swizzle + copy to DIB): 19.19 ms/frame new path (single copy to DIB): 3.61 ms/frame swizzle pass alone: 9.58 ms/frame The GDI blit is unchanged (already 1:1, 0.87-3.47 ms since 01b1291). tx-agent: jcode-win-client tx-validated: test (cherry picked from commit 3a045d2)
A head that cannot honour the requested mode refuses it, and the host corrects
the client's mode slot with `Reconfigured { accepted: true, mode }` carrying what
it can actually encode. The client ignored all of it: the ffmpeg argv, the
reader's frame size, the window client area and the DIB were all sized from the
*requested* mode.
The reader is the fatal part. It allocates one buffer of `width * height * 4` from
the requested size at spawn, and every read is a `read_exact` of exactly that many
bytes. When the host delivers a different geometry the pipe desynchronises and the
reader blocks forever waiting for a byte count that will never arrive. Measured
before this change: request 1512x982@120 against a head that serves 2560x1440 and
the client sat at `present frames=0 fps="0.0"` for 160 s while the host reported
sent=3796 AUs - a black window blamed on the host, caused here.
Four coordinated pieces:
- main.rs: a task keeps reading the control stream (it was otherwise a one-shot
read of `Welcome`) and stores any `Reconfigured` mode; the session loop drains
it, logs "adopting the delivered mode" with from/to, and calls
`decoder.resize()` and `presenter.resize()`.
- ff.rs: `reinit()` respawns the child at the delivered geometry and replays the
buffered AUs, so the replacement starts from the opening parameter sets - the
same discipline as the hwaccel fallback.
- window.rs: `resize()` recreates the DIB at the delivered size and SetWindowPos's
the client area to match, so the 1:1 `SetDIBitsToDevice` fast path survives a
mode change instead of silently refusing every frame.
- present.rs / window.rs: `copy_frame_to_dib` returns on a size mismatch rather
than copying past the buffer, and `Decoder`/`Presenter` gained a no-op `resize`
so backends that do not care stay unchanged.
Verified on the desk host (release build, pid 25252, fingerprint 0f9f361c):
refused 1512x982@120 -> host corrected to 2560x1440@120
528 frames presented in 15.0 s
convert 0.97-1.37 ms, blit 0.05-0.07 ms, present 1.28-1.43 ms, decode 0.01 ms
accepted 1920x1080@144
485 frames presented in 12.0 s (40.4 fps)
convert 0.64-0.74 ms, blit 0.05-0.06 ms, present 0.69-0.81 ms
Both are source-limited by an idle desktop (spin_ms 15-24), not by the client: its
own cost is now ~1.3 ms/frame instead of the 7-16 ms measured before. The window
really did resize, and the log line naming the adopted mode is what makes a
refused mode diagnosable instead of looking like a silent black screen.
tx-agent: jcode
tx-validated: build+run
(cherry picked from commit a9a05cf)
…ailing at 15 s
An unpaired device's first knock is parked host-side for delegated approval with a
180 s window (crates/slipstream-host/src/protocol/slipstream1.rs:757, "parking
connection for delegated approval"). The host holds the connection open and silent
for that whole window before it sends Welcome.
The client gave up on the session offer after 15 s, which made a first connect
succeed only if a human clicked Approve inside a 15 s window - not achievable by
hand. I proved that earlier by racing an approving script against the client: the
same client connects instantly once paired.
Two-phase wait, which is also what the Mac client ships (185 s,
clients/apple SessionModel.swift:365):
- FIRST_OFFER_WAIT = 15 s. On expiry emit a WARN that names the likely cause
("the host has parked this device for approval; approve it in the host console -
still waiting") and keep the SAME connection open.
- APPROVAL_WAIT = 195 s of extra grace, so the total ceiling is 210 s - just past
the host's 180 s park plus room for the approval round trip, so an approval
actually lands on the connection that is already waiting.
- On final failure the message now says what really happened instead of only
blaming a stalled pipeline.
A genuinely wedged capture/encode pipeline still fails, just later and with a
message that mentions both possibilities.
Verified: cargo test -p slipstream-windows --bin slipstream-windows, 34 tests pass,
including offer_wait_outlasts_the_hosts_pairing_park and the assertion that the
narrated wait is shorter than the grace it announces. Not verified end to end:
this identity (KOOSHAPARI-DESK) is already paired, so exercising the unpaired path
would require clearing the live host's pairing file, which is out of bounds.
Written by a worker that was stopped by a server reload before it could build or
commit; built, tested and committed by the coordinator.
tx-agent: jcode
tx-validated: test
(cherry picked from commit f0fd1fa)
…ro-fill Windows capture lands every frame in CPU memory via a full 2560x1440x4 staging readback, but nothing reported what producing a frame COST, so a source delivery ceiling (few FrameArrived events) and a per-frame cost ceiling (each frame takes ~40 ms) were indistinguishable at the stats boundary. (cherry picked from commit 1a34ba1)
…hat blocked all video The WGC and DXGI capture backends created their device with pAdapter = NULL and DriverType = D3D_DRIVER_TYPE_UNKNOWN. That pairing is invalid: D3D_DRIVER_TYPE_UNKNOWN is only meaningful when an explicit adapter is supplied, so with a NULL adapter it is always E_INVALIDARG (0x80070057). On Windows every capture-backed session therefore failed at device creation, the video pipeline never built, and the host shipped audio with zero video frames (host log: "pipeline build failed ... wgc: D3D11CreateDevice: The parameter is incorrect. (0x80070057)", retried 7 times per session). A NULL adapter means "default adapter", which requires D3D_DRIVER_TYPE_HARDWARE; it is the explicit-adapter case whose only legal value is D3D_DRIVER_TYPE_UNKNOWN. Corroboration that this is the call and not the driver: nvenc_d3d11.rs:406 pairs Some(&adapter) with UNKNOWN (legal) and its capability probe succeeds in the same process on the same GPUs (h264=true h265=true hevc_444=true ten_bit=true). Fixes wgc.rs:224 and dxgi.rs:207 (one token each); the import and comments were updated to record the contract so the pairing does not regress. tx-agent: jcode tx-validated: cargo-check (cargo check -p ss-capture with CMAKE_GENERATOR="Visual Studio 17 2022" and CMAKE_POLICY_VERSION_MINIMUM=3.5, finished clean) (cherry picked from commit a91e14a)
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 49 minutes. View limit details
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. |
There was a problem hiding this comment.
Devin Review found 8 potential issues.
6 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
| if args.connect.is_some() | ||
| && (args.discover.is_some() || args.pair.is_some() || args.play.is_some()) | ||
| { | ||
| return Err("--connect cannot be combined with --discover, --pair or --play".into()); | ||
| } |
There was a problem hiding this comment.
🔴 PIN pairing is unreachable
With a host and --pair, parse rejects the command before pairing starts. Without a host, pair fails in target_of. No CLI invocation can complete PIN pairing.
| if args.connect.is_some() | |
| && (args.discover.is_some() || args.pair.is_some() || args.play.is_some()) | |
| { | |
| return Err("--connect cannot be combined with --discover, --pair or --play".into()); | |
| } | |
| if args.connect.is_some() && (args.discover.is_some() || args.play.is_some()) { | |
| return Err("--connect cannot be combined with --discover or --play".into()); | |
| } |
Was this helpful? React with 👍 or 👎 to provide feedback.
| drop(self.au_tx.take()); | ||
| if let Some(w) = self.writer.take() { | ||
| let _ = w.join(); | ||
| } | ||
| let mut out = Vec::new(); | ||
| while let Ok(frame) = self.frames.recv() { |
There was a problem hiding this comment.
🔴 Playback shutdown can deadlock
When playback ends with queued input, finish joins the writer before draining decoded frames. A full three-frame queue blocks FFmpeg output, which blocks the writer's input pipe. Playback then hangs indefinitely, including after window closure.
Learn more
The decoded-frame reader sends into a three-frame bounded channel. If that channel fills, FFmpeg blocks writing stdout and stops consuming stdin, leaving the AU writer blocked in write_all. Waiting for that writer before consuming frames creates a circular wait. A read-only reproduction with real FFmpeg, 120 H.264 frames at 640×360, and the same three-frame queue left the writer blocked with all three queue slots occupied.
Example: Run unpaced playback so compressed input remains queued when the file ends. finish waits for the writer, but only finish can drain the frames needed to unblock it.
Recommended fix: Close the AU sender, drain and present output concurrently with writer completion, and join only after output can no longer block the writer. On cancellation, kill the child instead of flushing the entire backlog. Prefer incremental draining over returning every remaining uncompressed frame in one vector.
Was this helpful? React with 👍 or 👎 to provide feedback.
| let mut data = MFT_OUTPUT_DATA_BUFFER { | ||
| dwStreamID: 0, | ||
| pSample: std::mem::ManuallyDrop::new(Some(osample.clone())), | ||
| dwStatus: 0, | ||
| pEvents: std::mem::ManuallyDrop::new(None), | ||
| }; |
There was a problem hiding this comment.
🔴 Media Foundation output buffers leak continuously
With Media Foundation enabled, drain leaks a cloned sample reference on every output attempt, including MF_E_TRANSFORM_NEED_MORE_INPUT. ManuallyDrop prevents releasing the sample and its attached buffer. Memory grows throughout the session.
Learn more
osample.clone() adds a COM reference, and the sample owns the memory buffer added just above. Wrapping that reference in ManuallyDrop suppresses its release when the output descriptor leaves scope. Success, break, and continue paths all retain the reference, so even an output attempt returning no picture leaks its allocated buffer. Returned event references also require explicit ownership handling.
Example: With a 1920×1080 NV12 output buffer, each leaked sample retains approximately 3.1 MB. Repeated calls reporting that more input is needed still retain one such allocation per attempt.
Recommended fix: Introduce an RAII output-descriptor guard that releases pSample and pEvents on every path after ProcessOutput, including stream changes and errors. Preserve any returned sample long enough for conversion, and validate memory use over a sustained MF decoding session.
Was this helpful? React with 👍 or 👎 to provide feedback.
| let transport = UdpTransport::connect(&format!("0.0.0.0:{udp_port}"), &host_udp.to_string()) | ||
| .context("bind data plane")?; | ||
| let mut session = | ||
| Session::new(cfg, Box::new(transport)).map_err(|e| anyhow!("client session: {e:?}"))?; |
There was a problem hiding this comment.
🔴 Video fails behind client-side NAT
Behind NAT or a stateful inter-VLAN firewall, stream_async never sends a punch from the video socket. spawn_data_punch opens that return path and exposes the translated port. QUIC connects, but video never arrives.
Learn more
A UDP connect selects a peer locally; it sends no packet and creates no NAT mapping. The host data-plane setup waits 2.5 seconds for a punch and otherwise sends to the client-reported port, which is not necessarily the external port. The probe receive setup explicitly starts a punch sender before receiving video.
Example: A Windows client reports local video port 51000, but its router would translate outgoing video-socket traffic to 62000. No outgoing packet creates that mapping, so the host's video to port 51000 cannot reach the client.
Recommended fix: Clone the connected data socket and start spawn_data_punch immediately after binding it, before decoder/window initialization. Stop the punch thread during session teardown and retain the socket throughout setup.
Was this helpful? React with 👍 or 👎 to provide feedback.
| let t_poll = Instant::now(); | ||
| let polled = session.poll_frame(); | ||
| let poll_ns = t_poll.elapsed().as_nanos() as u64; | ||
| let mut spin_ns = 0u64; | ||
| match polled { | ||
| Ok(frame) => { | ||
| last_rx = Instant::now(); | ||
| if frame.flags & FLAG_PROBE as u32 != 0 { | ||
| continue; // speed-test filler, not video | ||
| } | ||
| frames += 1; | ||
| stats.note_au(); | ||
| bytes += frame.data.len() as u64; | ||
| if let Some(s) = sink.as_mut() { | ||
| s.write_all(&frame.data).context("write AU")?; | ||
| } | ||
| let t_dec = Instant::now(); | ||
| let decoded = decoder.decode(&frame.data, codec); |
There was a problem hiding this comment.
🔴 Lost opening keyframes leave video blank
If loss exceeds FEC protection for the opening keyframe, stream_async keeps feeding dependent frames without requesting recovery. The NVENC configuration disables periodic keyframes. Video can remain blank for the session.
Learn more
Session reassembles video and records losses, but it does not own the QUIC control stream used to request replacement keyframes. The probe recovery task sends RequestKeyframe when unrecoverable-frame counts increase. This client implements neither that task nor equivalent frame-gap recovery. An infinite-GOP stream cannot recover missing opening codec parameter sets through later dependent frames alone.
Example: Enough shards of the initial HEVC keyframe are lost to prevent reassembly. Later AUs arrive and increment the received counter, but the decoder never receives the parameter sets needed to display them.
Recommended fix: Publish unrecoverable loss and frame-gap information from the native receive thread to a throttled control-plane recovery sender. Send RequestKeyframe for startup loss and use the existing shared recovery policy where possible. Also expose local decoder backlog drops to recovery rather than assuming the host generates keyframes spontaneously.
Was this helpful? React with 👍 or 👎 to provide feedback.
| video_codecs: slipstream_core::quic::CODEC_H264 | ||
| | slipstream_core::quic::CODEC_HEVC | ||
| | slipstream_core::quic::CODEC_AV1, | ||
| preferred_codec: args.preferred_codec, |
There was a problem hiding this comment.
🔴 Negotiated AV1 sessions abort immediately
With --codec av1 and an AV1-capable host, stream_async negotiates a codec its default decoder cannot open. FfmpegDecoder::spawn rejects AV1. The session aborts before video reception or recording.
Learn more
The host codec negotiation honors the requested codec when both peers advertise it. The Windows client's default FFmpeg decoder only maps H.264 and HEVC to input formats, while its Hello claims AV1 support. Decoder initialization occurs before the receive loop, so the error also prevents --record from receiving data.
Example: Connect to an AV1-capable host with --codec av1 --record out.av1 and no decoder environment overrides. Admission succeeds, then decoder creation returns an unsupported-codec error.
Recommended fix: Derive the advertised codec mask and allowed preferences from the selected decoder, or implement and validate the AV1 input format in the FFmpeg backend. Keep headless recording capability separate from presentation capability.
Was this helpful? React with 👍 or 👎 to provide feedback.
| /// Cumulative source-side arrival callbacks (WGC `FrameArrived`). Compare with | ||
| /// `capture_frames_published` to separate a delivery ceiling from a consumer ceiling. | ||
| #[serde(default)] | ||
| pub capture_frames_arrived: u64, | ||
| /// Cumulative pool drain attempts that returned a frame. | ||
| #[serde(default)] | ||
| pub capture_try_next_ok: u64, | ||
| /// Cumulative pool drain attempts that returned nothing. | ||
| #[serde(default)] | ||
| pub capture_try_next_empty: u64, |
There was a problem hiding this comment.
🟡 Generated telemetry API artifacts remain stale
After adding four telemetry fields to StatsSample, the documentation snapshot and generated SDK schema retain the old shape. CONTRIBUTING requires regenerating both artifacts. The OpenAPI consistency gate fails.
Learn more
The public API snapshot includes capture_frames_arrived, capture_try_next_ok, capture_try_next_empty, and capture_producer_us. The documentation snapshot still matches the base revision, and the SDK's StatsSample schema lacks all four fields. This leaves the checked-in generated artifacts inconsistent.
Example: Comparing the API snapshot with the documentation snapshot returns a difference; the CI OpenAPI comparison therefore fails even when Rust compilation succeeds.
Recommended fix: Follow the generation commands in CONTRIBUTING: regenerate the API snapshot from the host, copy it to the documentation snapshot, and regenerate the TypeScript SDK. Commit all generated changes together.
Was this helpful? React with 👍 or 👎 to provide feedback.
| Err(SlipstreamError::NoFrame) => { | ||
| let t_spin = Instant::now(); | ||
| std::thread::sleep(Duration::from_micros(300)); | ||
| spin_ns = t_spin.elapsed().as_nanos() as u64; |
There was a problem hiding this comment.
🟡 Silent streams disable window close controls
While no video arrives, stream_async only polls and sleeps without pumping window messages. GdiPresenter::present provides the only message pump, so closed() never observes X or Esc. The window remains unresponsive until reception resumes or the session expires.
| Err(SlipstreamError::NoFrame) => { | |
| let t_spin = Instant::now(); | |
| std::thread::sleep(Duration::from_micros(300)); | |
| spin_ns = t_spin.elapsed().as_nanos() as u64; | |
| Err(SlipstreamError::NoFrame) => { | |
| presenter.present(None); | |
| let t_spin = Instant::now(); | |
| std::thread::sleep(Duration::from_micros(300)); |
Was this helpful? React with 👍 or 👎 to provide feedback.
vindeckyy
left a comment
There was a problem hiding this comment.
Not merging this. CI is red on the PR itself: Rust checks, TypeScript SDK, and CodeQL (rust) all fail while main is green, and I reproduced the failures locally. The Devin findings below check out against the code, so fix them instead of arguing with the bot.
Blockers:
-
It does not compile.
cargo check -p slipstream-hostfails with E0063: theCaptureTelemetryinitializer incrates/ss-capture/src/platform/linux/mod.rs:573is missing the four new fields (frames_arrived,try_next_ok,try_next_empty,producer_us). You added the fields to the struct and updated the host-side literal but not the Linux one. This is the Rust checks failure, and CodeQL failing with exit 101 is the same build failure. -
Generated artifacts are stale.
api/openapi.jsonwas regenerated butdocs-site/public/openapi.jsonandsdk/src/gen/slipstream.tswere not. Both the OpenAPI gate and the SDK gate fail on the diff. Regenerate both and commit them together. -
--pairis dead code.parserejects a host combined with--pair, andpair()needsargs.connectto resolve a target, so no CLI invocation can ever complete PIN pairing. Decide the intended CLI shape, fix it, and add a test that actually runshost --pair PINthrough parse. -
ff.rsfinish()deadlocks. It joins the writer thread before draining the 3-deep frame queue. Once the queue fills, ffmpeg blocks writing stdout, stops reading stdin, and the writer blocks inwrite_allforever. Drain concurrently with the writer join. -
mf.rsdrain()leaks on every call.ManuallyDrop::new(Some(osample.clone()))never releases the cloned sample or its buffer, including on theMF_E_TRANSFORM_NEED_MORE_INPUTpath. At 1080p NV12 that is ~3 MB per attempt, growing for the whole session. Use a real RAII guard for the output descriptor. -
No data punch.
stream_asyncnever callsspawn_data_punch, so behind NAT or a stateful firewall the host sends video to the client-reported port and it never arrives. The probe does this atclients/probe/src/session.rs:896. Mirror it. -
No keyframe recovery. There is no
RequestKeyframeanywhere in this client. Lose the opening keyframe and the session stays black, and with periodic keyframes disabled nothing ever fixes it. Mirror the probe recovery task. -
AV1 is advertised but undecodable. Hello claims AV1 and
--codec av1is accepted, butFfmpegDecoder::spawnbails on anything but H.264/HEVC, so an AV1 session aborts before any video. Either stop advertising AV1 or teach the ffmpeg backend AV1. -
The
NoFramespin sleeps without pumping window messages, so X and Esc do nothing while no frames arrive. Present on that path.
Security side is fine: no new dependencies (lock diff is only the new workspace member, everything else was already in the tree), no exfiltration, no auth changes, and the ffmpeg spawn uses fixed args. Fix the nine items above and re-request review.
|
I do not have a working WIndows Client, only Host. Closing this generally until I can validate and accept those features as well. |
|
Fair call. A client PR you cannot validate end to end is not mergeable, and the host side does not compile either, so this cannot land as is. Closing it out. Bring it back as smaller pieces once you can actually run the Windows client against a host. Host-only testing does not cut it here. |
|
GitHub is serving a stale head for this PR: `headRefOid` stays at `09640066` while the branch is at `7f535f46` (`compare` reports ahead_by=24, tip `7f535f46`; an empty refresh commit and a normal push did not update it). Reopening the same work as a fresh PR from the same branch so CI checks the real tip. All blockers from your review are addressed in the new PR except 6 and 7, which need the client runtime that is not on this branch. |
This is slice 4 of 4 (Group B: Windows capture stack + native Windows client) from the agreed split of the old #81 work.
On #81 the maintainer asked for "smaller thematic PRs, each rebased onto current main with CI green", and the operator replied "Will part out with it to small and clean slices", to which he answered "Small clean slices sound perfect, happy to review them as they come in." This PR is the fourth and final slice. It does not reopen or modify #81.
This completes the 46-commit split: 5 (PR #83) + 9 (PR #84) + 11 (PR #85) + 18 (this PR) = 43 included, plus 3 dropped globally.
Commits (18 Group B commits, cherry-picked onto current main 9627d39)
15cc420ca4c27669fc058b2050a20c905f7058f2fix(windows-capture): correct the D3D11 adapter/driver-type pairing that blocked all video05877df7c450801d3f9846c549675835eb4447b3fix(windows-capture): hold the virtual-output keepalive for the capturer's lifetime3106bc2a4b1bbede2066982f67c256b0ea58569bfeat(windows-capture): instrument WGC cadence and gate a min-update-interval experiment58b018505b46f1b723ac38f6b3e95d03e027bc36perf(windows-capture): decouple WGC pool drain from frame materialisation5e67eec54e15d3a3e1c0d9d63b31e9421e8924fdfix(capture): honour the resolved backend on the Windows virtual-output patheddd900673e2f32a911b0581a9ac2b8d68826e20fix(wgc): log the capture adapter and give the frame pool headroom6daa6175d339ef437a734395eb81494f0b179698feat(clients/windows): native Windows session client (transport + admission + present seam)4f4100c2d97748731b5bc55aaa249ee5f4cd4e3achore(clients/windows): lockfile for the new crate5949535daa5e4a79d3361becbee6e80bc0790b28feat(clients/windows): decode HEVC and present frames in a Win32 windowab524fbdcb1351f59d1b9278415f3cd9b06dbd4bdocs(clients/windows): record the live 1080p144 session21a93b7bffe372080bb0a3950a25ce51a7e95404perf(clients/windows): four pipeline counters, cut ffmpeg probe buffer to 32k, one frame per AU96b7f2a387ed11f6932fb75f09c9934b3fdd4cfaperf(clients/windows): bound the decode-ahead queue to 3 frames (flow control)c1a12a4c3d6cf32335912168f7270a21636bad2cperf(clients/windows): 1:1 client area so GDI stops stretching, plus stage timings62e30f5307d10853fe471509557f969488696afbperf(clients/windows): decode straight into DIB byte order (BGRA), one copy per frame28dd0a649363173ecccac42cbf38954158e88148fix(clients/windows): adopt the geometry the host actually deliverse503c7e639d457dc207c97906fb707cd5816b19bfix(clients/windows): wait past the host's approval park instead of failing at 15 s3e0f815fdb4a49904eb3ff224a56bc651e57892fperf(capture): measure per-frame producer cost, drop the per-frame zero-fill5148f437686c393be51fe9f0d10d485f55a6140efix(windows-capture): correct the D3D11 adapter/driver-type pairing that blocked all videoAll 18 Group B commits are included. The two same-subject D3D11 pairing commits are distinct patches in sequence (
15cc420cintroduces the fix;5148f437reapplies it after the producer-cost instrumentation).3e0f815fconflicted instats_recorder.rsbecause earlier Group B picks had already added three of its four fixture fields; the conflict was resolved mechanically by keeping the four fields with no semantic guess. An additional mechanical commit,09640066style: rustfmt Group B sources for current toolchain, makes the touched crates passcargo fmt --checkon the current toolchain. No generatedinclude/slipstream_core.hwas committed.Excluded / dropped
547b6d5b3a4058fcbcdc040c3bb16627f95c59c4fix(host): stop the wire capture-grid drifting ahead at non-native refresh. Already upstream via PR fix(host): stop the wire capture-grid drifting ahead at non-native refresh #77 (23ce1bc2), patch-id match. Dropped from the whole split.dccf2fa3dc455f4163d75d5d0571b26a4bfc270efeat(macos-client): HostAdvert and ConnectOutcome seams. Already upstream via PR feat(macos-client): HostAdvert and ConnectOutcome seams #80 (dcda2ff2), patch-id match. Dropped from the whole split.76c39677b07a5f92a8e422dd273346c944441fb3fix(host): pin the KWin Wayland socket at host startup. Superseded upstream by the reviewed version in PR fix(host): pin the KWin Wayland socket at host startup #79 (e2ff2847). Dropped from the whole split.pr81/merge-base-9627d39lead commits that are exact ancestors of upstream main (merge PR fix(host): stop the wire capture-grid drifting ahead at non-native refresh #77/fix(host): pin the KWin Wayland socket at host startup #79/feat(macos-client): HostAdvert and ConnectOutcome seams #80, pair-TXT trim, KWin socket pin, wire-grid drift) are not included: they are already inorigin/main9627d39.is_socket,FileTypeExt) was introduced.Checks (verbatim)
Toolchain: VS 2026 Build Tools
vcvars64.bat,CARGO_HOME=C:\Users\koosh\Agents\scratch\cargo-home-sliceb(junctions to realregistry,git,bin),CMAKE_POLICY_VERSION_MINIMUM=3.5,CMAKE_GENERATOR=NMake Makefiles,--offline. The NMake-under-vcvars64 recipe was used as-is; thequic-audiofeature-gate fromefefd50bwas not needed because all three checks passed with NMake.cargo check -p slipstream-host --offline-> exit code 0cargo check -p ss-vdisplay --offline-> exit code 0cargo check -p slipstream-windows --offline-> exit code 0cargo fmt -p slipstream-core -- --check-> exit code 0cargo fmt -p slipstream-host -- --check-> exit code 0 (after the mechanical09640066formatting commit)cargo fmt -p ss-capture -- --check-> exit code 0 (after09640066)cargo fmt -p ss-vdisplay -- --check-> exit code 0cargo fmt -p slipstream-windows -- --check-> exit code 0 (after09640066)Logs:
C:\Users\koosh\Agents\scratch\reports\sliceb-final-*.log. The generatedinclude/slipstream_core.hwas restored after each Cargo check and is not present in the branch diff. This is the final slice; no slices remain.