From a3119bef5e38984071287f03881d98c4123c41b0 Mon Sep 17 00:00:00 2001 From: Elena Torro Date: Fri, 9 Jan 2026 12:56:01 +0100 Subject: [PATCH] :wrench: Show message and button to reload the page when WebGL context is lost --- frontend/src/app/main/ui/static.cljs | 14 ++++++++++++++ frontend/src/app/render_wasm/api.cljs | 5 +++-- frontend/translations/en.po | 9 +++++++++ frontend/translations/es.po | 9 +++++++++ 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/main/ui/static.cljs b/frontend/src/app/main/ui/static.cljs index 1140ee319b..96ec92fd8b 100644 --- a/frontend/src/app/main/ui/static.cljs +++ b/frontend/src/app/main/ui/static.cljs @@ -308,6 +308,16 @@ [:div {:class (stl/css :sign-info)} [:button {:on-click on-click} (tr "labels.retry")]]])) +(mf/defc webgl-context-lost* + [] + (let [on-reload (mf/use-fn #(js/location.reload))] + [:> error-container* {} + [:div {:class (stl/css :main-message)} (tr "labels.webgl-context-lost.main-message")] + [:div {:class (stl/css :desc-message)} (tr "labels.webgl-context-lost.desc-message")] + [:div {:class (stl/css :buttons-container)} + [:> button* {:variant "primary" :on-click on-reload} + (tr "labels.reload-page")]]])) + (defn- generate-report [data] (try @@ -437,6 +447,7 @@ (rx/of default) (rx/throw cause))))))) + (mf/defc exception-section* {::mf/private true} [{:keys [data route] :as props}] @@ -469,6 +480,9 @@ :service-unavailable [:> service-unavailable*] + :webgl-context-lost + [:> webgl-context-lost*] + [:> internal-error* props]))) (mf/defc context-wrapper* diff --git a/frontend/src/app/render_wasm/api.cljs b/frontend/src/app/render_wasm/api.cljs index f2e1d133a4..3059462cd6 100644 --- a/frontend/src/app/render_wasm/api.cljs +++ b/frontend/src/app/render_wasm/api.cljs @@ -10,6 +10,7 @@ ["react-dom/server" :as rds] [app.common.data :as d] [app.common.data.macros :as dm] + [app.common.exceptions :as ex] [app.common.files.helpers :as cfh] [app.common.logging :as log] [app.common.math :as mth] @@ -21,7 +22,6 @@ [app.common.types.text :as txt] [app.common.uuid :as uuid] [app.config :as cf] - [app.main.data.render-wasm :as drw] [app.main.refs :as refs] [app.main.render :as render] [app.main.store :as st] @@ -1236,7 +1236,8 @@ (dom/prevent-default event) (reset! wasm/context-lost? true) (log/warn :hint "WebGL context lost") - (st/emit! (drw/context-lost))) + (ex/raise :type :webgl-context-lost + :hint "WebGL context lost")) (defn init-canvas-context [canvas] diff --git a/frontend/translations/en.po b/frontend/translations/en.po index fedd5e7e82..8524ffd135 100644 --- a/frontend/translations/en.po +++ b/frontend/translations/en.po @@ -2521,6 +2521,9 @@ msgstr "Release notes" msgid "labels.reload-file" msgstr "Reload file" +msgid "labels.reload-page" +msgstr "Reload page" + #: src/app/main/ui/workspace/libraries.cljs, src/app/main/ui/dashboard/team.cljs #, unused msgid "labels.remove" @@ -8475,6 +8478,12 @@ msgstr "Recent" msgid "labels.deleted" msgstr "Deleted" +msgid "labels.webgl-context-lost.main-message" +msgstr "Oops! The canvas context was lost" + +msgid "labels.webgl-context-lost.desc-message" +msgstr "WebGL has stopped working. Please reload the page to reset it" + msgid "dashboard.restore-all-deleted-button" msgstr "Restore All" diff --git a/frontend/translations/es.po b/frontend/translations/es.po index 2101493c92..ff4edb86de 100644 --- a/frontend/translations/es.po +++ b/frontend/translations/es.po @@ -2502,6 +2502,9 @@ msgstr "Notas de versión" msgid "labels.reload-file" msgstr "Recargar archivo" +msgid "labels.reload-page" +msgstr "Recargar página" + #: src/app/main/ui/workspace/libraries.cljs, src/app/main/ui/dashboard/team.cljs #, unused msgid "labels.remove" @@ -8328,6 +8331,12 @@ msgstr "Recientes" msgid "labels.deleted" msgstr "Eliminados" +msgid "labels.webgl-context-lost.main-message" +msgstr "Ups! Se ha perdido el contexto del canvas" + +msgid "labels.webgl-context-lost.desc-message" +msgstr "WebGL ha dejado de funcionar. Por favor, recarga la página para restaurarlo" + msgid "dashboard.restore-all-deleted-button" msgstr "Restaurar todo"