W3C home > Mailing lists > Public > public-webapps@w3.org > October to December 2011

Re: postMessage is the new wtf

From: Dmitry Lomov <dslomov@chromium.org>
Date: Tue, 13 Dec 2011 12:20:15 -0800
Message-ID: <CAObu7DFKji3jb2fQvVVus01vN==u-r4NfaDXaQoHLuczCX9mkQ@mail.gmail.com>
To: Rick Waldron <waldron.rick@gmail.com>
Cc: Webapps WG <public-webapps@w3.org>
(resending to list - Rick, sorry if you get this twice)

On Tue, Dec 13, 2011 at 11:59 AM, Rick Waldron <waldron.rick@gmail.com>
 wrote:

>
>
> On Tue, Dec 13, 2011 at 2:11 PM, Dmitry Lomov <dslomov@chromium.org>
>  wrote:
>
>>
>> window.webkitPostMessage(msg, transferables) does not really exist (it is
>> an error in the blog post, and I am told the post will be amended). What
>> exists is window.webkitPostMessage(msg, targetOrigin, transferables).
>>
>
> This supports the subject line "postMessage is the new wtf"
>

You are obviously entitled to your own opinions, but folks were working
hard to make sure that changes to the spec result in API that is both makes
sense in its final form and does not break the Web.


>>
>> The spec mandates 'void postMessage(any message, optional
>> sequence<Transferable> transfer)'. Transferable includes both MessagePorts
>> and ArrayBuffers, so in the new spec the transfer argument to postMessage
>> may be a mix of both types, and a backwards-compat extension to what we had
>> before (sequence<MessagePort> aka MessagePortArray). Note that message
>> ports got an additional change in semantics, and can now be mentioned in
>> the message as well - both
>>
>    worker.postMessage({p:port}, [port])
>> and
>>    worker.postMessage({p:port, ab:arrayBuffer}, [post, arrayBuffer])
>> work. Therefore this extension to postMessage semantics is both
>> backwards-compatible and consistent.
>>
>
> Can you provide a reference for this? I'm unable to locate anything that
> covers these semantics.
>

A spec for structured cloning algorithm (ready-for-implementations state):
http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-interfaces.html#safe-passing-of-structured-data
A spec for typed array tarnsfer (strawman state):
http://www.khronos.org/registry/typedarray/specs/latest/#9

(I agree it is not super easy to find these, but all this is bleeding-edge
still - when dust settles, I am sure there will be more blog posts,
articles and all that jazz)

Thanks!

Dmitry


>>
>>
>> On Tue, Dec 13, 2011 at 8:24 AM, Rick Waldron <waldron.rick@gmail.com>wrote:
>>
>>> Following the recent blog post
>>> http://updates.html5rocks.com/2011/12/Transferable-Objects-Lightning-Fastand subsequent Twitter discussion regarding changes to the parameter list
>>> of:
>>>
>>> Worker.prototype.postMessage( message [, transfer ] ) [1]
>>>
>>> DedicatedWorkerGlobalScope void postMessage<http://dev.w3.org/html5/workers/#dom-dedicatedworkerglobalscope-postmessage>(any
>>> message, optional sequence<Transferable> transfer) [2][3]
>>>
>>>
>>> I'm unable to find documentation or discussion that would clarify the
>>> rationale of over-using and over-loading the "postMessage" Identifier;
>>> considering the the blog cited above shows this example:
>>>
>>> [window|worker].webkitPostMessage(uInt8Array.buffer, [uInt8Array.buffer
>>> ]);
>>>
>>>  which conflicts with:
>>>
>>> window.postMessage(message, targetOrigin [, transfer ]) [4][5]
>>>
>>> and they both conflict with:
>>>
>>> DedicatedWorkerGlobalScope : WorkerGlobalScope ...
>>>  void postMessage(in any message, in optional MessagePortArray ports);
>>> [6]
>>>
>>> Currently, passing a second arg to worker.postMessage(), that is not a
>>> MessagePortArray raises
>>> "Uncaught TypeError: MessagePortArray argument must contain only
>>> MessagePorts" in Chrome and "Could not get domain" warning in Firefox.
>>>
>>>
>>> Any reasonable clarification would be greatly appreciated.
>>>
>>> Thanks in advance
>>>
>>> Rick
>>>
>>>
>>> [1]
>>> http://www.whatwg.org/specs/web-apps/current-work/multipage/workers.html#dedicated-workers-and-the-worker-interface
>>>
>>> [2]
>>> http://www.whatwg.org/specs/web-apps/current-work/multipage/workers.html#dedicated-workers-and-the-dedicatedworkerglobalscope-interface
>>>
>>> [3]
>>> http://dev.w3.org/html5/workers/#dedicated-workers-and-the-dedicatedworkerglobalscope-interface
>>>
>>> [4]
>>> http://www.whatwg.org/specs/web-apps/current-work/multipage/web-messaging.html#web-messaging
>>>
>>> [5]
>>> http://www.whatwg.org/specs/web-apps/current-work/multipage/web-messaging.html#posting-messages
>>>
>>> [6] PREVIOUS SPECIFICATION STATE!!!
>>> http://www.w3.org/TR/2011/WD-workers-20110208/#dedicated-workers-and-the-dedicatedworkerglobalscope-interface
>>>
>>
>>
>
Received on Tuesday, 13 December 2011 20:20:52 GMT

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