From 866053df7a2a32d9bb39c1f9cb60326dde82e032 Mon Sep 17 00:00:00 2001 From: Olli Pettay Date: Tue, 25 Jul 2017 22:22:12 +0300 Subject: [PATCH] Bug 1384215 - Try to run deferred deletion more likely during idle time, r=mccr8 --HG-- extra : rebase_source : 0dd6ec9641e323959a454d812a9d2f15b1d02982 --- dom/base/nsJSEnvironment.cpp | 13 +++++++++---- js/xpconnect/src/XPCJSRuntime.cpp | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index 0c8b0f6905ef..a177e3eca758 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -2090,10 +2090,15 @@ CCRunnerFired(TimeStamp aDeadline, void* aData) // Our efforts to avoid a CC have failed, so we return to let the // timer fire once more to trigger a CC. - // Clear content unbinder before the first CC slice. - Element::ClearContentUnbinder(); - // And trigger deferred deletion too. - nsCycleCollector_doDeferredDeletion(); + if (!aDeadline.IsNull() && TimeStamp::Now() < aDeadline) { + // Clear content unbinder before the first CC slice. + Element::ClearContentUnbinder(); + + if (TimeStamp::Now() < aDeadline) { + // And trigger deferred deletion too. + nsCycleCollector_doDeferredDeletion(); + } + } return didDoWork; } } else { diff --git a/js/xpconnect/src/XPCJSRuntime.cpp b/js/xpconnect/src/XPCJSRuntime.cpp index f16c4bc6829b..a6c49cc85b9e 100644 --- a/js/xpconnect/src/XPCJSRuntime.cpp +++ b/js/xpconnect/src/XPCJSRuntime.cpp @@ -140,7 +140,7 @@ public: nsresult Dispatch() { nsCOMPtr self(this); - return NS_IdleDispatchToCurrentThread(self.forget(), 1000); + return NS_IdleDispatchToCurrentThread(self.forget(), 2500); } void Start(bool aContinuation = false, bool aPurge = false)