Skip to content
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

Open
Izzimach opened this issue Jan 7, 2015 · 5 comments
Open

Hot reload clobbers images #4

Izzimach opened this issue Jan 7, 2015 · 5 comments
Assignees

Comments

@Izzimach
Copy link
Owner

Izzimach commented Jan 7, 2015

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.

@Izzimach Izzimach self-assigned this Jan 7, 2015
@xeqi
Copy link

xeqi commented Jan 19, 2015

The upstream issue might be pixijs/pixijs#1238. Looks there is a fix ready for v3 (whenever that is released).

@Izzimach
Copy link
Owner Author

Well I guess waiting for pixi v3 is an option. I might add in the hack mentioned there until then though.

@xeqi
Copy link

xeqi commented Jan 20, 2015

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.

@porglezomp
Copy link

This is apparently fixed in Pixi v3, would this be compatible?

@Izzimach
Copy link
Owner Author

Izzimach commented Aug 6, 2016

Still runs on React 0.13, some stuff would need to be updated. I think react-pixi is in cljsjs now though?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants