W3C home > Mailing lists > Public > whatwg@whatwg.org > October 2013

Re: [whatwg] Synchronizing Canvas updates in a worker to DOM changes in the UI thread

From: Robert O'Callahan <robert@ocallahan.org>
Date: Tue, 22 Oct 2013 09:48:34 +0200
Message-ID: <CAOp6jLYqsMV7+mxpEcVccHR2SuG5qp3aQ=mhGnkg_sumwX3WXQ@mail.gmail.com>
To: Glenn Maynard <glenn@zewt.org>
Cc: whatwg <whatwg@whatwg.org>, Kenneth Russell <kbr@google.com>
On Tue, Oct 22, 2013 at 12:39 AM, Glenn Maynard <glenn@zewt.org> wrote:

> Using ImageBitmap for this has a lot of issues.  It requires synchronizing
> with scripts in the UI thread.  It requires manualling resize your canvas
> repeatedly to fit different destinations.  It also may potentially create
> lots of backbuffers. Here's an example of code using ImageBitmap
> incorrectly, leading to excess memory allocation:
>
> function render()
> {
>     var canvas = myWorkerCanvas;
>     renderTo(canvas);
>     var buffer = canvas.transferToImageBitmap();
>     postMessage(buffer);
> }
> setTimeout(render, 1);
>


This code actually does something potentially useful which can't easily be
done with attachToCanvas: generating a series of images as fast as possible
which will be processed on another thread in some way other than just
rendering them on the screen. (E.g., be encoded into an animated image or
video file.)

Rob
-- 
Jtehsauts  tshaei dS,o n" Wohfy  Mdaon  yhoaus  eanuttehrotraiitny  eovni
le atrhtohu gthot sf oirng iyvoeu rs ihnesa.r"t sS?o  Whhei csha iids  teoa
stiheer :p atroa lsyazye,d  'mYaonu,r  "sGients  uapr,e  tfaokreg iyvoeunr,
'm aotr  atnod  sgaoy ,h o'mGee.t"  uTph eann dt hwea lmka'n?  gBoutt  uIp
waanndt  wyeonut  thoo mken.o w  *
*
Received on Tuesday, 22 October 2013 07:49:01 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 17:00:12 UTC