[whatwg] Hardware accelerated canvas

Glenn Maynard glenn at zewt.org
Tue Sep 4 12:17:33 PDT 2012


(some quotes restored)

On Tue, Sep 4, 2012 at 12:28 PM, Ian Hickson <ian at hixie.ch> wrote:

>  > > Realistically, there are too many pages that have 2D canvases that are
> > > drawn to once and never updated for any solution other than "don't
> > > lose the data" to be adopted. How exactly this is implemented is a
> > > quality of implementation issue.
>
> > There are ways to make it work without forgoing acceleration, e.g. taking
> > regular "backups" of the canvas contents, remembering every instruction
> > that was sent to the canvas, etc.
>
> On Mon, 3 Sep 2012, Glenn Maynard wrote:
> >
> > As Erik said, taking a snapshot of the canvas is very expensive on some
> > platforms.  If you're rendering a game in realtime, you never have a
> "time
> > out" where you can tolerate an expensive readback.
>
> If you're rendering a game in realtime, the issue doesn't come up. The
> most you'll be out is a frame.
>

You were listing approaches for never exposing the effects of context loss,
in claiming that "don't lose data" is workable.  To do that with snapshots,
you'd have to take a snapshot *every* frame, regardless of whether it's a
realtime game or a one-shot renderer.  That's the only way to get "don't
lose the data".  After all, the game might decide to stop rendering at any
moment (eg. it might pause).  If your snapshot isn't up-to-date when
context loss happens, you won't have an up-to-date snapshot to restore, so
there's nothing you can do but lose data (and showing an out-of-date
snapshot is probably even worse than reverting to a blank canvas).

I do think that *heuristic* snapshots are probably one part of the
solution, but they're distinctly heuristic and they will always leave edge
cases where it's possible to lose canvas data.

It doesn't follow that since there are pages that only render once, the
only solution is to not lose data, since it's fairly straightforward to
only snapshot the first couple frames and then stop snapshotting (or eg.
stop snapshotting until the page doesn't render for 500ms, or something
like thaT).

-- 
Glenn Maynard



More information about the whatwg mailing list