From fad5e712e7613e806dfed5c69c6109965f4697f1 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Fri, 28 Aug 2026 13:14:15 +0200 Subject: [PATCH] :zap: Chunk stale text resize into batches on page load Process resize-wasm-text-all in groups of 64 with a short delay between chunks so propagate-modifiers does not block the main thread on large pages. --- frontend/src/app/main/data/workspace.cljs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index d9afb0cc62..616b502702 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -507,11 +507,19 @@ ;; Resize auto-grow text shapes whose selrect does not match ;; the WASM text layout once their fonts finish loading. + ;; Process in chunks so a large page does not freeze the main + ;; thread with one propagate-modifiers pass. (->> stream (rx/filter (ptk/type? :app.render-wasm.api/stale-text-selrects)) (rx/map deref) - (rx/map (fn [{:keys [ids]}] - (dwwt/resize-wasm-text-all ids)))) + (rx/mapcat + (fn [{:keys [ids]}] + (apply rx/merge + (map-indexed + (fn [idx chunk] + (cond->> (rx/of (dwwt/resize-wasm-text-all chunk)) + (pos? idx) (rx/delay (* idx 50)))) + (partition-all 64 ids)))))) (let [local-commits-s (->> stream