From 9ab653db26b6af3ae970ba431f94adde6acc9cfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Thu, 24 Sep 2026 16:10:59 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(decode):=20the=20visualizer?= =?UTF-8?q?=20seat=20masks=20what=20it=20declares,=20and=20floors=20nothin?= =?UTF-8?q?g?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The wave lane's worker declaration carried a `.max(2)` floor under the even mask. It kept the worker alive, but it broke the decode lane's inherited answer for a canvas with no size: a `Composer::passthrough()` canvases came back as a 2x2 picture instead of the empty one it asked for, whose own test caught it on the first full run of the merged tree. The mask alone is what both need: the declared size is the size the planes really have, so the conversion always has the chroma plane it indexes, while a canvas with nothing to divide still takes the painter's empty picture (`empty_peaks_paint_the_flat_line`'s neighbour in `visualizer_window_i420`). Witnessed at 1920x1, 1921x1081, 320x1 and 321x181 through the seat and through `set_resolution`. --- crates/engine/src/decode.rs | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/crates/engine/src/decode.rs b/crates/engine/src/decode.rs index 8379a76..2a59391 100644 --- a/crates/engine/src/decode.rs +++ b/crates/engine/src/decode.rs @@ -650,15 +650,18 @@ impl DecodeSession { // the picture *is* the canvas, and whatever transform the clip // carries still reaches it through the render below. // - // Masked to even dimensions first, and floored at two: that is what the - // painter does to the planes it hands back, so a canvas it cannot divide - // evenly (an odd `resolution 1921 1081` line, or a one-pixel-high one) - // used to be *declared* at a size the picture never had -- and the - // conversion below then indexes a chroma plane that is not there - // (`index out of bounds` on a zero-length slice, in this worker, where - // no frame ever arrives and nothing catches it). + // Masked to even dimensions first: that is what the painter does to the + // planes it hands back, so a canvas it cannot divide evenly (an odd + // `resolution 1921 1081` line, or a one-pixel-high one) used to be + // *declared* at a size the picture never had -- and the conversion below + // then indexes a chroma plane that is not there (`index out of bounds` + // on a zero-length slice, in this worker, where no frame ever arrives + // and nothing catches it). No floor under the mask: a canvas with no + // size is asked for no picture, and the painter answers that with empty + // planes ([`visualizer_window_i420`]), which the declared size now + // matches. let (canvas_w, canvas_h) = canvas.dims(); - let (width, height) = ((canvas_w & !1).max(2), (canvas_h & !1).max(2)); + let (width, height) = (canvas_w & !1, canvas_h & !1); let worker_cancel = Arc::clone(&cancel); let path = path.to_path_buf(); let handle = thread::Builder::new() @@ -2883,9 +2886,12 @@ mod tests { 0, ) .unwrap_or_else(|e| panic!("open the visualizer at {w}x{h}: {e}")); - let frame = stream.frames.recv_timeout(Duration::from_secs(30)).unwrap_or_else(|e| { - panic!("a picture for a {w}x{h} canvas, not a worker that died instead: {e}") - }); + let frame = stream + .frames + .recv_timeout(Duration::from_secs(30)) + .unwrap_or_else(|e| { + panic!("a picture for a {w}x{h} canvas, not a worker that died instead: {e}") + }); assert_eq!( (frame.width, frame.height), (w, h),