Bug 1726712 - Only do a shrinking GC if we're not animating r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D124014
This commit is contained in:
Paul Bone 2021-09-29 00:37:39 +00:00
Родитель b3f8450984
Коммит a3770290ab
1 изменённых файлов: 22 добавлений и 6 удалений

Просмотреть файл

@ -7,6 +7,7 @@
#include "mozilla/StaticPrefs_javascript.h"
#include "mozilla/CycleCollectedJSRuntime.h"
#include "mozilla/dom/ScriptSettings.h"
#include "nsRefreshDriver.h"
namespace mozilla {
@ -115,11 +116,20 @@ bool CCGCScheduler::GCRunnerFiredDoGC(TimeStamp aDeadline,
// Run a GC slice, possibly the first one of a major GC.
nsJSContext::IsShrinking is_shrinking = nsJSContext::NonShrinkingGC;
if (!InIncrementalGC() && aStep.mReason == JS::GCReason::USER_INACTIVE) {
bool do_gc = mWantAtLeastRegularGC;
if (!mUserIsActive) {
mIsCompactingOnUserInactive = true;
is_shrinking = nsJSContext::ShrinkingGC;
} else if (!mWantAtLeastRegularGC) {
// Don't GC now.
if (!nsRefreshDriver::IsRegularRateTimerTicking()) {
mIsCompactingOnUserInactive = true;
is_shrinking = nsJSContext::ShrinkingGC;
do_gc = true;
} else {
// Poke again to restart the timer.
PokeShrinkingGC();
}
}
if (!do_gc) {
using mozilla::ipc::IdleSchedulerChild;
IdleSchedulerChild* child =
IdleSchedulerChild::GetMainThreadIdleScheduler();
@ -233,8 +243,14 @@ void CCGCScheduler::PokeShrinkingGC() {
[](nsITimer* aTimer, void* aClosure) {
CCGCScheduler* s = static_cast<CCGCScheduler*>(aClosure);
s->KillShrinkingGCTimer();
s->SetWantMajorGC(JS::GCReason::USER_INACTIVE);
s->EnsureGCRunner(0);
if (!s->mUserIsActive) {
if (!nsRefreshDriver::IsRegularRateTimerTicking()) {
s->SetWantMajorGC(JS::GCReason::USER_INACTIVE);
s->EnsureGCRunner(0);
} else {
s->PokeShrinkingGC();
}
}
},
this, StaticPrefs::javascript_options_compact_on_user_inactive_delay(),
nsITimer::TYPE_ONE_SHOT_LOW_PRIORITY, "ShrinkingGCTimerFired");