W3C home > Mailing lists > Public > whatwg@whatwg.org > January 2011

[whatwg] WebWorkers and images

From: Berend-Jan Wever <skylined@chromium.org>
Date: Thu, 13 Jan 2011 11:08:10 +0100
Message-ID: <AANLkTi=rgmB21CwsGEL08UrsVEh1TrP7vvuLhRFdp=HG@mail.gmail.com>
I ended up creating a PageWorker object, which is constructed in the page
rather then in a WebWorker. It uses setInterval to repeatedly run a function
in the background to do the image processing directly on the canvas imageD
data. To reduce overhead, each interval runs the function in a small loop
for a certain number of ms. After each interval, the browser gets some time
to do UI updating. This seems to work well in my Mandelbrot fractal
renderer; the browser remains responsive:

http://skypher.com/SkyLined/demo/FractalZoomer/Mandel.html

Cheers,
BJ

Berend-Jan Wever (SkyLined at google.com) | Security Software Engineer
Google Netherlands B.V. | Reg: Claude Debussylaan 34, 15th floor 1082 MD
Amsterdam
34198589 | NETHERLANDS | VAT / Tax ID:- 812788515 B01


On Sat, Jan 8, 2011 at 03:39, Glenn Maynard <glenn at zewt.org> wrote:

> On Fri, Jan 7, 2011 at 8:16 PM, Drew Wilson <atwilson at chromium.org> wrote:
> > I would recommend that people review this
> > thread:
> http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2010-February/025254.html
> > to understand the objections previously raised to this idea.
>
> To comment on one thing in particular:
>
> On Tue, Feb 23, 2010 at 12:05 AM, Jonas Sicking <jonas at sicking.cc>
> wrote:
> > I admit to not being a graphics expert, but I would imagine you have
> > to do quite a lot of drawing before
> > 1. Drawing on offscreen canvas
> > 2. Cloning the pixel data in order to ship it to a different thread
> > 3. Drawing the pixel data to the on-screen canvas
> > gets to be cheaper than
> > 1. Drawing to on-screen canvas.
>
> It's not about doing things more cheaply.  It's about not doing work
> in the UI thread, where it can hold up the whole tab or worse.  Even
> if it's somewhat more expensive in terms of CPU power used, doing this
> sort of work in a thread can be a huge win: keeping the UI
> consistently responsive.
>
> I've seen it in practice: select an image in an image box, start
> typing in another form field, and my typing freezes for half a second
> while an invisible canvas operation runs.
>
> --
> Glenn Maynard
>
Received on Thursday, 13 January 2011 02:08:10 UTC

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