Open Izzimach opened 9 years ago
The upstream issue might be GoodBoyDigital/pixi.js#1238. Looks there is a fix ready for v3 (whenever that is released).
Well I guess waiting for pixi v3 is an option. I might add in the hack mentioned there until then though.
This got more annoying as I kept building. Ended up adding a hack to my project to attempt cleanup and reseting PIXI's internals around webgl, contexts, and textures.
om/IWillUnmount
(will-unmount [_]
;;PIXI v2 leaks gl objects and has a hardcoded
;;limit of 4 glcontexts. Lets cleanup for them
;;and reset the id to 0 so we can hot-reload
;;without issue
;; Allow the renderer to cleanup
(.destroy (aget js/PIXI.instances 0))
(doseq [texture (vals (js->clj js/PIXI.TextureCache))
:let [bt (.-baseTexture texture)]]
;; mark the texture dirty so it will regenerate the glTexture for the correct context
(.dirty bt)
;; remove reference to glTexture from previous context
;; hopefully it can be GC'd now
(.. bt -_glTextures pop))
;; reset the id used for the renderer/context
;; this is used implicitly as the index for renderer->glTextures and renderer->context mappings
;; hence some of the cleanup above
(set! js/PIXI.WebGLRenderer.glContextId 0))
This is sufficient for my case as I only have one PIXI.Stage
/webgl context/renderer on screen at a time.
This is apparently fixed in Pixi v3, would this be compatible?
Still runs on React 0.13, some stuff would need to be updated. I think react-pixi is in cljsjs now though?
When hot-reloading with figwheel the images will sometimes vanish and sprites will then display black boxes instead of the proper image. The interactive example shows this pretty well.