[whatwg] "offscreen canvas" /Access to canvas functionality from a worker

Oliver Hunt oliver at apple.com
Sun Dec 6 22:34:46 PST 2009


On Dec 6, 2009, at 10:18 PM, Sigbjorn Finne wrote:

> On 12/5/2009 13:24, Franz Buchinger wrote:
>> Gears introduced the concept of an "offscreen canvas" that doesn't draw
>> anything in the browser window, but can be used to manipulate images in a
>> web worker.
>> 
>> I used this functionality to implement a "resize-before-upload" feature in
>> my photo gallery uploader. Now I'm trying to port my uploader to HTML5 but
>> there seems no way to delegate the scaling work to a HTML5 web worker.
>> Surely I could use the DOM canvas to scale down the photos in the main
>> "browser thread", but this means that the UI gets blocked during this
>> process.
>> 
>> If the user chooses more than a few multi-megapixel photos, the
>> CPU-intensive downscaling will likely freeze the browser and trigger a
>> script abortion warning.
>> 
>> Are there plans to introduce an "offscreen canvas" in html5? If not, which
>> workarounds are possible?
>> 
> Hi Franz,
> 
> ImageData is cloneable via postMessage(), so you could perform some
> forms of image processing that way.

I think the problem is that you lose more or less all native image processing support -- all you have is raw pixels which is fine if you're doing pure pixel manipulation, but unhelpful in many other cases.  Eg. in this case you have to implement your own image scaling logic in JS rather than relying in the (presumably) heavily optimised browser implementation.

That said I'm not sure whether we should really be trying to spec such a feature until we've had more time to see how workers are used in the wild.

> 
> --sigbjorn <sof at opera.com>
> 
--Oliver


More information about the whatwg mailing list