-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Instantiating more than 4 WebGLRenderers causes black textures #1238
Comments
After testing further it appears that the texture's the problem. I noticed that redText.texture.baseTexture._glTextures is empty after the 5th renderer |
I think I found the problem! This will need some input from a maintainer tho, in WebGLSpriteBatch.prototype.renderBatch the _dirty array never has more than 4 elements. Once WebGLRenderer.gl.id is >= 4 the expression if(texture._dirty[gl.id]) ... always returns undefined and the texture is never updated with the current renderer. Although I'm not exactly sure what the process for setting textures as dirty is, or why there's only ever 4, or even what a dirty texture is. I'm able to get around this problem by manually calling: renderer.updateTexture(redTexture.texture.baseTexture); Directly after I create the texture/sprite Thoughts? |
Hey, I'm having this issue as well. Could anyone shed any light? |
Ran into this issue as well with 5 renderers on the same page. A sprited icon in the last renderer would always render as a black square. As suggested above, calling |
The problem is because of this really ugly line: One fix would be to use an empty initial array for texture._dirty[gl.id] !== false There are a lot of places in PIXI that do the above dirty check so the patch would actually have to go through and change all of them. Instead it would be better to avoid repetition by providing a getter or method to check "dirtyness" of a texture. I think these problems would appear less if Pixi contributors / maintainers took the DRY principle more seriously. EDIT: An alternative approach would be to make |
I've run into this as well now. Is there a workaround for 2.x? I can't go back to 1.6.1 since I need features from 2.x. |
@noseglid 😐 |
Won't really help me.. I don't know how many I need. |
Well most browsers aren't capable of handling more than a couple dozen, so that's a starting point. Why do you need so many? Sent from my iPhone
|
It's not that I have many at the same time. I create and destroy them as I go along. My project is an SPA; so the page is never really reloaded. |
In previous projects I've used a singleton to re-use canvas contexts, but that can arguably get annoying to test and also isn't easily supported by some frameworks. I suspect even if this bug is fixed you will find other issues with Pixi not cleaning up resources from earlier renderers (just off the top of my head: the texture cache). 😞 |
This should be fixed now in v3. Using events from the texture that any number of renderers can listen for to update/destroy that texture. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
If I instantiate and destroy more than 4 WebGLRenderers on a single page I get a black canvas, this behavior is consistent across chrome/ff/safari, I've included a minimal example, any ideas why this would be happening?
I'm in an "mvc" type page where the page is rarely refreshed, changing pages just swaps out content on the page, and my pages have a pixi instances on them.
So calling startPixi() then endPixi() more than 4 times causes this behavior
The text was updated successfully, but these errors were encountered: