mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-03 14:28:39 +09:00
Bug 1159003 - setResourceTimingBufferSize shouldn't affect user timing, but we should clean user markers if we have memory pressure, r=bz
This commit is contained in:
parent
6beccbf6ce
commit
bc3eb89dee
5 changed files with 40 additions and 17 deletions
|
|
@ -318,6 +318,8 @@ nsGlobalWindow::DOMMinTimeoutValue() const {
|
|||
// nsTimerImpl.h for details.
|
||||
#define DOM_MAX_TIMEOUT_VALUE DELAY_INTERVAL_LIMIT
|
||||
|
||||
#define MEMORY_PRESSURE_OBSERVER_TOPIC "memory-pressure"
|
||||
|
||||
// The interval at which we execute idle callbacks
|
||||
static uint32_t gThrottledIdlePeriodLength;
|
||||
|
||||
|
|
@ -1525,6 +1527,8 @@ nsGlobalWindow::nsGlobalWindow(nsGlobalWindow *aOuterWindow)
|
|||
// Watch for dom-storage2-changed so we can fire storage
|
||||
// events. Use a strong reference.
|
||||
os->AddObserver(mObserver, "dom-storage2-changed", false);
|
||||
|
||||
os->AddObserver(mObserver, MEMORY_PRESSURE_OBSERVER_TOPIC, false);
|
||||
}
|
||||
|
||||
Preferences::AddStrongObserver(mObserver, "intl.accept_languages");
|
||||
|
|
@ -1840,6 +1844,7 @@ nsGlobalWindow::CleanUp()
|
|||
if (os) {
|
||||
os->RemoveObserver(mObserver, NS_IOSERVICE_OFFLINE_STATUS_TOPIC);
|
||||
os->RemoveObserver(mObserver, "dom-storage2-changed");
|
||||
os->RemoveObserver(mObserver, MEMORY_PRESSURE_OBSERVER_TOPIC);
|
||||
}
|
||||
|
||||
if (mIdleService) {
|
||||
|
|
@ -11702,6 +11707,13 @@ nsGlobalWindow::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!nsCRT::strcmp(aTopic, MEMORY_PRESSURE_OBSERVER_TOPIC)) {
|
||||
if (mPerformance) {
|
||||
mPerformance->MemoryPressure();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!nsCRT::strcmp(aTopic, OBSERVER_TOPIC_IDLE)) {
|
||||
mCurrentlyIdle = true;
|
||||
if (IsFrozen()) {
|
||||
|
|
|
|||
|
|
@ -262,11 +262,6 @@ already_AddRefed<PerformanceMark> Performance::Mark(
|
|||
const PerformanceMarkOptions& aMarkOptions,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
// Don't add the entry if the buffer is full. XXX should be removed by bug 1159003.
|
||||
if (mUserEntries.Length() >= mResourceTimingBufferSize) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIGlobalObject> parent = GetParentObject();
|
||||
if (!parent || parent->IsDying() || !parent->GetGlobalJSObject()) {
|
||||
aRv.Throw(NS_ERROR_DOM_UT_UNAVAILABLE_GLOBAL_OBJECT);
|
||||
|
|
@ -490,12 +485,6 @@ Performance::Measure(JSContext* aCx,
|
|||
const Optional<nsAString>& aEndMark,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
// Don't add the entry if the buffer is full. XXX should be removed by bug
|
||||
// 1159003.
|
||||
if (mUserEntries.Length() >= mResourceTimingBufferSize) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const PerformanceMeasureOptions* options = nullptr;
|
||||
if (aStartOrMeasureOptions.IsPerformanceMeasureOptions()) {
|
||||
options = &aStartOrMeasureOptions.GetAsPerformanceMeasureOptions();
|
||||
|
|
@ -753,5 +742,11 @@ Performance::IsObserverEnabled(JSContext* aCx, JSObject* aGlobal)
|
|||
return runnable->Dispatch() && runnable->IsEnabled();
|
||||
}
|
||||
|
||||
void
|
||||
Performance::MemoryPressure()
|
||||
{
|
||||
mUserEntries.Clear();
|
||||
}
|
||||
|
||||
} // dom namespace
|
||||
} // mozilla namespace
|
||||
|
|
|
|||
|
|
@ -124,6 +124,8 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
void MemoryPressure();
|
||||
|
||||
protected:
|
||||
Performance();
|
||||
explicit Performance(nsPIDOMWindowInner* aWindow);
|
||||
|
|
|
|||
|
|
@ -6441,14 +6441,23 @@ WorkerPrivate::MemoryPressureInternal()
|
|||
{
|
||||
AssertIsOnWorkerThread();
|
||||
|
||||
RefPtr<Console> console = mScope ? mScope->GetConsoleIfExists() : nullptr;
|
||||
if (console) {
|
||||
console->ClearStorage();
|
||||
if (mScope) {
|
||||
RefPtr<Console> console = mScope->GetConsoleIfExists();
|
||||
if (console) {
|
||||
console->ClearStorage();
|
||||
}
|
||||
|
||||
RefPtr<Performance> performance = mScope->GetPerformanceIfExists();
|
||||
if (performance) {
|
||||
performance->MemoryPressure();
|
||||
}
|
||||
}
|
||||
|
||||
console = mDebuggerScope ? mDebuggerScope->GetConsoleIfExists() : nullptr;
|
||||
if (console) {
|
||||
console->ClearStorage();
|
||||
if (mDebuggerScope) {
|
||||
RefPtr<Console> console = mDebuggerScope->GetConsoleIfExists();
|
||||
if (console) {
|
||||
console->ClearStorage();
|
||||
}
|
||||
}
|
||||
|
||||
for (uint32_t index = 0; index < mChildWorkers.Length(); index++) {
|
||||
|
|
|
|||
|
|
@ -157,6 +157,11 @@ public:
|
|||
|
||||
Performance* GetPerformance();
|
||||
|
||||
Performance* GetPerformanceIfExists() const
|
||||
{
|
||||
return mPerformance;
|
||||
}
|
||||
|
||||
already_AddRefed<Promise>
|
||||
Fetch(const RequestOrUSVString& aInput, const RequestInit& aInit, ErrorResult& aRv);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue