-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hot reload clobbers images #4
Comments
The upstream issue might be pixijs/pixijs#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 |
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.
The text was updated successfully, but these errors were encountered: