On Wednesday, September 18, 2013 2:39:07 PM UTC-7, Fernando Jiménez Moreno 
wrote:
> Looping dev-b2g again.
> 
> 
> 
> On 18/09/2013, at 13:18, smaug wrote:
> 
> 
> 
> > On 09/18/2013 05:29 AM, Kyle Huey wrote:
> 
> >> On Tue, Sep 17, 2013 at 7:25 PM, smaug wrote:
> 
> >> 
> 
> >> 
> 
> >>        Summary: - We need to add message listeners only when they are 
> >> actually needed. - For "one-shot" messages associated with specific 
> >> requests, we
> 
> >>        should add weak message listeners. - For messages that should be 
> >> listened during the lifetime of the window, we should add strong message
> 
> >>        listeners.
> 
> >> 
> 
> >>    ...or keep the listeners alive by some other mechanism. Like adding 
> >> some expando property to the relevant window and keep listeners alive 
> >> there.
> 
> >>    khueyfix should then kill those references when the window goes away, 
> >> right khuey?
> 
> >> 
> 
> >> 
> 
> >> I don't entirely understand what's going on here, but I don't think it 
> >> will clean up completely.  If we are listening to messages on some global 
> >> thing
> 
> >> through JS then we will cut the reference from the 
> >> cross-compartment-wrapper to the objects in the window, but we will leave 
> >> message listeners with
> 
> >> dead wrappers in the message manager so over time it will slow down as the 
> >> set of listeners continues to grow.
> 
> >> 
> 
> >> - Kyle
> 
> > 
> 
> > 
> 
> > message listeners would be weak, and message manager cleans up its 
> > dead-weak-references list occasionally.
> 
> 
> 
> Can you elaborate more on the "adding some expando property to the window" 
> suggestion, please?
> 
> 
> 
> I am obviously missing a lot of important background here, so forgive me in 
> advance if my questions sounds too dumb. Looking at the code, it seems that 
> we are cleaning up dead weak references at [1]. For what I understand from 
> your previous comment, you are suggesting that we can avoid removing [1] the 
> listeners that lives in a window (?) that has an specific expando property 
> that we should have previously set. And we can rely on khueyfix getting rid 
> of these references when this window goes away. Once the window goes away and 
> khueyfix cleans up the references, the message manager will be able to remove 
> the listeners, cause the window (and its expando property) won't be there 
> anymore. Am I understanding this correctly?

Yes, this way it is the API's responsibility to keep it's objects (like the 
MessagePorts) alive by holding onto them or tacking them onto something that 
stays alive, presumably as expandos.

While the alternative where you allow DOMRequestIpcHelper to hold strongrefs 
will work, I'd say that it is not the right way.

In the Inter-App Communication API, would it make sense for the 
WebappsApplication object to hold onto MessagePorts, since it itself seems to 
be held alive by the window? [1]
http://mxr.mozilla.org/mozilla-central/source/dom/apps/src/Webapps.js#307

Nikhil
_______________________________________________
dev-b2g mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-b2g

Reply via email to