[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Public WebGL] (summarizing) Canvas.getContext error handling
Here is an attempt at summarizing the main question in this debate, as was discussed during yesterday's conference call.
We need to choose between two main options:
Option 1: keep current WebGL spec behavior
-> That is: getContext returns null, generates a webglcontextcreationerror event, but does not throw.
Option 2: change WebGL spec to throw exceptions
-> That is: getContext throws an exception; the webglcontextcreationerror event becomes redundant/useless and its fate needs to be decided.
Here is some analysis of how these two options compare:
* Both options requiring changing the HTML canvas spec, since it currently requires a non-null object and no exception. This should be easy as it's not yet ratified.
* Option 2 also requires changing the WebGL spec to allow throwing an exception. This may be harder (require versioning) since WebGL 1.0 is already ratified.
* Option 2 also requires deciding on the fate of webglcontextcreationerror, which is part of the WebGL 1.0 spec.
* Both options preserve compatibility with existing content: option 1 is the current spec and option 2 is what (because of a bug) Firefox is currently doing.
* API comparison: depending on taste, one may prefer one option or the other.
** Both options are acceptable. The HTML canvas spec already allows throwing exceptions in other places. Exceptions are not JS-specific.
** Exceptions are a single unified mechanism; while with the webglcontextcreationerror way, every new canvas context type will have to introduce its own event type. But one may also argue that that's actually a good thing as different contexts have different kinds of failures and different messages to pass to the user. So, no clear advantage for either option.
In short, both options are acceptable to me, so I won't oppose either. By default, I'm inclined to just go for option 1 as it avoids having to change the WebGL spec and debate what to do about webglcontextcreationerror; but obviously, especially since option 2 is what Firefox currently does, I'm not opposed to it either.