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

Re: [Public WebGL] Firefox 4 and blacklist reporting

Unfortunately it's convoluted to use webglcontextcreationerror because as far as I know no one has implemented it.

You have to do something like this

if (!window.WebGLRenderingContext) {
  // the browser has no clue what webgl is
} else {
   try {  // need a try here because of Firefox 
     canvas.addEventListener("webglcontextcreationerror", getError, false);
     ctx = canvas.getContext("webgl");  // and experimental-webgl
   } catch (e) {
   if (!ctx) {
     // since we don't know if the browser implements webglcontextcreationerror yet 
     // we need to setup a timeout in case it doesn't send one.
     setTimeout(reportTrouble, 1);

err = ""
function getError(event) {
  err = event.message;

function reportTrouble() {
  alert("Your WebGL had trouble initializing: " + err);

Worse, AFAIK there's nothing in the HTML spec that says that you have to get the webglcontextcreationevent before the timeout. I suspect all browsers will send it immediately after _javascript_ returns control to the browser but there's no guarantee. You could set the timeout to a larger number in the hope that you'd never have a browser that would send that first or maybe you don't care, you'll just get no error message.

Maybe we should revisit that part of the spec. Maybe getContext should throw and we should define the exception object it returns. That would make it a lot less convoluted. I forgot why we didn't have it throw originally. Something from the canvas spec?


On Tue, Mar 29, 2011 at 7:12 PM, Mark Callow <callow_mark@hicorp.co.jp> wrote:
On 30/03/2011 01:08, Gregg Tavares (wrk) wrote:

On Tue, Mar 29, 2011 at 1:29 AM, Mark Callow <callow_mark@hicorp.co.jp> wrote:

I thought get.webgl.org/troubleshooting would try the context creation
again and display the error string from webglcontextcreationerror, if

No, it should not because many cards and browsers crash on context creation which means going to that page would not help them.
In that case the public wiki needs sample code for handling webglcontextcreationerror. I think it should be included in webgl-utils.js.