[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Public WebGL] Extension proposal: WEBGL_lose_context

Here's the other problem I have with this extension. 

#1) For a _javascript_ app to be able to test they handle lost context

   as pointed out, they can use _javascript_ for this

#2) To be able to write lost context conformance tests
#3) To test the browser's handing of lost context.

The problem with but #2 and #3 is that this extension WILL NOT ACHIEVE EITHER OF THOSE GOALS.

For example, to implement WebGL in Chrome required that when ctx.linkProgram is called internally glLinkProgram is called, after that glGetProgramiv is called once to check for success. If it was successful it gets called 4 more times with GL_ACTIVE_ATTRITUBES, GL_ACTIVE_ATTRIBUTES_MAX_LENGTH, GL_ACTIVE_UNIFORMS and GL_ACTIVE_UNIFORMS_MAX_LENGTH.  For each attribute and uniform found. glGetActiveAttrib/glGetActiveUniform, glGetAttribLocation/glGetUniformLocation are a called. That could easily be 10-20 calls for a typical program.  The context could be lost between any one of those calls an yet this extension will not test that the implementation works in those cases because its granularity is at the WebGL _javascript_ level, not the underlying gl call implementation level.

Same for clearing the backbuffer on resize. Easily 20-30 calls are required. If the user has an FBO bound it must be unbound, the clear color, color mask, depth clear value, depth mask, stencil clear value, stencil mask and scissor must all be set to something that will allow the backbufffer (virtual or real) to be cleared. Then all of those must be restored to whatever the user had previously.  Lost context can occur between any of those 20-30 gl calls. Again. This extension will NOT test the implementation handles this case.

Another example, ctx.getProgramInfoLog.  The underlying implementation is probably written something like this 

  GLint max_len;
  glGetProgramiv(service_id_, GL_INFO_LOG_LENGTH, &max_len);
  scoped_array<char> temp(new char[max_len]);
  GLint len;
  glGetProgramInfoLog(service_id_, max_len, &len, temp.get());
  return DOMString(temp.get(), len);
There's a LOST_CONTEXT bug in this code. max_len and len need to be set before calling glGetProgramiv and glGetProgramLogInfo. If not set and the context is lost they will be undefined. They will then be used to allocate a temp buffer of a random size then make a DOMString of a random length full of garbage

The proposed extension will not test this. Nor will it test that the first call succeeds and the second one fails because of LOST CONTEXT.

So again, what's the point of this extension? It doesn't and actually can't test WebGL. All it can do is help a _javascript_ app test their app. And yet they don't need that since that can be done in _javascript_ (with the example provided)