Last Comment Bug 598517 - X3DOM demo causes bad glBindTexture call in fake-black-texture code
: X3DOM demo causes bad glBindTexture call in fake-black-texture code
Product: Core
Classification: Components
Component: Canvas: WebGL (show other bugs)
: unspecified
: x86 Windows 7
-- normal (vote)
: ---
Assigned To: Nobody; OK to take it and work on it
: Milan Sreckovic [:milan]
Depends on:
  Show dependency treegraph
Reported: 2010-09-21 17:33 PDT by Benoit Jacob [:bjacob] (mostly away)
Modified: 2011-10-28 13:56 PDT (History)
2 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Description User image Benoit Jacob [:bjacob] (mostly away) 2010-09-21 17:33:56 PDT
Discussed on public_webgl.

This demo:

When run in with MOZ_GL_DEBUG_ABORT_ON_ERROR from the opengl debug mode (bug 597881) in a 32bit Windows build/ Win 7 / NVIDIA gives this stack trace leading to a GL error (calling glBindTexture again with a different target):

 	mozalloc.dll!mozalloc_abort(const char * const msg)  Line 77	C++
 	xul.dll!Abort(const char * aMsg)  Line 379 + 0xa bytes	C++
 	xul.dll!NS_DebugBreak_P(unsigned int aSeverity, const char * aStr, const char * aExpr, const char * aFile, int aLine)  Line 337 + 0xc bytes	C++
 	xul.dll!mozilla::gl::GLContext::AfterGLCall(const char * glFunction)  Line 1046 + 0x15 bytes	C++
 	xul.dll!mozilla::gl::GLContext::fBindTexture(unsigned int target, unsigned int texture)  Line 1100	C++
>	xul.dll!mozilla::WebGLContext::UnbindFakeBlackTextures()  Line 1011	C++
 	xul.dll!mozilla::WebGLContext::DrawElements(unsigned int mode, int count, unsigned int type, int byteOffset)  Line 1133	C++
 	xul.dll!nsICanvasRenderingContextWebGL_DrawElements(JSContext * cx, unsigned int argc, jsval_layout * vp)  Line 28301 + 0x21 bytes	C++
 	xul.dll!CallCompiler::generateNativeStub()  Line 455 + 0x23 bytes	C++
 	xul.dll!js::mjit::ic::NativeCall(js::VMFrame & f, unsigned long index)  Line 709 + 0x8 bytes	C++
 	nspr4.dll!_MD_CURRENT_THREAD()  Line 308 + 0xc bytes	C
 	nspr4.dll!_MD_CURRENT_THREAD()  Line 308 + 0xc bytes	C
 	nspr4.dll!PR_Sleep(unsigned int timeout)  Line 152	C
 	nspr4.dll!PR_GetThreadPrivate(unsigned int index)  Line 232 + 0x5 bytes	C

This means that when we unbind our fake black textures, in this code,

    for (PRInt32 i = 0; i < mGLMaxTextureImageUnits; ++i) {
        if (mBound2DTextures[i] && mBound2DTextures[i]->NeedFakeBlack()) {
            gl->fActiveTexture(LOCAL_GL_TEXTURE0 + i);
            gl->fBindTexture(LOCAL_GL_TEXTURE_2D, mBound2DTextures[i]->GLName());
        if (mBoundCubeMapTextures[i] && mBoundCubeMapTextures[i]->NeedFakeBlack()) {
            gl->fActiveTexture(LOCAL_GL_TEXTURE0 + i);
            gl->fBindTexture(LOCAL_GL_TEXTURE_CUBE_MAP, mBoundCubeMapTextures[i]->GLName());

we are making glBindTexture calls that we shouldn't.
Comment 1 User image Benoit Jacob [:bjacob] (mostly away) 2010-09-21 17:34:40 PDT
On the same machine, I can't reproduce in linux x86-64.
Comment 2 User image Scoobidiver (away) 2010-09-29 06:57:32 PDT
Build : Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0b7pre) Gecko/20100929 Firefox/4.0b7pre

With Intel GMA 4500MHD, there are 2 errors in error console :

Error: not well-formed
Source File: 
Line: 1, Column: 58
Source Code:
<p xmlns="">ERROR: No errors.

Error: uncaught exception: [Exception... "An invalid or illegal string was specified"  code: "12" nsresult: "0x8053000c (NS_ERROR_DOM_SYNTAX_ERR)"  location: " Line: 86"]
Comment 3 User image Vladimir Vukicevic [:vlad] [:vladv] 2010-12-13 15:25:38 PST
This needs more detail from the stack trace (a stack trace is generally not very useful by itself; if you have something in the debugger, it's worth getting as much information around the location where the error occurred):

  - which texture ID was being bound
  - was it a 2D or cubemap target
  - what are the values of the mBound2DTextures[i] or mBoundCubeMapTextures[i] struct?
Comment 4 User image Vladimir Vukicevic [:vlad] [:vladv] 2011-01-31 14:21:24 PST
Does this still happen?
Comment 5 User image Vladimir Vukicevic [:vlad] [:vladv] 2011-01-31 14:22:07 PST
Note that it might well be related to bug 629149
Comment 6 User image Benoit Jacob [:bjacob] (mostly away) 2011-01-31 14:46:21 PST
Good point! Will check ASAP.
Comment 7 User image Benoit Jacob [:bjacob] (mostly away) 2011-10-28 13:56:29 PDT
This got fixed a while ago, we were mis-querying the number of texture units so we were iterating over an array of the wrong size here.

Note You need to log in before you can comment on or make changes to this bug.