W3C home > Mailing lists > Public > whatwg@whatwg.org > May 2010

[whatwg] Image resize API proposal

From: Maciej Stachowiak <mjs@apple.com>
Date: Thu, 20 May 2010 20:28:22 -0700
Message-ID: <CE8E969C-44E8-400A-BEFF-A87466E7B99F@apple.com>

On May 20, 2010, at 8:13 PM, David Levin wrote:

> 
> 
> On Thu, May 20, 2010 at 7:55 PM, Maciej Stachowiak <mjs at apple.com> wrote:
> 
> On May 20, 2010, at 6:24 PM, Robert O'Callahan wrote:
> 
>> On Fri, May 21, 2010 at 12:50 PM, Maciej Stachowiak <mjs at apple.com> wrote:
>> I'd also love to hear from Mike Shaver and others from the original thread what they think of this API proposal.
>>  
>> I think Shaver's feedback still applies: on any device with a GPU, we can optimize canvas and/or rendering enough that scaling images is no problem on the main thread. So this API would have a short useful lifetime ... possibly negative.
>> 
>> Coming thread full circle, I now think there are good use cases for off-main-thread canvas, in particular with WebGL, but I guess that deserves its own thread again :-).
> 
> As far as I can tell, the proposed API doesn't enable resizing off the main thread. It is an API on HTMLImageElement so you can't call it from a worker. And it returns synchronously so the main thread has to block until the resize is done regardless. It returns a Blob, so I suppose it may be possible that the intent is to make a magical blob that's actually backed by a background thread asynchronous computation instead of data. That wasn't clear to me from the proposal. It would be a little weird.
> 
> 
> The proposed api has a callback for the blob, so it is totally async. We attempted to return the blob sync (and do everything hidden in the background), but blob.size wouldn't be known (so it would need to throw or block, etc.)  
> 
> Sample code from the proposal:
> 
> var successEvt = function (newBlob) { myDiv.innerHTML += "<img src='" + newBlob.url + "' />"; };
> 
> i.getBlob("image/jpeg", 300, 350, successEvt);
> 
> 

Ah, I misread the proposal. Didn't realize it had call backs.

In that case - why add an asynchronous API for this when there is evidence that adequate responsiveness can be achieved with a sufficiently optimized nonblocking API? Surely an async API is not more convenient on the whole. So the only reason to add it would be for performance, but it seems that could be achieved just by optimizing canvas sufficiently.

Regards,
Maciej

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20100520/d92d8565/attachment.htm>
Received on Thursday, 20 May 2010 20:28:22 UTC

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