From a11037f427120eca807cd86fd60bb4c4c152ed9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bel=C3=A9n=20Albeza?= Date: Fri, 24 Apr 2026 09:59:31 +0200 Subject: [PATCH] :bug: Avoid race condition in initialize-workspace --- frontend/src/app/main/data/profile.cljs | 12 ++++++------ frontend/src/app/main/data/workspace.cljs | 12 ++++++++---- .../src/app/main/ui/workspace/viewport/hooks.cljs | 1 - frontend/translations/en.po | 2 +- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/frontend/src/app/main/data/profile.cljs b/frontend/src/app/main/data/profile.cljs index 82ecbcbb36..4233e8a826 100644 --- a/frontend/src/app/main/data/profile.cljs +++ b/frontend/src/app/main/data/profile.cljs @@ -292,13 +292,13 @@ ;; FIXME ptk/WatchEvent (watch [_ _ _] - (let [refresh-profile$ (->> (rp/cmd! :update-profile-props {:props props}) - (rx/map (constantly (refresh-profile)))) - recompute$ (when (contains? props :renderer) + (let [refresh-profile (->> (rp/cmd! :update-profile-props {:props props}) + (rx/map (constantly (refresh-profile)))) + recompute (when (contains? props :renderer) (rx/of (features/recompute-features)))] - (if recompute$ - (rx/concat recompute$ refresh-profile$) - refresh-profile$))))) + (if recompute + (rx/concat recompute refresh-profile) + refresh-profile))))) (defn mark-onboarding-as-viewed ([] (mark-onboarding-as-viewed nil)) diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index 37bdd54a03..b17aa417bb 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -75,6 +75,7 @@ [app.main.store :as st] [app.render-wasm :as wasm] [app.render-wasm.api :as wasm.api] + [app.render-wasm.wasm :as wasm-state] [app.util.dom :as dom] [app.util.globals :as ug] [app.util.http :as http] @@ -319,7 +320,10 @@ (let [stoper-s (rx/filter (ptk/type? ::finalize-workspace) stream) rparams (rt/get-params state) features (features/get-enabled-features state team-id) - render-wasm? #(features/active-feature? @st/state "render-wasm/v1")] + render-wasm-enabled? #(features/active-feature? @st/state "render-wasm/v1") + render-wasm-ready? #(and (render-wasm-enabled?) + wasm-state/context-initialized? + (not @wasm-state/context-lost?))] (log/debug :hint "initialize-workspace" :team-id (dm/str team-id) @@ -330,7 +334,7 @@ (rx/concat ;; Fetch all essential data that should be loaded before the file (rx/merge - (if ^boolean (render-wasm?) + (if ^boolean (render-wasm-enabled?) (->> (rx/from @wasm/module) (rx/filter true?) (rx/tap (fn [_] @@ -408,7 +412,7 @@ (->> stream (rx/filter dch/commit?) - (rx/filter (fn [_] (render-wasm?))) + (rx/filter (fn [_] (render-wasm-ready?))) (rx/map deref) (rx/mapcat (fn [{:keys [redo-changes]}] @@ -421,7 +425,7 @@ (let [local-commits-s (->> stream (rx/filter dch/commit?) - (rx/filter (fn [_] (render-wasm?))) + (rx/filter (fn [_] (render-wasm-ready?))) (rx/map deref) (rx/filter #(and (= :local (:source %)) (not (contains? (:tags %) :position-data)))) diff --git a/frontend/src/app/main/ui/workspace/viewport/hooks.cljs b/frontend/src/app/main/ui/workspace/viewport/hooks.cljs index 02f86b21e7..225dde4fd9 100644 --- a/frontend/src/app/main/ui/workspace/viewport/hooks.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/hooks.cljs @@ -31,7 +31,6 @@ [app.main.ui.workspace.viewport.utils :as utils] [app.main.worker :as mw] [app.render-wasm.api :as wasm.api] - [app.render-wasm.wasm :as wasm] [app.util.debug :as dbg] [app.util.dom :as dom] [app.util.globals :as globals] diff --git a/frontend/translations/en.po b/frontend/translations/en.po index bdc358cc19..978694deff 100644 --- a/frontend/translations/en.po +++ b/frontend/translations/en.po @@ -1166,7 +1166,7 @@ msgid "dashboard.webgl-switch.beta" msgstr "Beta" msgid "dashboard.webgl-switch.description" -msgstr "WebGL rendering can improve performance, but it is in beta and may be less stable. Some visual differences may appear between the canvas, exports (SVG/​​PDF), and view mode." +msgstr "WebGL rendering can improve performance, but it is in beta and may be less stable. Some visual differences may appear between the canvas, exports (SVG/PDF), and view mode." msgid "dashboard.webgl-switch.status" msgstr "Status"