Closed Bug 648883 Opened 13 years ago Closed 12 years ago

Stencil shadows demo doesn't work in Firefox

Categories

(Core :: Graphics: CanvasWebGL, defect)

All
Linux
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: bjacob, Unassigned)

References

()

Details

This demo works in Chrome, but in Firefox the whole scene is in the gray shadow. A user reported that the first frame was rendered correctly for him, but afterwards it's all gray.

http://www.playtankworld.com/demo/stencil_shadows
When I run it the error console contains:

Error: attempt to run compile-and-go script on a cleared scope
Source File: http://www.playtankworld.com/javascript/demo/stencilShadowDemo.js
Line: 1114

I wonder if fixing that would help?
The problem at line 1114 is caused by the call to "requestAnimFrame" which is a function defined in a webgl utils file from Google. I tested some demos on 
learningwebgl.com and this http://learningwebgl.com/lessons/lesson04/index.html demo gives the same error when you refresh the page.

I think it's not related to the problem with the stencil buffer.
I've been seeing Nightly not giving any stencil buffer.   The stencil_shadow demo there may be doing things wrong by not specifically requesting a stencil buffer when creating the context (getContext('webgl', {stencil : true}), but in MapsGL we do request the stencil and we're still not getting it on Nightly.  Haven't tried other versions of Firefox, but it used to work in Nightly a week or so ago.
Is this on all platforms?
The demo linked to in the description does indeed not appear to request a stencil buffer. The 'stencil' attrib defaults to 'false' as per spec when 'stencil' is unspecified.

Downloading the source files and adding { stencil: true } to the context creation call seemed to result in proper rendering on windows paths.

It looks like mac and linux both use FBOs, for which they should be using GL_DEPTH24_STENCIL8, which is spec-required. If it's broken there, we're either mishandling the format object, mishandling FBO creation for those with stencil channels, or driver bugs. Also it it's breaking on windows, can you give a little more information regarding what args you're supplying to getContext() the size of canvas?
I think we only see a problem on Linux.  Our actual call to get the context is:


          canvas.getContext(
              name, {'stencil': true, 'preserveDrawingBuffer': true }));

Where 'name' cycles through a list till it finds one that works:
   ['experimental-webgl', 'moz-webgl', 'webgl'];
OS: All → Linux
Tested on FF14 trunk. Demo works fine when modified to add "{'stencil': true}" to the context creation call. Bill, if you can still reproduce FF failing to create contexts with stencil buffers, please re-open.
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → WORKSFORME
Yeh, I don't think I've seen any issues in nightly for a while.
Note that this same uncorrected version of the demo is up on MDN: https://developer.mozilla.org/en-US/demos/detail/shadows
(In reply to Jeff Gilbert [:jgilbert] from comment #7)
> Tested on FF14 trunk. Demo works fine when modified to add "{'stencil':
> true}" to the context creation call. Bill, if you can still reproduce FF
> failing to create contexts with stencil buffers, please re-open.

When is this fix going to go live?  FF12 seems to still have the problem.  Will we have to wait until FF14 to see it working in a released version?
Bill, as explained in comment 7, this is a bug in this web page: it relies on a stencil buffer being present, but doesn't ask for it. We are currently advocating on the WebGL mailing list that it should be explicitly forbidden for browsers to give a stencil buffer when it's not asked for ({stencil:true} context creation attribute) as that only causes incompatibilities between browsers.
Resolution: WORKSFORME → INVALID
Ah, it seems the bug is that gl.getParameter(gl.STENCIL_BITS) returns 0 even if you enable the stencil.
Here's a demo modified to ask for stencil and then alert if STENCIL_BITS says it's zero:
http://billbaxter.com/stencilShadow/index.html
The demo doesn't alert here in Nightly.
Yes, Nightly is fine (as per comment 8).  11 and 12 both alert.  We're not sure about 13.
In fact, it seems that we still have that bug in mozilla-central, but whether the symptoms actually occur depend on fragile details. Indeed, webgl.getParameter(STENCIL_BITS) just returns the value returned by glGetIntegerv, but that's bogus for GL contexts backed by a FBO.

Filed bug 748600 about that.
Great.  Thanks for filing!
In fact, bug 748600 was invalid, as Jeff noted. glGetIntegerv(GL_STENCIL_BITS) is returning the values of the currently bound framebuffer, which is correct, and WebKit is doing that too.

On what driver do you get the alert in the link in comment 14?
OS: Linux-x86_64
NVIDIA Driver Version: 280.13
Graphics Processor: Quadro FX 580
VBIOS Version: 62.94.96.00.05
Tested with FF13, and it is ok.  STENCIL_BITS non-zero as expected.  So it looks like this bug dies with FF12.
You need to log in before you can comment on or make changes to this bug.