[whatwg] Canvas.getContext error handling
Ian Hickson
ian at hixie.ch
Thu May 12 19:35:19 PDT 2011
On Thu, 12 May 2011, Cedric Vivier wrote:
>
> Thanks for your thorough reply and overview of the issue.
>
> In case it slipped through your inbox, I've posted a more up-to-date
> (wrt WebGL WG discussions) and actionable proposal at :
> http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2011-May/031415.html
>
> Please have a look, we need your feedback on which option do you think
> is more reasonable, or objection if both options are "wrong".
Oops, didn't notice that one when looking for the getContext e-mails. It
was still in my pile of mails to deal with but not categorised as a canvas
e-mail. :-) Reply below:
On Mon, 2 May 2011, Cedric Vivier wrote:
>
> For WebGL, we need getContext to possibly fail whereas the browser
> supports contextId "webgl". Indeed it is possible the browser fails
> creating a new 3D context for many different reasons at run-time, which
> means a given contextId might not be available at any given time.
>
> This is in relation to [1]
> http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-canvas-getcontext
>
> We are investigating two options :
>
> Option #1 - modify getContext specified context creation steps so that
> null can be returned at a later stage than step 3.
> In a nutshell, allow the contextId specification to fail new context
> initialization, reorder setting primary context only after the new
> context object has been successfully initialized. [...]
>
> Option #2 - allow getContext to throw an exception.
> We still need the modification of the spec as above, with step 6 as :
> "6. If the new context object could not be initialized successfully,
> throw an exception and abort these steps."
> We'd probably also need to specify the kind of exception object to be thrown.
These options don't seem to be better than the one Kenneth and yourself
proposed earlier, namely, return null in step 2 if there's a permanent
failure (unsupported driver, no hardware, etc), and return a context that
you immediately fire the "lost context" event on for the case of a
temporary failure.
--
Ian Hickson U+1047E )\._.,--....,'``. fL
http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,.
Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
More information about the whatwg
mailing list