[webkit-dev] Passing data structures through postMessage()

Oliver Hunt oliver at apple.com
Thu Sep 10 17:29:06 PDT 2009


On Sep 10, 2009, at 5:09 PM, Chris Campbell wrote:

> On Thu, Sep 10, 2009 at 4:55 PM, Sam Weinig <sam.weinig at gmail.com>  
> wrote:
>> It should not be necessary to serialize to a string just to pass the
>> structured clones across thread boundaries.  This would be an  
>> especially bad
>> idea for things like CanvasPixelArray.  I am also not sure I  
>> understand the
>> name AttributeIterator.
>> -Sam
>
> Perhaps it's not necessary to serialize to a string.  However, there
> is existing code that passes strings through and it would be nice not
> to have to change all that.  Binary image data could be text-encoded.
> That said, I'm open to binary serialization if it's not too big a
> change.

There is no advantage in converting data to a string form when  
transferring across contexts, all it does is mean that you have to a  
large amount of extra work to serialise arbitrary data to a string  
form, then parse it again on the way out.  This is both  
computationally expensive and risky as string serialisation and  
deserialisation have historically been places where a large number of  
subtle errors can be introduced.

>
> "AttributeIterator" is supposed to convey that the class can be used
> to recursively iterate over the properties/attributes of JS objects
> and arrays.  (Though it can also represent primitive values.)  I'm
> open to alternative names for this class, too.

This is incorrect, from the bindings point of view the type here  
should be "any", which in the JS bindings means ScriptValue.  The  
actual serialisation is by definition bindings dependent, be that JSC  
or ObjC.

--Oliver



More information about the webkit-dev mailing list