Merge remote-tracking branch 'origin/main' into staging

This commit is contained in:
Andrey Antukh 2026-07-27 08:52:31 +02:00
commit eda5aa76f0
2 changed files with 12 additions and 5 deletions

View File

@ -222,7 +222,12 @@
(watch [_ state _] (watch [_ state _]
(if (and (features/active-feature? state "render-wasm/v1") (if (and (features/active-feature? state "render-wasm/v1")
(contains? cf/flags :available-viewer-wasm)) (contains? cf/flags :available-viewer-wasm))
(let [objects (dsh/lookup-page-objects state file-id page-id) ;; Fallback matches the viewer UI when the URL omits page-id.
(let [page-id (or page-id
(-> (dsh/lookup-file-data state file-id)
:pages
first))
objects (dsh/lookup-page-objects state file-id page-id)
shapes shapes
(reduce-kv (reduce-kv
@ -233,13 +238,12 @@
[] []
objects) objects)
;; Creates a stream from the async callback. This stream will only ;; Positive size required: OffscreenCanvas(0, 0) crashes
;; emit one single value after the objects have finished loading ;; `_set_render_options` on some browsers.
;; in the wasm memory.
set-objects-stream set-objects-stream
(rx/create (rx/create
(fn [subs] (fn [subs]
(wasm.api/init-canvas-context (js/OffscreenCanvas. 0 0)) (wasm.api/init-canvas-context (js/OffscreenCanvas. 64 64))
(wasm.api/set-objects-callback shapes #(rx/push! subs :done)) (wasm.api/set-objects-callback shapes #(rx/push! subs :done))
nil))] nil))]

View File

@ -2175,6 +2175,9 @@
browser (sr/translate-browser cf/browser) browser (sr/translate-browser cf/browser)
dpr (get-dpr) dpr (get-dpr)
[css-w css-h] (canvas-css-size canvas dpr) [css-w css-h] (canvas-css-size canvas dpr)
;; Avoid 0×0 Skia/GL surfaces (crashes on some browsers).
css-w (mth/max 1 css-w)
css-h (mth/max 1 css-h)
can-listen? (fn? (.-addEventListener ^js canvas))] can-listen? (fn? (.-addEventListener ^js canvas))]
(when-not (nil? context) (when-not (nil? context)
(let [handle (.registerContext ^js gl context #js {"majorVersion" 2})] (let [handle (.registerContext ^js gl context #js {"majorVersion" 2})]