W3C home > Mailing lists > Public > public-webapps@w3.org > April to June 2011

Re: What changes to Web Messaging spec are proposed? [Was: Re: Using ArrayBuffer as payload for binary data to/from Web Workers]

From: Ian Hickson <ian@hixie.ch>
Date: Thu, 23 Jun 2011 23:52:29 +0000 (UTC)
To: Jonas Sicking <jonas@sicking.cc>
cc: Andrew Wilson <atwilson@google.com>, Kenneth Russell <kbr@google.com>, David Levin <levin@chromium.org>, Arthur Barstow <art.barstow@nokia.com>, Glenn Maynard <glenn@zewt.org>, Dmitry Lomov <dslomov@google.com>, ben turner <bent.mozilla@gmail.com>, "public-webapps@w3.org" <public-webapps@w3.org>, Travis Leithead <Travis.Leithead@microsoft.com>
Message-ID: <Pine.LNX.4.64.1106232348500.19153@ps20323.dreamhostps.com>
On Tue, 21 Jun 2011, Ian Hickson wrote:
> 
> How about we just make postMessage() take the object to clone in the first 
> argument, an array of objects to transfer in the second; on the other 
> side, the author receives the object cloned, with anything listed in the 
> array and in the structured data being transferred instead of cloned, and, 
> in addition, in the event.ports array, a list of the ports that were given 
> in the transfer array.
> 
> This has the advantage of being completely backwards-compatible.
> 
> So for example, on the sending side:
> 
>    postMessage(['copied', copiedArrayBuffer, transferredArrayBuffer,
>                 transferredPort1], // could be an object too
>                [transferredArrayBuffer, transferredPort1,
>                 transferredPort2]);
> 
> ...on the receiving side, the event has
> 
>    data == ['copied', newCopiedArrayBuffer, newTransferredArrayBuffer,  
>             newTransferredPort1];
>    ports == [newTransferredPort1, newTransferredPort2];
> 
> It's not going to win any design awards, but I think that boat has sailed 
> for this particular API anyway, given the contraints we're operating under.

Since no serious problems were raised with this and it seems to address 
all the constraints, I've now specced this.

One edge case that wasn't mentioned above is what happens when a non-port 
Transferable object is in the second list but not the first. I defined it 
such that it still gets cloned (and thus the original is neutered), but it 
is then discarded. (That definition more or less fell out of the way one'd 
have to implement this to make it simple to understand, but I'm happy to 
do it a different way if there's a good reason to.)

http://html5.org/tools/web-apps-tracker?from=6272&to=6273

kbr: Feel free to ping me if you need advice on how to use this with 
ArrayBuffer in the short term. On the long term I'm happy to just spec 
this in the same spec as the rest of this stuff.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Thursday, 23 June 2011 23:52:52 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:45 GMT