W3C home > Mailing lists > Public > whatwg@whatwg.org > September 2012

Re: [whatwg] Hardware accelerated canvas

From: Glenn Maynard <glenn@zewt.org>
Date: Tue, 4 Sep 2012 14:17:33 -0500
Message-ID: <CABirCh-ZHD8TAAwgBTag5pH8geGp0Luhi_TyvH9kAnWm3kVmPg@mail.gmail.com>
To: Ian Hickson <ian@hixie.ch>
Cc: whatwg@lists.whatwg.org
(some quotes restored)

On Tue, Sep 4, 2012 at 12:28 PM, Ian Hickson <ian@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
Received on Tuesday, 4 September 2012 19:18:24 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:45 UTC