Re: Transferable Objects, was: Re: Web Messaging Intents, was: Re: [DRAFT] Web Intents Task Force Charter

On 11/22/11 8:10 AM, Rich Tibbett wrote:
> Paul Kinlan wrote:
>> On Tue, Nov 22, 2011 at 3:32 PM, Rich Tibbett<richt@opera.com>  wrote:
>>> Paul Kinlan wrote:
>>>>
>>>> Someone mentioned earlier get-temperature as an example:
>>>> var channel = new MessageChannel()
>>>> var i = new Intent('get-temperature',
>>>> "application/octet-stream+myprotocol", channel.port2)
>>>> navigator.startActivity(i);
>>>>
>>> I'm missing how channel.port2 gets propagated to the selected Intent 
>>> Handler
>>> if it is not designated as a Transferable parameter. If the _exact_ 
>>> port2
>>> object is not transferred, then there is no messaging channel to use 
>>> in the
>>> first place...
> ...
>>>
>>> I may be missing a trick here.
>>
> ...
>> startActivity uses
>> the structured clone algorithm, that support Transferable objects.
>
> Of course! Until recently MessagePort wasn't compatible with the 
> structured clone algorithm but since it has recently come to implement 
> Transferable it has become compatible with that algorithm, making your 
> example work and negating the need for a fourth parameter specifically 
> for Transferable objects.
>
> Thanks for the explanation. This is helpful. I hope we can document 
> this level of detail in a specification soon.

I believe that transferable objects are still shared via "transfer map":
http://dev.w3.org/html5/spec/common-dom-interfaces.html#transferable-objects

Transferable objects are only handled by the transfer map, not by the 
internal structured cloning algorithm.
It seems like WebIDL may need some more work in this area, per the 
editorial note:
http://www.w3.org/TR/2010/WD-WebIDL-20101021/#idl-sequence

It seems to me that MessagePort could easily be added to the internal 
structured clone algorithm, but,
I don't see that happening for other transferable objects. Again, the 
problem is with ArrayBuffer:

postMessage(ArrayBuffer) // Copy the buffer
postMessage('', [ArrayBuffer]) // Transfer the buffer
http://www.khronos.org/registry/typedarray/specs/latest/typedarray.idl

I don't think this is an issue that Web Intents introduced, but it seems 
like one that we should clear up ASAP.

-Charles

Received on Thursday, 24 November 2011 22:11:29 UTC