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

WebGL Render Warning if cacheAsBitmap is true #3767

Closed
jsfi opened this issue Feb 20, 2017 · 14 comments
Closed

WebGL Render Warning if cacheAsBitmap is true #3767

jsfi opened this issue Feb 20, 2017 · 14 comments
Labels
🙏 Feature Request Community request for new features, APIs, packages. Stale Previously “Won’t Fix”, bots should tag with this for inactive issues or pull-requests. 💾 v4.x (Legacy) Legacy version 4 support

Comments

@jsfi
Copy link

jsfi commented Feb 20, 2017

If cacheAsBitmap is set to true on a container that is empty or has only invisible children, Chrome (v56) and Firefox (v49) log a WebGL warning.

Warning Chrome:

[.Offscreen-For-WebGL-0000005524CBB4F0] GL ERROR :GL_INVALID_FRAMEBUFFER_OPERATION : glClear: framebuffer incomplete
[.Offscreen-For-WebGL-0000005524CBB4F0] RENDER WARNING: texture bound to texture unit 0 is not renderable. It maybe non-power-of-2 and have incompatible texture filtering.

Warning Firefox:

Error: WebGL: clear: Incomplete framebuffer: Status 0x8cd6: COLOR_ATTACHMENT0 has no width or height.
Error: WebGL: drawElements: Active texture 0 for target 0x0de1 is 'incomplete', and will be rendered as RGBA(0,0,0,1), as per the GLES 2.0.24 $3.8.2: The dimensions of `level_base` are not all positive.

Example: https://codepen.io/anon/pen/PWrXOB

Actual use-case: I have a container with n sprite elements. Depending on the state of the application I want to show 0 to n of the elements (by setting visible to true/false). After updating which sprites are visible, the container can be cached. If all elements are set to invisible the warnings appear.

My suggestion would be to extend the condition in
DisplayObject.prototype._renderCachedWebGL (and maybe in DisplayObject.prototype._renderCachedCanvas to be consistent) to include a check for width and height of the element.

if (!this.visible || this.worldAlpha <= 0 || !this.renderable)
{
  return;
}

to

if (!this.visible || this.worldAlpha <= 0 || !this.renderable || this.width === 0 || this.height === 0)
{
  return;
}

I can create a Pull request if you like the solution but I wanted to discuss it first as I am not sure if it's the only/best place for a fix.

@bigtimebuddy bigtimebuddy added Plugin: cacheAsBitmap 🙏 Feature Request Community request for new features, APIs, packages. 💾 v4.x (Legacy) Legacy version 4 support labels Feb 20, 2017
@ivanpopelyshev
Copy link
Collaborator

better not use "width" and "height" , they are properties

@jsfi
Copy link
Author

jsfi commented Feb 21, 2017

Is it better to use the bounds Object in DisplayObject.prototype._initCachedDisplayObject?

If the renderTexture is only created when bounds.width > 0 && bounds.height > 0, the cached sprite uses Texture.EMPTY as a fallback which doesn't trigger the warnings.

@ivanpopelyshev
Copy link
Collaborator

I'm not sure that bounds won't be changed later. Its better to add flag to cached object that renderTexture is empty, or may be reference Texture.EMPTY instead, and then check it in rendering method

@jsfi
Copy link
Author

jsfi commented Feb 21, 2017

Maybe I understand something wrong, but aren't the bounds used to generate the texture?

https://github.com/pixijs/pixi.js/blob/dev/src/extras/cacheAsBitmap.js#L186

If either width or height are zero, the texture should be empty. So by checking width and height first, it is possible to step over lines 178 to 205 and create the sprite without texture (which will automatically use Texture.Empty https://github.com/pixijs/pixi.js/blob/dev/src/core/sprites/Sprite.js#L103)

@BossLevel
Copy link

Referencing my previously closed #3418 issue - it's just reared it's head again, and having read this, I can confirm that the relevant container has zero children at the time. I'd turned off cacheAsBitmap previously and this must have been what resulted in a resolution.

@neutrino84
Copy link
Contributor

@ivanpopelyshev I was looking at the cacheAsBitmap implementation, and it seems bit heavy - would simply rendering to a texture do the trick? Cobbled something that sees to work, although, you need access the gl

@ivanpopelyshev
Copy link
Collaborator

@neutrino84 is does rendering into the texture and it works. what's the problem?

jsfi added a commit to jsfi/pixi.js that referenced this issue Feb 23, 2017
jsfi added a commit to jsfi/pixi.js that referenced this issue Feb 23, 2017
Fix WebGL Render Warning if cacheAsBitmap is true pixijs#3767
jsfi added a commit to jsfi/pixi.js that referenced this issue Feb 23, 2017
@jsfi
Copy link
Author

jsfi commented Feb 23, 2017

Sorry for the spam, I didn't know all commits would be referenced.

Maybe some code makes it clearer what I think would be a good solution. Please ignore the first two commits.

@PixelsCommander
Copy link

Also see this problem on Intel HD graphics card. So it is hardware related, but let`s be fair, IntelHD is world most popular built-in chip.

@englercj
Copy link
Member

Hey @jsfi, if you think you have a solution for this can you put in a PR that references this issue?

Thanks!

@ghost
Copy link

ghost commented Sep 13, 2017

Whats the current update on this? I'm still getting this same bug, even on that codepen. I'm in a dilemma right now where I have to choose between setting cacheAsBitmap = false (with lower performance) or cacheAsBitmap = true (with these warnings)

@themoonrat
Copy link
Member

Does anyone on this thread still get this error with the latest pixi? Thanks!

@stale
Copy link

stale bot commented Feb 24, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Stale Previously “Won’t Fix”, bots should tag with this for inactive issues or pull-requests. label Feb 24, 2019
@lock
Copy link

lock bot commented Feb 24, 2020

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.

@lock lock bot locked and limited conversation to collaborators Feb 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🙏 Feature Request Community request for new features, APIs, packages. Stale Previously “Won’t Fix”, bots should tag with this for inactive issues or pull-requests. 💾 v4.x (Legacy) Legacy version 4 support
Projects
None yet
Development

No branches or pull requests

8 participants