-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Fix Firefox console warnings. #5939
Conversation
…extures before using texSubImage.
@bagnell, thanks for the pull request! Maintainers, we have a signed CLA from @bagnell, so you can review this at any time. I noticed that CHANGES.md has not been updated. If this change updates the public API in any way, fixes a bug, or makes any non-trivial update, please add a bullet point to I am a bot who helps you make Cesium awesome! Thanks again. |
@@ -121,25 +120,30 @@ define([ | |||
gl.activeTexture(gl.TEXTURE0); | |||
gl.bindTexture(textureTarget, texture); | |||
|
|||
function createFace(target, sourceFace) { | |||
function createFace(target, sourceFace, preMultiplyAlpha, flipY) { | |||
// TODO: gl.pixelStorei(gl._UNPACK_ALIGNMENT, 4); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean to leave this TODO in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that was in the original code. I just moved it.
Source/Renderer/CubeMap.js
Outdated
function createFace(target, sourceFace) { | ||
function createFace(target, sourceFace, preMultiplyAlpha, flipY) { | ||
// TODO: gl.pixelStorei(gl._UNPACK_ALIGNMENT, 4); | ||
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there duplicate pixelStorei
calls if sourceFace.arrayBufferView
below is not defined? If so, can we move these to the first if
block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bump - I was about to leave this comment and then noticed @pjcozzi already mentioned it.
gl.texSubImage2D(this._targetFace, 0, xOffset, yOffset, source.width, source.height, this._pixelFormat, this._pixelDatatype, source.arrayBufferView); | ||
} else { | ||
gl.texSubImage2D(this._targetFace, 0, xOffset, yOffset, this._pixelFormat, this._pixelDatatype, source); | ||
var uploaded = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here and below seems more complicated than it needs to be; I will not have the time to dive deep for awhile.
@lilleyse can you take a look?
@bagnell should we get this into tomorrow's release? Seems like we would want to (especially if it's a speed improvement). |
Please do not rush the review - would rather see this go into the following release. |
Do you think this will help with #3888? The Firefox tab now crashes if you run the tests with WebGL validation. |
No, the tab still crashes for me. |
Hey all, just curious if this fell off somebody's plate -- I'm still seeing the warnings I mentioned in #5912 . |
Waiting for a review from @lilleyse. |
Source/Renderer/CubeMap.js
Outdated
function createFace(target, sourceFace) { | ||
function createFace(target, sourceFace, preMultiplyAlpha, flipY) { | ||
// TODO: gl.pixelStorei(gl._UNPACK_ALIGNMENT, 4); | ||
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bump - I was about to leave this comment and then noticed @pjcozzi already mentioned it.
Source/Renderer/CubeMapFace.js
Outdated
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, this._preMultiplyAlpha); | ||
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, this._flipY); | ||
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false); | ||
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment here - there are some situations where gl.pixelStorei
gets called twice.
Source/Renderer/CubeMapFace.js
Outdated
} | ||
|
||
var size = PixelFormat.componentsLength(this._pixelFormat) * this._size * this._size; | ||
var bufferView = new constructor(size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could maybe be simplified with PixelFormat.textureSizeInBytes
. And to round it out PixelFormat
could have a function like PixelFormat.createTypedArray
, like how we have ComponentDatatype.createTypedArray
createFace(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, source.positiveY, preMultiplyAlpha, flipY); | ||
createFace(gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, source.negativeY, preMultiplyAlpha, flipY); | ||
createFace(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, source.positiveZ, preMultiplyAlpha, flipY); | ||
createFace(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, source.negativeZ, preMultiplyAlpha, flipY); | ||
} else { | ||
gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, pixelFormat, size, size, 0, pixelFormat, pixelDatatype, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it valid to pass in null
? If the value is null
does the texture still require another texImage2D
call with an empty typed array? Could that step go here instead? If so, then I think all the initialized
checks in CubeMapFace
may not be needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did it this way for the case where you create a texture and upload the entire texture later. This avoids creating an array buffer of all zeroes. The only time the array buffer of zeroes would be created would be when a texture is created and then a bunch of texSubImage2D
's are called to fill out an atlas. If we don't care about that case or optimization, then Ill change this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, a texture that is going to be rendered to cannot be set.
// Source: ImageData, HTMLImageElement, HTMLCanvasElement, or HTMLVideoElement | ||
gl.texImage2D(textureTarget, 0, internalFormat, pixelFormat, pixelDatatype, source); | ||
} | ||
} else { | ||
gl.texImage2D(textureTarget, 0, internalFormat, width, height, 0, pixelFormat, pixelDatatype, null); | ||
initialized = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically the same note as above, can we initialize the texture with an empty typed array now to avoid the initialized
check in copyFrom
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment here.
@lilleyse This is ready for another look. |
Source/Renderer/Texture.js
Outdated
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, this._preMultiplyAlpha); | ||
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, this._flipY); | ||
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false); | ||
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make the same changes as CubeMapFace
so that pixelStorei
isn't called multiple times in some cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Tests pass and the Sandcastle demos I tried still work.
It seems mostly unavoidable to me based on this discussion #5939 (comment). Do we want to release this with 1.43? @pjcozzi did you want to take a look? |
I don't have bandwidth to look at this for 1.43, but please merge if you are confident. |
I'm still seeing a related warning with Cesium 1.45 and Firefox 52 (which we are unfortunately stuck on for our application):
Was that supposed to be resolved by this PR? |
Hi @markerikson, do you see that error in Cesium 1.44 as well? This PR was added in 1.43 so if you're seeing the error in 1.45 but not 1.44 it means that we might have introduced something in 1.45 |
Loading up our app with 1.44, I actually see considerably more warnings:
(All repeated quite a few times, just isolating the unique messages.) In 1.45, I only see the "pixel formatting" message. |
I haven't seen that error, but I'm using Firefox 60. Do you see that in the Viewer or any Sandcastle example? If not, can you post an example so I can take a look? |
Yes, just loading up the main Sandcastle page in FF52 immediately shows the "pixel reformatting" warning in the console. |
Hmm, I don't see it on FF59 either. It's unfortunate you're unable to upgrade |
Yeah, we have an internal app that targets a specific Firefox ESR version at a time, so we're still targeting FF52 for this dev cycle. We'll live with it, just was wanting to see if it was supposed to have been resolved already (and at least there's fewer warnings). |
Fixes #5912