[whatwg] Synchronizing Canvas updates in a worker to DOM changes in the UI thread
Robert O'Callahan
robert at ocallahan.org
Tue Oct 22 00:48:34 PDT 2013
On Tue, Oct 22, 2013 at 12:39 AM, Glenn Maynard <glenn at 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 *
*
More information about the whatwg
mailing list