-
Notifications
You must be signed in to change notification settings - Fork 326
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
Browser fixes #479
Browser fixes #479
Conversation
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.
Presumably everything is logically and functionally sound and it just prevents an undefined-behavior corner case from erroring out? If so, seems reasonable to me.
lib/texture.js
Outdated
@@ -1314,12 +1333,15 @@ module.exports = function createTextureSet ( | |||
|
|||
tempBind(texture) | |||
for (var i = 0; texture.mipmask >> i; ++i) { | |||
var _w = w >> i | |||
var _h = h >> i | |||
if (!_w || !_h) break |
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.
Firefox warns when w
/h
is not POT, and it is not when _w === 0
lib/texture.js
Outdated
@@ -828,6 +842,10 @@ module.exports = function createTextureSet ( | |||
gl.copyTexImage2D( | |||
target, miplevel, format, info.xOffset, info.yOffset, width, height, 0) | |||
} else { | |||
if (!data) { |
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.
Firefox requires texture to be init with data before subimage
call, otherwise gives warning.
v1.3.1 has seven failures in safari (some given with just a bit of context since the console is too slow to fetch stack traces):
Of concern is a new error in master:
And that tests halt at 18629 with: |
this error is not critical - some browsers naturally give WebGL warnings but keep functioning, and that assertion checks if there are none. |
Yup. Currently digging in a bit more. The |
Looks like the half float oes bug is Safari-~10-11(?)-specific and has been encountered by a few different projects and that it results in objects rendering black. Unity encountered this but unfortunately there's no helpful information on the issue. I think this is not new but is actually the result of checks that were not previously implemented: 75730b6#diff-6d2e0d9813eb0b2330521d6a391021d3R169 I think the immediate fix here is to have the test fail but not bring all tests to a halt. |
After patching over the framebuffer-parse test to report an error without halting, I believe the above list is complete for Safari 11.1 on OS X 10.13.4. Of course fixing the tests is a different matter. |
Apologies this is all a bit scattered. Summarizing what I know about the test failures for Safari:
|
lib/texture.js
Outdated
if (Dtype) { | ||
data = new Dtype(width * height * channels) | ||
} | ||
data = pool.allocType(type, width * height * channels) |
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.
We should really scope this to browsers that throw warning on null
texture data. How do we do so?
test/texture2d.js
Outdated
0, 0, 0, 255, 0, 0, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 0, 0, 0, | ||
0, 0, 0, 255, 0, 0, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 0, 0, 0, | ||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | ||
255, 0, 0, 255, 255, 255, 255, 255, 0, 0, 0, 255, 0, 0, 0, 255, null, null, null, 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.
null
signifies insignificance
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.
Noted in the comment above, so sounds good 👍
lib/texture.js
Outdated
if (Dtype) { | ||
data = new Dtype(width * height * channels) | ||
} | ||
data = pool.allocType(type, width * height * channels) |
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.
We should really scope this to browsers that throw warning on null
texture data. How do we do so?
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 there any precedent for feature-detection in regl? Ideally I think we'd just feature-detect if it accepts null data since the result probably doesn't change.
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.
Unfortunately that is not an error but warning, there is no way to detect that via gl.getError
or alike https://stackoverflow.com/questions/26400009/webgl-get-error-warning-message-text-as-a-string, so forcing null-data every time via zero pool seems reasonable solution. Is that indeed?
module.exports = createPool() | ||
|
||
// zero pool for initial zero data | ||
module.exports.zero = createPool() |
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.
Reserved for zero-data inits.
@rreusser seems that Safari tests pass on my side. Could you possibly run them once again to make sure all except for |
The two read float tests fail in Safari 11.1, and also the stencil renderbuffer test at framebuffer-depth-stencil.js:
|
Ok, fixed |
lib/read.js
Outdated
if (gl.checkFramebufferStatus(gl.FRAMEBUFFER) !== gl.FRAMEBUFFER_COMPLETE) return false | ||
|
||
gl.viewport(0, 0, 1, 1) | ||
gl.clearColor(1.0, 0.0, 0.0, 1.0) |
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 wonder if that can lose previous clear color, if there is any. That should not be an issue, since regl.clear
or regl._refresh
fully reinit the state.
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 check is run on startup, right? I think it'd be fine then as long as the state is refreshed/initialized afterwards.
lib/read.js
Outdated
gl.bindTexture(gl.TEXTURE_2D, null) | ||
if (gl.checkFramebufferStatus(gl.FRAMEBUFFER) !== gl.FRAMEBUFFER_COMPLETE) return false | ||
|
||
gl.viewport(0, 0, 1, 1) |
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.
That should not affect previous render/framebuffer, should that? At the moment of this call gl
does not have any fbo/renderbuffer attached.
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.
Oh, and apologies, but just curious? What does this really do? On platforms where it's not supported, does it currently fail silently? Throw an error? A warning? After this, what is the result?
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 uses own regl ‘check’ function to throw an error if reading floats is not supported, as discussed in the adjacent PR.
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.
Apologies, but I forgot: does it already throw an error without regl itself detecting and throwing an error?
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.
@@ -92,7 +93,7 @@ tape('read pixels', function (t) { | |||
}) | |||
|
|||
// now do it for an float fbo | |||
if (regl.hasExtension('oes_texture_float')) { | |||
if (regl.hasExtension('oes_texture_float') && !safari) { |
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.
Blindly disable safari. Is there any sense to double-check if reading floats is supported here instead of 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.
Seems okay to me. Could feature-detect it independently from regl, but I think the main goal is just to have safari reasonably report pass/fail on the tests so that regl as a whole is easier to maintain. This accomplishes it, though it'd be nice if there were a pending
state or something so that it'd report without failing. But short of that, 👍, I guess?
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 tend to agree on that point. What about exposing ‘regl.supports’ set to let user manually check supported features rather than throwing an error? Or mb just reusing ‘regl.limits’?
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.
Seems reasonable if regl detects it anyway. limits
is strictly builtin getParameter
results (right?) so seems nice to keep that clean.
Side note: Does safari really not throw an exception for unsupported types? 😞 See: https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/readPixels#Exceptions
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.
Saw the commit. limits
seems fine too 👍
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.
It does not. It just silently returns 0
, as in this demo.
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.
Perfect. Getting a bit lost in the number of issues being tackled here. Got it. 👍 👍
Ok, now all browser tests pass, merge-ready. It is up to reviewing and confirming/discussing feature-detection and browser-scoping tests decisions. @rreusser hope for your help with that :) |
So just to reiterate the approach to vendor-specific issues (correct me if I'm wrong): In the sense that regl only wraps the webgl API, it's nice to avoid caring about what works or doesn't work, but I think some minimal feature detection, if only for the sake of warning/failing when something would otherwise fail silently (and possibly just in debug mode?) is reasonable. Could split hairs all day on all the little points, but things here look good to me 👍 |
The intention of this PR is to make sure Firefox/IE11/Safari and other non-webkits pass tests.