From 2901d0086209dff2312ab2e300c5fd98c3daafb8 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 21 Apr 2026 15:35:06 +0200 Subject: [PATCH] :bug: Fix errors in thumbnails --- frontend/src/app/render_wasm/api.cljs | 6 +++--- frontend/src/app/render_wasm/wasm.cljs | 3 +++ frontend/src/app/worker/thumbnails.cljs | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/render_wasm/api.cljs b/frontend/src/app/render_wasm/api.cljs index a68d3d1b24..897ea4aa55 100644 --- a/frontend/src/app/render_wasm/api.cljs +++ b/frontend/src/app/render_wasm/api.cljs @@ -334,7 +334,7 @@ (defn request-render [_requester] - (when (and wasm/context-initialized? (not @wasm/context-lost?)) + (when (and wasm/context-initialized? (not @wasm/context-lost?) (not @wasm/disable-request-render?)) (if @shapes-loading? (register-deferred-render!) (when-not @pending-render @@ -1698,6 +1698,8 @@ [] (when wasm/context-initialized? (try + (set! wasm/context-initialized? false) + ;; Cancel any pending animation frame to prevent race conditions (when wasm/internal-frame-id (js/cancelAnimationFrame wasm/internal-frame-id) @@ -1708,8 +1710,6 @@ (reset! shapes-loading? false) (reset! deferred-render? false) - ;; TODO: perform corresponding cleaning - (set! wasm/context-initialized? false) (h/call wasm/internal-module "_clean_up") ;; Remove event listener for WebGL context lost diff --git a/frontend/src/app/render_wasm/wasm.cljs b/frontend/src/app/render_wasm/wasm.cljs index 5c43ba4899..25c2908575 100644 --- a/frontend/src/app/render_wasm/wasm.cljs +++ b/frontend/src/app/render_wasm/wasm.cljs @@ -26,6 +26,9 @@ (defonce context-initialized? false) (defonce context-lost? (atom false)) +;; When we're rendering in a sync way we want to stop the asynchrous `request-render` +(defonce disable-request-render? (atom false)) + (defonce serializers #js {:blur-type shared/RawBlurType diff --git a/frontend/src/app/worker/thumbnails.cljs b/frontend/src/app/worker/thumbnails.cljs index d90536619d..d7692d63d4 100644 --- a/frontend/src/app/worker/thumbnails.cljs +++ b/frontend/src/app/worker/thumbnails.cljs @@ -170,6 +170,7 @@ (render/calculate-dimensions objects thumbnail-aspect-ratio)) zoom (/ width (:width vbox))] + (reset! wasm/disable-request-render? true) (wasm.api/initialize-viewport objects zoom vbox :background bgcolor