Closed Bug 1422983 Opened 7 years ago Closed 7 years ago

cycle collect ClientSource owner reference to nsGlobalWindowInner and nsDocShell

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla59
Tracking Status
thunderbird_esr52 --- unaffected
firefox-esr52 --- unaffected
firefox58 --- unaffected
firefox59 - fixed

People

(Reporter: bkelly, Assigned: bkelly)

References

Details

Attachments

(1 file, 1 obsolete file)

We are seeing some leaks on nightly lately.  It occurs to me that the ClientSource code I integrated with nsGlobalWindowInner and nsDocShell could be contributing to the problem.  There is a ref-cycle in play but we don't include it in the cycle collection because ClientSource is not ref-counted at the moment.
Summary: verify ClientSource does not break cycle collection for nsGlobalWindowInner and nsDocShell → cycle collect ClientSource owner reference to nsGlobalWindowInner and nsDocShell
This could cause bad leaks and should be easy to fix.
Make sure to traverse/unlink this in every CCed thing that holds one of these. It looks like at least nsDocShell and nsGlobalWindowInner have one. LoadInfo has one but it isn't CCed. WorkerPrivate has one, and maybe it is CCed?
Comment on attachment 8934316 [details] [diff] [review]
Cycle collect the ClientSource object when owned by an nsGlobalWindowInner or nsDocShell object. r=mccr8

Since this is a small patch I'm going to flag for review now even though try has not completed.

Note, we only need to CC the ClientSource when its owned by the nsGlobalWindowInner and nsDocShell.  These are the only cases where we have a strong ref out from ClientSource to a CC'able object.

When the ClientSource is owned by a WorkerPrivate or LoadInfo object we do not have a strong reference out to the owner.
Attachment #8934316 - Flags: review?(continuation)
Comment on attachment 8934316 [details] [diff] [review]
Cycle collect the ClientSource object when owned by an nsGlobalWindowInner or nsDocShell object. r=mccr8

Review of attachment 8934316 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/clients/manager/ClientSource.cpp
@@ +270,5 @@
> +{
> +  if (mOwner.is<RefPtr<nsPIDOMWindowInner>>()) {
> +    ImplCycleCollectionTraverse(aCallback,
> +                                mOwner.as<RefPtr<nsPIDOMWindowInner>>(),
> +                                "mOwner", aFlags);

You should use aName here instead of "mOwner", and in the other case. aName will be the name of the ClientSource field (for instance "mClientSource"). This is what the name of the field is going to show up as in the cycle collector log, for the window or docshell. If there was more than one thing here we wanted to traverse then it would get complicated but for now this will work. If you think that would be confusing, then maybe a field name like ClientSource::mOwner would work.
Attachment #8934316 - Flags: review?(continuation) → review+
Pushed by bkelly@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/46463dab3129
Cycle collect the ClientSource object when owned by an nsGlobalWindowInner or nsDocShell object. r=mccr8
Blocks: 1293277
Hmm, how good is the cycle collection stuff in nsDocShell. Didn't mystor make the globalwindow split in a bit different way because merging outer to nsDocShell was leaky.
(I wonder why mInitialClientSource is in docshell and not in outer. Perhaps doesn't matter much.)
https://hg.mozilla.org/mozilla-central/rev/46463dab3129
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla59
See Also: → 1422912
See Also: 1422912
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: