From b9b75805c91eed9cd89c0702d7eb7d9d5f566441 Mon Sep 17 00:00:00 2001 From: Elena Torro Date: Mon, 27 Jul 2026 16:48:36 +0200 Subject: [PATCH] :wrench: Warn at startup when headless wasm export is enabled --- exporter/src/app/core.cljs | 8 ++++++++ exporter/src/app/renderer/wasm.cljs | 2 +- exporter/src/app/wasm.cljs | 12 +++++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/exporter/src/app/core.cljs b/exporter/src/app/core.cljs index 5ce68ebf98..35ebd830bd 100644 --- a/exporter/src/app/core.cljs +++ b/exporter/src/app/core.cljs @@ -12,6 +12,7 @@ [app.config :as cf] [app.http :as http] [app.redis :as redis] + [app.wasm :as wasm] [promesa.core :as p])) (enable-console-print!) @@ -23,6 +24,13 @@ :public-uri (str (cf/get :public-uri)) :internal-uri (str (cf/get-internal-uri)) :version (:full cf/version)) + (when (cf/get :wasm-headless) + (l/warn :msg "headless wasm export enabled (experimental)" + :hint (str "renders run in-process on a single shared wasm module " + "and are serialized one at a time, so exports do not " + "run concurrently; not recommended for busy instances") + :wasm-dir (wasm/artifact-dir) + :image-cache-mb (wasm/image-cache-mb))) (p/do! (bwr/init) (redis/init) diff --git a/exporter/src/app/renderer/wasm.cljs b/exporter/src/app/renderer/wasm.cljs index 92bc31e734..f4594d8bd2 100644 --- a/exporter/src/app/renderer/wasm.cljs +++ b/exporter/src/app/renderer/wasm.cljs @@ -442,7 +442,7 @@ ;; Trim the image store AFTER the request (never mid-render, so ;; an image can't disappear under a running export). Images the ;; next request needs again are simply re-provisioned. - (let [evicted (wasm/evict-images! (cf/get :wasm-image-cache-mb 256))] + (let [evicted (wasm/evict-images! (wasm/image-cache-mb))] (when (pos? evicted) (l/info :hint "wasm render: evicted cached images" :count evicted))) result)) diff --git a/exporter/src/app/wasm.cljs b/exporter/src/app/wasm.cljs index 2fcceb4ccf..8607166044 100644 --- a/exporter/src/app/wasm.cljs +++ b/exporter/src/app/wasm.cljs @@ -44,10 +44,20 @@ ;; get_fonts_for_shape entry: [uuid 16 bytes][weight u32][style u32]. (def ^:private FONT-ENTRY-BYTES 24) -(defn- artifact-dir +(defn artifact-dir + "Directory holding the built render-wasm artifact (render-wasm.js/.wasm). + The docker image points `PENPOT_WASM_DIR` at the copy shipped inside the + exporter bundle; the default is where `render-wasm/build` leaves it in + devenv." [] (cf/get :wasm-dir "../frontend/resources/public/js")) +(defn image-cache-mb + "Byte budget (in MB) the wasm image store is trimmed down to between + requests. See `evict-images!`." + [] + (cf/get :wasm-image-cache-mb 256)) + (defn- read-result-bytes "Reads `len` bytes from the WASM heap starting at `offset`, copying them out (via `.slice`) before the buffer is freed."