Merge pull request #8207 from penpot/alotor-wasm-disable-thumbnail-generation

🐛 Disable thumbnails render in wasm
This commit is contained in:
Aitor Moreno 2026-01-28 13:28:07 +01:00 committed by GitHub
commit 2b00e4eec9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 63 additions and 46 deletions

View File

@ -16,6 +16,7 @@
[app.main.data.profile :as dp] [app.main.data.profile :as dp]
[app.main.data.websocket :as ws] [app.main.data.websocket :as ws]
[app.main.errors] [app.main.errors]
[app.main.features :as feat]
[app.main.rasterizer :as thr] [app.main.rasterizer :as thr]
[app.main.store :as st] [app.main.store :as st]
[app.main.ui :as ui] [app.main.ui :as ui]
@ -87,7 +88,12 @@
(rx/map deref) (rx/map deref)
(rx/filter dp/is-authenticated?) (rx/filter dp/is-authenticated?)
(rx/take 1) (rx/take 1)
(rx/map #(ws/initialize))))))) (rx/map #(ws/initialize)))))
ptk/EffectEvent
(effect [_ state _]
(when-not (feat/active-feature? state "render-wasm/v1")
(thr/init!)))))
(defn ^:export init (defn ^:export init
[options] [options]
@ -97,7 +103,7 @@
(mw/init!) (mw/init!)
(i18n/init) (i18n/init)
(cur/init-styles) (cur/init-styles)
(thr/init!)
(init-ui) (init-ui)
(st/emit! (plugins/initialize) (st/emit! (plugins/initialize)
(initialize))) (initialize)))

View File

@ -105,9 +105,15 @@
(if (dsh/lookup-page state file-id page-id) (if (dsh/lookup-page state file-id page-id)
(rx/concat (rx/concat
(rx/of (initialize-page* file-id page-id) (rx/of (initialize-page* file-id page-id)
(fdf/fix-deleted-fonts-for-page file-id page-id) (fdf/fix-deleted-fonts-for-page file-id page-id))
(dwth/watch-state-changes file-id page-id)
(dwl/watch-component-changes)) ;; Disable thumbnail generation in wasm renderer
(if (features/active-feature? state "render-wasm/v1")
(rx/empty)
(rx/of (dwth/watch-state-changes file-id page-id)))
(rx/of (dwl/watch-component-changes))
(let [profile (:profile state) (let [profile (:profile state)
props (get profile :props)] props (get profile :props)]
(when (not (:workspace-visited props)) (when (not (:workspace-visited props))

View File

@ -191,59 +191,63 @@
[page-id [event [old-data new-data]]] [page-id [event [old-data new-data]]]
(let [changes (:changes event) (let [changes (:changes event)
lookup-data-objects ;; cache for the get-frame-ids function
(fn [data page-id] frame-id-cache (atom {})]
(dm/get-in data [:pages-index page-id :objects]))
(letfn [(lookup-data-objects [data page-id]
(dm/get-in data [:pages-index page-id :objects]))
extract-ids (extract-ids [{:keys [page-id type] :as change}]
(fn [{:keys [page-id type] :as change}] (case type
(case type :add-obj [[page-id (:id change)]]
:add-obj [[page-id (:id change)]] :mod-obj [[page-id (:id change)]]
:mod-obj [[page-id (:id change)]] :del-obj [[page-id (:id change)]]
:del-obj [[page-id (:id change)]] :mov-objects (->> (:shapes change) (map #(vector page-id %)))
:mov-objects (->> (:shapes change) (map #(vector page-id %))) []))
[]))
get-frame-ids (get-frame-ids [id]
(fn get-frame-ids [id] (let [old-objects (lookup-data-objects old-data page-id)
(let [old-objects (lookup-data-objects old-data page-id) new-objects (lookup-data-objects new-data page-id)
new-objects (lookup-data-objects new-data page-id)
new-shape (get new-objects id) new-shape (get new-objects id)
old-shape (get old-objects id) old-shape (get old-objects id)
old-frame-id (if (cfh/frame-shape? old-shape) id (:frame-id old-shape)) old-frame-id (if (cfh/frame-shape? old-shape) id (:frame-id old-shape))
new-frame-id (if (cfh/frame-shape? new-shape) id (:frame-id new-shape)) new-frame-id (if (cfh/frame-shape? new-shape) id (:frame-id new-shape))
root-frame-old? (cfh/root-frame? old-objects old-frame-id) root-frame-old? (cfh/root-frame? old-objects old-frame-id)
root-frame-new? (cfh/root-frame? new-objects new-frame-id) root-frame-new? (cfh/root-frame? new-objects new-frame-id)
instance-root? (ctc/instance-root? new-shape)] instance-root? (ctc/instance-root? new-shape)]
(cond-> #{} (cond-> #{}
root-frame-old? root-frame-old?
(conj ["frame" old-frame-id]) (conj ["frame" old-frame-id])
root-frame-new? root-frame-new?
(conj ["frame" new-frame-id]) (conj ["frame" new-frame-id])
instance-root? instance-root?
(conj ["component" id]) (conj ["component" id])
(and (uuid? (:frame-id old-shape)) (and (uuid? (:frame-id old-shape))
(not= uuid/zero (:frame-id old-shape))) (not= uuid/zero (:frame-id old-shape)))
(into (get-frame-ids (:frame-id old-shape))) (into (get-frame-ids (:frame-id old-shape)))
(and (uuid? (:frame-id new-shape)) (and (uuid? (:frame-id new-shape))
(not= uuid/zero (:frame-id new-shape))) (not= uuid/zero (:frame-id new-shape)))
(into (get-frame-ids (:frame-id new-shape))))))] (into (get-frame-ids (:frame-id new-shape))))))
(into #{} (get-frame-ids-cached [id]
(comp (mapcat extract-ids) (or (get @frame-id-cache id)
(filter (fn [[page-id']] (= page-id page-id'))) (let [result (get-frame-ids id)]
(map (fn [[_ id]] id)) (swap! frame-id-cache assoc id result)
(mapcat get-frame-ids)) result)))]
changes))) (into #{}
(comp (mapcat extract-ids)
(filter (fn [[page-id']] (= page-id page-id')))
(map (fn [[_ id]] id))
(mapcat get-frame-ids-cached))
changes))))
(defn watch-state-changes (defn watch-state-changes
"Watch the state for changes inside frames. If a change is detected will force a rendering "Watch the state for changes inside frames. If a change is detected will force a rendering

View File

@ -108,6 +108,7 @@
"Initializes the rasterizer." "Initializes the rasterizer."
[] []
(let [iframe (dom/create-element "iframe")] (let [iframe (dom/create-element "iframe")]
(dom/set-attribute! iframe "id" "rasterizer")
(dom/set-attribute! iframe "src" origin) (dom/set-attribute! iframe "src" origin)
(dom/set-attribute! iframe "hidden" true) (dom/set-attribute! iframe "hidden" true)
(.addEventListener js/window "message" on-message) (.addEventListener js/window "message" on-message)