mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 977940, part 2 - Don't automatically trigger the ghost window detector during ICC. r=smaug
This commit is contained in:
parent
ae691fcc12
commit
e91cb76669
@ -31,7 +31,9 @@ StaticRefPtr<nsWindowMemoryReporter> sWindowReporter;
|
||||
const int32_t kTimeBetweenChecks = 45; /* seconds */
|
||||
|
||||
nsWindowMemoryReporter::nsWindowMemoryReporter()
|
||||
: mLastCheckForGhostWindows(TimeStamp::NowLoRes())
|
||||
: mLastCheckForGhostWindows(TimeStamp::NowLoRes()),
|
||||
mCycleCollectorIsRunning(false),
|
||||
mCheckTimerWaitingForCCEnd(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -116,6 +118,10 @@ nsWindowMemoryReporter::Init()
|
||||
/* weakRef = */ true);
|
||||
os->AddObserver(sWindowReporter, "after-minimize-memory-usage",
|
||||
/* weakRef = */ true);
|
||||
os->AddObserver(sWindowReporter, "cycle-collector-begin",
|
||||
/* weakRef = */ true);
|
||||
os->AddObserver(sWindowReporter, "cycle-collector-end",
|
||||
/* weakRef = */ true);
|
||||
}
|
||||
|
||||
RegisterStrongMemoryReporter(new GhostWindowsReporter());
|
||||
@ -619,6 +625,18 @@ nsWindowMemoryReporter::Observe(nsISupports *aSubject, const char *aTopic,
|
||||
ObserveDOMWindowDetached(aSubject);
|
||||
} else if (!strcmp(aTopic, "after-minimize-memory-usage")) {
|
||||
ObserveAfterMinimizeMemoryUsage();
|
||||
} else if (!strcmp(aTopic, "cycle-collector-begin")) {
|
||||
if (mCheckTimer) {
|
||||
mCheckTimerWaitingForCCEnd = true;
|
||||
KillCheckTimer();
|
||||
}
|
||||
mCycleCollectorIsRunning = true;
|
||||
} else if (!strcmp(aTopic, "cycle-collector-end")) {
|
||||
mCycleCollectorIsRunning = false;
|
||||
if (mCheckTimerWaitingForCCEnd) {
|
||||
mCheckTimerWaitingForCCEnd = false;
|
||||
AsyncCheckForGhostWindows();
|
||||
}
|
||||
} else {
|
||||
MOZ_ASSERT(false);
|
||||
}
|
||||
@ -645,6 +663,7 @@ void
|
||||
nsWindowMemoryReporter::CheckTimerFired(nsITimer* aTimer, void* aClosure)
|
||||
{
|
||||
if (sWindowReporter) {
|
||||
MOZ_ASSERT(!sWindowReporter->mCycleCollectorIsRunning);
|
||||
sWindowReporter->CheckForGhostWindows();
|
||||
}
|
||||
}
|
||||
@ -656,6 +675,11 @@ nsWindowMemoryReporter::AsyncCheckForGhostWindows()
|
||||
return;
|
||||
}
|
||||
|
||||
if (mCycleCollectorIsRunning) {
|
||||
mCheckTimerWaitingForCCEnd = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// If more than kTimeBetweenChecks seconds have elapsed since the last check,
|
||||
// timerDelay is 0. Otherwise, it is kTimeBetweenChecks, reduced by the time
|
||||
// since the last check. Reducing the delay by the time since the last check
|
||||
|
@ -237,6 +237,10 @@ private:
|
||||
mozilla::TimeStamp mLastCheckForGhostWindows;
|
||||
|
||||
nsCOMPtr<nsITimer> mCheckTimer;
|
||||
|
||||
bool mCycleCollectorIsRunning;
|
||||
|
||||
bool mCheckTimerWaitingForCCEnd;
|
||||
};
|
||||
|
||||
#endif // nsWindowMemoryReporter_h__
|
||||
|
@ -729,6 +729,11 @@ void
|
||||
XPCJSRuntime::EndCycleCollectionCallback(CycleCollectorResults &aResults)
|
||||
{
|
||||
nsJSContext::EndCycleCollectionCallback(aResults);
|
||||
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
if (obs) {
|
||||
obs->NotifyObservers(nullptr, "cycle-collector-end", nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user