[whatwg] Hardware accelerated canvas

Glenn Maynard glenn at zewt.org
Sun Sep 2 11:22:25 PDT 2012


On Sun, Sep 2, 2012 at 12:13 PM, Ashley Gullen <ashley at scirra.com> wrote:

> Why is it prohibitively expensive to handle a lost context automatically in
> a canvas 2D?
>
> Having written a 2D engine which supports this (albeit in DirectX), don't
> you just need to recreate the surface, set up your render state again,
> recreate any textures that were referenced, then continue? (In some
> engines, this can amount to simply calling init() again)
>

That would erase the canvas, since you don't know its contents in order to
recreate it.

WebGL's intent is just to expose OpenGL ES to javascript, and since OpenGL
> ES makes you handle lost contexts yourself, so does WebGL.


If there was a way to make WebGL transparently handle context loss, they'd
have done it.  It's easily the most unpleasant part of WebGL and will
probably end up being the biggest source of bugs and failed interop (on
platforms where it happens).  WebGL makes you handle lost contexts yourself
because it's the only thing that can be implemented in practice.

It'd be easier on users with 2d canvases, since there's much less
unrestorable state (only the contents of the canvas, not textures, shaders,
and so on), but it would still be a major source of interop issues.

-- 
Glenn Maynard



More information about the whatwg mailing list