From 35a65703c6cb1f26216b9f3089fed56abe9ecdae Mon Sep 17 00:00:00 2001 From: GhaZy Date: Sat, 31 Oct 2026 14:23:19 +0200 Subject: [PATCH] fix(scap-direct3d): compare in-flight frames to pool size instead of content size (#3594) Resolves issue #3594 where Windows desktop recording immediately stalls at 0 seconds and self-terminates after a 5-second timeout. - When follow_item_size is enabled, in-flight frame drops should discard frames whose surface texture dimensions do not match the expected pool dimensions before a pool recreation. - Comparing (surface_desc.Width, surface_desc.Height) against (content_width, content_height) erroneously dropped all window capture frames because Windows.Graphics.Capture window surfaces include drop shadows and invisible resize borders that differ from content bounds. - Replaces the content size comparison with the active pool_size, allowing valid window frames to be trimmed and processed rather than dropped. --- crates/scap-direct3d/src/lib.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/crates/scap-direct3d/src/lib.rs b/crates/scap-direct3d/src/lib.rs index 92e37f9d34..a580eda3f2 100644 --- a/crates/scap-direct3d/src/lib.rs +++ b/crates/scap-direct3d/src/lib.rs @@ -730,11 +730,18 @@ impl Capturer { // A frame queued before the pool was recreated: its // surface is the old size, and the next frame is not. - if follow_item_size - && (surface_desc.Width, surface_desc.Height) - != (content_width, content_height) - { - return Ok(()); + if follow_item_size { + let (expected_width, expected_height) = { + let size = pool_size + .lock() + .unwrap_or_else(|poisoned| poisoned.into_inner()); + (size.0.max(0) as u32, size.1.max(0) as u32) + }; + if (surface_desc.Width, surface_desc.Height) + != (expected_width, expected_height) + { + return Ok(()); + } } let frame = if let Some((cropped_texture, crop)) = crop_data.clone() {