From 3f4d699395b6e69df5447853e122777116ca0868 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Tue, 28 Oct 2025 12:20:02 +0100 Subject: [PATCH] :bug: Prevent rendering of unused fill slots in shapes --- common/src/app/common/types/fills/impl.cljc | 12 +++++++++--- render-wasm/src/wasm/fills.rs | 5 ++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/common/src/app/common/types/fills/impl.cljc b/common/src/app/common/types/fills/impl.cljc index 26f3757c6e..beebc29655 100644 --- a/common/src/app/common/types/fills/impl.cljc +++ b/common/src/app/common/types/fills/impl.cljc @@ -301,11 +301,17 @@ IHeapWritable (-get-byte-size [_] - (- (.-byteLength dbuffer) 4)) + ;; Include the 4-byte header with the fill count + (+ 4 (* size FILL-U8-SIZE))) (-write-to [_ heap offset] - (let [buffer' (.-buffer ^js/DataView dbuffer)] - (.set heap (js/Uint32Array. buffer' 4) offset))) + (let [buffer' (.-buffer ^js/DataView dbuffer) + ;; Calculate byte size: 4 bytes header + (size * FILL-U8-SIZE) + byte-size (+ 4 (* size FILL-U8-SIZE)) + ;; Create Uint32Array with exact size needed (convert bytes to u32 elements) + u32-array (js/Uint32Array. buffer' 0 (/ byte-size 4))] + ;; Copy from offset 0 to include the header with fill count + (.set heap u32-array offset))) IBinaryFills (-get-image-ids [_] diff --git a/render-wasm/src/wasm/fills.rs b/render-wasm/src/wasm/fills.rs index 24935e7491..46901816e4 100644 --- a/render-wasm/src/wasm/fills.rs +++ b/render-wasm/src/wasm/fills.rs @@ -70,7 +70,10 @@ pub fn parse_fills_from_bytes(buffer: &[u8], num_fills: usize) -> Vec