diff --git a/frontend/src/app/main/data/viewer.cljs b/frontend/src/app/main/data/viewer.cljs index 87b9c1007b..1d9c49f9d3 100644 --- a/frontend/src/app/main/data/viewer.cljs +++ b/frontend/src/app/main/data/viewer.cljs @@ -222,7 +222,12 @@ (watch [_ state _] (if (and (features/active-feature? state "render-wasm/v1") (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 (reduce-kv @@ -233,13 +238,12 @@ [] objects) - ;; Creates a stream from the async callback. This stream will only - ;; emit one single value after the objects have finished loading - ;; in the wasm memory. + ;; Positive size required: OffscreenCanvas(0, 0) crashes + ;; `_set_render_options` on some browsers. set-objects-stream (rx/create (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)) nil))] diff --git a/frontend/src/app/render_wasm/api.cljs b/frontend/src/app/render_wasm/api.cljs index a96353dea4..388c3611d7 100644 --- a/frontend/src/app/render_wasm/api.cljs +++ b/frontend/src/app/render_wasm/api.cljs @@ -2175,6 +2175,9 @@ browser (sr/translate-browser cf/browser) dpr (get-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))] (when-not (nil? context) (let [handle (.registerContext ^js gl context #js {"majorVersion" 2})]