[whatwg] [canvas] request for {create, get, put}ImageDataHD and ctx.backingStorePixelRatio

Maciej Stachowiak mjs at apple.com
Thu Apr 19 21:28:16 PDT 2012

On Apr 17, 2012, at 3:32 PM, Darin Fisher wrote:
> ^^^ This got me thinking...
> In Chrome at least, getImageData() doesn't actually block to fetch pixels.  The thread is only blocked when the first dereference of the pixel buffer occurs.  I believe this is done so that a getImageData() followed by putImageData() call will not need to block the calling thread.
> The above suggests that making getImageData() asynchronous would not actually provide any benefit for cases where the page does not dereference the pixel buffer.  Another use case where this comes up is passing the ImageData to a web worker.  If the web worker is the first to dereference the ImageData, then only the web worker thread should block.
> I think this becomes an argument for keeping getImageData() as is.  It assumes that ImageData is just a handle, and we could find another way to discourage dereferencing the pixel buffer on the UI thread.
> Hmm...

You could also address this by adding a way to be notified when the contents of an ImageData are available without blocking. That would work with both vanilla getImageData and the proposed getImageDataHD. It would also give the author the alternative of just blocking (e.g. if they know the buffer is small) or of sending the data off to a worker for processing.


More information about the whatwg mailing list