Merge pull request #7687 from penpot/ladybenko-12440-fix-corrupt-files
Some checks failed
_DEVELOP / build-bundle (push) Has been cancelled
_DEVELOP / build-docker (push) Has been cancelled
_STAGING / build-bundle (push) Has been cancelled
_STAGING / build-docker (push) Has been cancelled
Commit Message Check / Check Commit Message (push) Has been cancelled

🐛 Fix wasm crash when loading a file with missing font assets
This commit is contained in:
Alejandro Alonso
2025-11-05 07:57:39 +01:00
committed by GitHub
3 changed files with 114 additions and 107 deletions

View File

@@ -102,12 +102,13 @@
(defn use-shape
[id]
(when wasm/context-initialized?
(let [buffer (uuid/get-u32 id)]
(h/call wasm/internal-module "_use_shape"
(aget buffer 0)
(aget buffer 1)
(aget buffer 2)
(aget buffer 3))))
(aget buffer 3)))))
(defn set-parent-id
[id]
@@ -1078,13 +1079,15 @@
;; Initialize Wasm Render Engine
(h/call wasm/internal-module "_init" (/ (.-width ^js canvas) dpr) (/ (.-height ^js canvas) dpr))
(h/call wasm/internal-module "_set_render_options" flags dpr)))
(h/call wasm/internal-module "_set_render_options" flags dpr))
(set! wasm/context-initialized? true))
(set-canvas-size canvas)
context-init?))
(defn clear-canvas
[]
;; TODO: perform corresponding cleaning
(set! wasm/context-initialized? false)
(h/call wasm/internal-module "_clean_up"))
(defn show-grid

View File

@@ -13,6 +13,7 @@
[app.common.types.shape.layout :as ctl]
[app.main.refs :as refs]
[app.render-wasm.api :as api]
[app.render-wasm.wasm :as wasm]
[beicon.v2.core :as rx]
[cljs.core :as c]
[cuerdas.core :as str]))
@@ -126,6 +127,7 @@
;; The `set-wasm-attr!` can return a list of callbacks to be executed in a second pass.
(defn- set-wasm-attr!
[shape k]
(when wasm/context-initialized?
(let [v (get shape k)
id (get shape :id)]
(case k
@@ -233,7 +235,7 @@
(api/set-flex-layout shape)))
;; Property not in WASM
nil)))
nil))))
(defn process-shape!
[shape properties]
@@ -256,8 +258,9 @@
(rx/mapcat (fn [[shape-id props]] (process-shape! (get objects shape-id) props)))
(rx/subs!
(fn [_]
(when wasm/context-initialized?
(api/update-shape-tiles)
(api/request-render "set-wasm-attrs")))))
(api/request-render "set-wasm-attrs"))))))
;; `conj` empty set initialization
(def conj* (fnil conj #{}))

View File

@@ -3,3 +3,4 @@
(defonce internal-frame-id nil)
(defonce internal-module #js {})
(defonce serializers #js {})
(defonce context-initialized? false)