Open Bug 802442 Opened 12 years ago Updated 1 year ago

Add support for native cycle collected classes with inheritance

Categories

(Core :: Cycle Collector, defect)

defect

Tracking

()

People

(Reporter: mccr8, Unassigned)

References

Details

Ehsan tried to more audio stuff over from being nsISupports to being native but he hit a lot of problems, because we don't have any real support for native CCed classes with inheritance.

There are some minor annoyances, like not having nice macros for TRAVERSE_INHERITED_NATIVE, but the big problem is that we need to be able to get the "real" CC participant whenever we are going to add something to the purple buffer.  For nsISupports classes, they have the QI hack.  For existing native classes, they only have a single participant.  nsXULElement tags things and uses that.

One solution would be to add a virtual function Participant() that returns the actual participant for the class.  Any class that defines its own Traverse etc function must also define its own Participant() function. Then all of the subclasses of the base class could use the same concrete AddRef/Release functions, as the cost of an additional virtual call when we add something to the purple buffer.  RefCount logging would also be slightly messed up but we could add an additional ToName() kind of virtual method if we care.
Can we get assignee please? Besides a11y bug 812767 that needs it I realized that a11y::AccEvent derived classes keep pointers that should participate in cycle collection too. We might be leaking.
This is not quite trivial to fix. So for now I'd just inherit nsISupports.
Especially given the improved macros, making something cycle collectable is pretty easy.
That'd be a step back, we removed nsISupports from those classes in the past. Also that prevents dexpcom'ization of accessible object classes where keeping nsISupports inheritance should be bad for memory consumption.
See Also: → 1384717
Severity: normal → S3
Component: XPCOM → Cycle Collector
You need to log in before you can comment on or make changes to this bug.