mirror of
https://github.com/penpot/penpot.git
synced 2026-08-01 10:56:20 +00:00
🐛 Fix too many active WEBGL contexts
This commit is contained in:
parent
1738847694
commit
1388865cfc
@ -1244,6 +1244,8 @@
|
|||||||
(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})]
|
||||||
(.makeContextCurrent ^js gl handle)
|
(.makeContextCurrent ^js gl handle)
|
||||||
|
(set! wasm/gl-context-handle handle)
|
||||||
|
(set! wasm/gl-context context)
|
||||||
|
|
||||||
;; Force the WEBGL_debug_renderer_info extension as emscripten does not enable it
|
;; Force the WEBGL_debug_renderer_info extension as emscripten does not enable it
|
||||||
(.getExtension context "WEBGL_debug_renderer_info")
|
(.getExtension context "WEBGL_debug_renderer_info")
|
||||||
@ -1266,6 +1268,20 @@
|
|||||||
(set! wasm/context-initialized? false)
|
(set! wasm/context-initialized? false)
|
||||||
(h/call wasm/internal-module "_clean_up")
|
(h/call wasm/internal-module "_clean_up")
|
||||||
|
|
||||||
|
;; Ensure the WebGL context is properly disposed so browsers do not keep
|
||||||
|
;; accumulating active contexts between page switches.
|
||||||
|
(when-let [gl (unchecked-get wasm/internal-module "GL")]
|
||||||
|
(when-let [handle wasm/gl-context-handle]
|
||||||
|
(try
|
||||||
|
;; Ask the browser to release resources explicitly if available.
|
||||||
|
(when-let [ctx wasm/gl-context]
|
||||||
|
(when-let [lose-ext (.getExtension ^js ctx "WEBGL_lose_context")]
|
||||||
|
(.loseContext ^js lose-ext)))
|
||||||
|
(.deleteContext ^js gl handle)
|
||||||
|
(finally
|
||||||
|
(set! wasm/gl-context-handle nil)
|
||||||
|
(set! wasm/gl-context nil)))))
|
||||||
|
|
||||||
;; If this calls panics we don't want to crash. This happens sometimes
|
;; If this calls panics we don't want to crash. This happens sometimes
|
||||||
;; with hot-reload in develop
|
;; with hot-reload in develop
|
||||||
(catch :default error
|
(catch :default error
|
||||||
|
|||||||
@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
(defonce internal-frame-id nil)
|
(defonce internal-frame-id nil)
|
||||||
(defonce internal-module #js {})
|
(defonce internal-module #js {})
|
||||||
|
(defonce gl-context-handle nil)
|
||||||
|
(defonce gl-context nil)
|
||||||
(defonce serializers
|
(defonce serializers
|
||||||
#js {:blur-type shared/RawBlurType
|
#js {:blur-type shared/RawBlurType
|
||||||
:blend-mode shared/RawBlendMode
|
:blend-mode shared/RawBlendMode
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user