Closed Bug 1938613 Opened 2 months ago Closed 29 days ago

Add a way to only log a CC when a window is leaked

Categories

(Core :: Cycle Collector, task)

task

Tracking

()

RESOLVED FIXED
136 Branch
Tracking Status
firefox136 --- fixed

People

(Reporter: mccr8, Assigned: mccr8)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

I've been experimenting with an option to make it so that CC logs are only collected if a DOM window is alive. This makes use of the existing nsContentUtils::GetCurrentInnerOrOuterWindowCount() which tracks how many windows are alive. The goal here is to avoid making logs you don't care about.

This could also be used to make CC logging "always on" on TreeHerder. It would be nice if for the leaks in bug 1866073 you could open up the job for a failure and get a CC log. Some extra work would be needed to get this to work in content processes due to sandboxing, or we'd need to run find_roots as part of the test run itself and save it in the same directory as the XPCOM leak logs.

To get this effect, you also need to use the MOZ_CC_LOG_SHUTDOWN_SKIP=1 option, because we always have windows to free in the first CC.

In addition to the implementation of the option itself, I also needed to delay initializing the logger. The issue is that in the first CC we unlink a bunch of windows, but they aren't actually freed until we run FixGrayBits at the start of the next CC, so we need to wait to call LogThisCC() until after that has run, but before we start using the log. If we want a GC log, we still have to initialize the logger before FixGrayBits, so unfortunately this means you need to use MOZ_CC_DISABLE_GC_LOG=1 to get "clean logs". CC logs alone are still at least somewhat useful.

This adds the MOZ_CC_LOG_WINDOW_ONLY option. This makes it so that
we never get a CC log on the main thread unless there is a window
that is alive. This will result in less irrelevant logs when you
are investigating a DOM window leak.

I also moved the comments on the non-logging CC options first.

The goal of this is to make GetCurrentInnerOrOuterWindowCount()
more accurate. I was seeing regular cases where there was
a live window at the start of the CC but then it would
be freed by the shutdown GC before we actually start
traversing. This means that you need to disable GC logging
with MOZ_CC_DISABLE_GC_LOG=1 for this to fully work.

Pushed by amccreight@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/2b29b255ca6c part 1 - Add a way to get a cycle collector log only if a window is alive. r=smaug https://hg.mozilla.org/integration/autoland/rev/63ee162f95b6 part 2 - Delay initializing cycle collector logging. r=smaug
Status: NEW → RESOLVED
Closed: 29 days ago
Resolution: --- → FIXED
Target Milestone: --- → 136 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: