From 78caabba7ef91cd1030da6f70b41d266704ffece Mon Sep 17 00:00:00 2001 From: Hojjat Date: Mon, 13 Apr 2026 11:49:44 -0600 Subject: [PATCH] fix: load image synchronously if no callback is set --- wgpu/src/image/cache.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/wgpu/src/image/cache.rs b/wgpu/src/image/cache.rs index 5e8059e8..097a383f 100644 --- a/wgpu/src/image/cache.rs +++ b/wgpu/src/image/cache.rs @@ -398,10 +398,16 @@ fn load_image<'a>( // Load RGBA handles synchronously, since it's very cheap cache.insert(handle, Memory::load(handle)); } else if !pending.contains_key(&handle.id()) { - let _ = pending.insert(handle.id(), Vec::from_iter(callback)); + if callback.is_some() { + let _ = pending.insert(handle.id(), Vec::from_iter(callback)); - #[cfg(not(target_arch = "wasm32"))] - worker.load(handle); + #[cfg(not(target_arch = "wasm32"))] + worker.load(handle); + } else { + // Synchronous fallback when no callback is provided, + // needed for one-shot renders like drag icon screenshots + cache.insert(handle, Memory::load(handle)); + } } }