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: Kenneth Russell <kbr@google.com>
Date: Fri, 3 Jun 2011 11:37:12 -0700
Message-ID: <BANLkTi=9nnGdQJdzenqyi4GgirAyrM9z=0G_LhLetMr7tCutYQ@mail.gmail.com>
To: Glenn Maynard <glenn@zewt.org>
Cc: Dmitry Lomov <dslomov@google.com>, Jonas Sicking <jonas@sicking.cc>, David Levin <levin@chromium.org>, ben turner <bent.mozilla@gmail.com>, "public-webapps@w3.org" <public-webapps@w3.org>, Ian Hickson <ian@hixie.ch>, Travis Leithead <Travis.Leithead@microsoft.com>
On Fri, Jun 3, 2011 at 9:46 AM, Glenn Maynard <glenn@zewt.org> wrote:
> On Fri, Jun 3, 2011 at 11:12 AM, Dmitry Lomov <dslomov@google.com> wrote:
>> a) Recursive transfer lists. Allow arbitrary objects, not only ArrayBuffers,
>> to appear in transfer lists.  ArrayBuffers that are under objects in
>> transfer lists are transferred, others are cloned.
> This again causes the same forwards-compatibility problem.  If you do this:
> frame = { video: canvasPixelArrayInstance, histogram: arrayBuffer } }
> postMessage({ frame: frame }, { transfer: frame });
> and you expect only histogram to be transferred (since that's all that
> supports it when you write this code), your code breaks when
> CanvasPixelArray later supports it.
>> b) Transfer lists + separate transferMessage method. We still equip
>> postMessage with transfer lists, these transfer lists list ArrayBuffers, and
>> we provide a separate method transferMessage with recursive transfer
>> semantics.
>> What do people think?
> Same problem.
> If you want a quicker way to transfer all messages of given types, see
> my previous mail: { transfer: ArrayBuffer }.

Agreed on these points. Using an object graph for the transfer list
(which is what the recursive transfer list idea boils down to) also
sounds overly complicated.

May I suggest to reconsider adding another optional array argument to
postMessage for the transfer list, rather than using an object with
special properties?

Points in favor of adding another optional array argument:

1. Less typing, and less possibility that a typo will cause incorrect behavior:
  worker.postMessage(objectGraph, null, [ arrayBuffer1ToTransfer,
arrayBuffer2ToTransfer ]);
  worker.postMessage(objectGraph, { transfer: [
arrayBuffer1ToTransfer, arrayBuffer2ToTransfer] });

2. Possibility of using Web IDL to specify the type of the optional
array argument (i.e., "Transferable[]?"). Would be harder to do using
an object -- requiring either specifying another interface type with
the "ports" and "transfer" attributes, or using "any" plus
ECMAScript-specific text.

Points in favor of using an object:

1. Could potentially overload the meaning of the optional ports array
argument, avoiding adding another argument to postMessage.

2. More extensible in the future.


Received on Friday, 3 June 2011 18:37:42 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 18:13:19 UTC