A lot of IPDL-using code winds up using reference counting, and then plays tricks with .forget().take() and similar so that raw pointers wind up getting passed around. WDYT about forcing, say, AllocPProtocol to return already_AddRefed<PProtocol>? Not entirely sure what to do about DeallocPProtocol...maybe make managing protocols hold strong references in their managee arrays? And eliminate DeallocPProtocol entirely?
I think it kinda sucks that we ever ended up with reference-counted actors, and I would really hate it if we propagated it to more code than absolutely necessary.
Summary: bake in reference-counting semantics to idpl Alloc/Dealoc methods → bake in reference-counting semantics to idpl Alloc/Dealloc methods
(In reply to Benjamin Smedberg [:bsmedberg] from comment #1) > I think it kinda sucks that we ever ended up with reference-counted actors, > and I would really hate it if we propagated it to more code than absolutely > necessary. But why did we end up with reference-counted actors in the first place? Because the lifetimes of their parent (non-ipdl, presumably reference-counted) entities were a poor match for the tree-structured ipdl stuff, or something else?
All of the initial plugin tree was carefully not-reference-counted. When we started hacking in content processes, we started bolting IPDL stuff on the side of existing XPCOM API layers (in particular the necko streams) and rather than having separate IPDL and XPCOM objects, they got unified as a single C++ object which was for both IPDL and XPCOM. I think that's technical debt we used for initial expediency but something we ought to solve long-term.
I agree with Benjamin here.
The pattern I ended up with to avoid ref-counted actors in my code was: 1) Create pure virtual listener class that provides the ipdl Recv*() and ActorDestroyed() methods. 2) My ref-counted class implements listener class and calls SetListener() on Actor. 3) In the listener ActorDestroy() my ref-counted class calls ClearListener() on Actor. 4) Actor proxies all Recv*() and ActorDestry() calls to listener. It would be nice if IPDL could generate the code for this kind of listener proxying automatically. I think it would make it easier to integrate ref-counted classes with actors.
You need to log in before you can comment on or make changes to this bug.