Re: [whatwg] onclose events for MessagePort

This is a feature we've long wanted for Google Docs, but not for the most
obvious reason.  We have a situation where more than one tab can be
visualizing the same document.  Under those conditions, we have a
requirement that one of the documents hold a lock which entitles it to do
things with the locally stored version of the document which other tabs and
workers in the system cannot.  Implementing this locking system is painful
and inefficient.  One of the main reasons is that it's impossible to get a
notification in the shared worker (where the lock 'lives') when the
lock-holding tab has closed.  We would use a message port onclose event for
this, reducing the complexity of our current system (which involves polling
loops and other very undesirable things) tremendously.

Generally speaking it's just a disappointing moment when you discover
message ports don't have this capability and you have to jury rig an
unreliable workaround, like so many times before.  A communications channel
with no 'is connected' status on it is just... not finished.

Why is revealing when garbage collection happens such a terrible thing
anyway?  Java does it...

-Dave

On Wed Oct 09 2013 at 1:11:09 AM, David Levin <levin@google.com> wrote:

> On Tue, Oct 1, 2013 at 11:13 AM, Boris Zbarsky <bzbarsky@mit.edu> wrote:
>
> > On 10/1/13 2:11 PM, Ian Hickson wrote:
> >
> >> How often do we expect two tabs to be talking to each other though?
> >>
> >
> > Or a page to an out-of-process subframe?
> >
> > How often do we expect MessageChannel to be used at all?
>
>
> Speaking as an web developer, I've found MessageChannel to be pretty useful
> when writing a complex web application because it allows you to isolate
> different communication pathways and hop across multiple iframes in a
> single bound (while only knowing about the next step at any one layer... it
> is hard to explain why this is useful without having to dive into the app).
> You can do this all on top of window.postMessage but it is more complicated
> and fragile. (Due to this, I've had to write a a layer above these that
> allows me to use either so that my code can work on browsers that don't
> support MessageChannel but it will be easier to debug on those that do.)
>
> dave
>
>
> >
> >
> >  Is that even possible on phone browsers?
> >>
> >
> > Sure is in Firefox and FirefoxOS.
> >
> >
> >  Anyway, I'm happy to support this in principle.
> >>
> >
> > OK, good.  ;)
> >
> > -Boris
> >
>

Received on Thursday, 10 October 2013 15:44:13 UTC