Commit 4a7bd2a3 authored by kouhei@chromium.org's avatar kouhei@chromium.org

WebLeakDetector: Fix false positive leaks on worker tests when oilpan is enabled.

This patch adds another round of GC to make sure Document is destroyed after |WorkerMessagingProxy::workerObjectDestroyed|.

BUG=389042

Review URL: https://codereview.chromium.org/350013003

git-svn-id: svn://svn.chromium.org/blink/trunk@177043 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 9366b2e4
......@@ -61,6 +61,7 @@ public:
: m_client(client)
, m_delayedGCAndReportTimer(this, &WebLeakDetectorImpl::delayedGCAndReport)
, m_delayedReportTimer(this, &WebLeakDetectorImpl::delayedReport)
, m_numberOfGCNeeded(0)
{
ASSERT(m_client);
}
......@@ -76,6 +77,7 @@ private:
WebLeakDetectorClient* m_client;
Timer<WebLeakDetectorImpl> m_delayedGCAndReportTimer;
Timer<WebLeakDetectorImpl> m_delayedReportTimer;
int m_numberOfGCNeeded;
};
void WebLeakDetectorImpl::collectGarbageAndGetDOMCounts(WebLocalFrame* frame)
......@@ -98,19 +100,25 @@ void WebLeakDetectorImpl::collectGarbageAndGetDOMCounts(WebLocalFrame* frame)
// This method is called from navigation hook inside FrameLoader,
// so previous document is still held by the loader until the next event loop.
// Complete all pending tasks before proceeding to gc.
m_numberOfGCNeeded = 2;
m_delayedGCAndReportTimer.startOneShot(0, FROM_HERE);
}
void WebLeakDetectorImpl::delayedGCAndReport(Timer<WebLeakDetectorImpl>*)
{
// We do a second GC here to address flakiness: Resource GC may have postponed clean-up tasks to next event loop.
// We do a second and third GC here to address flakiness
// The second GC is necessary as Resource GC may have postponed clean-up tasks to next event loop.
// The third GC is necessary for cleaning up Document after worker object died.
for (int i = 0; i < kNumberOfGCsToClaimChains; ++i)
V8GCController::collectGarbage(V8PerIsolateData::mainThreadIsolate());
// Note: Oilpan precise GC is scheduled at the end of the event loop.
// Inspect counters on the next event loop.
m_delayedReportTimer.startOneShot(0, FROM_HERE);
if (--m_numberOfGCNeeded)
m_delayedGCAndReportTimer.startOneShot(0, FROM_HERE);
else
m_delayedReportTimer.startOneShot(0, FROM_HERE);
}
void WebLeakDetectorImpl::delayedReport(Timer<WebLeakDetectorImpl>*)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment