summaryrefslogtreecommitdiff
path: root/dom
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2023-10-01 20:54:48 +0200
committerMoonchild <moonchild@palemoon.org>2023-10-01 20:54:48 +0200
commit16e405f81806ac85332a7c208d93e2edec7984d8 (patch)
treebc5528d6c6886f40cf9d771cf054da323ddec298 /dom
parentbfae2ed943863d171f3687a67a0f5575c84d4192 (diff)
downloaduxp-16e405f81806ac85332a7c208d93e2edec7984d8.tar.gz
Issue #2323 - Part 3: Exclude chrome workers from worker timer clamping.
Diffstat (limited to 'dom')
-rw-r--r--dom/workers/WorkerPrivate.cpp6
-rw-r--r--dom/workers/WorkerPrivate.h4
2 files changed, 8 insertions, 2 deletions
diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp
index f0542e63ce..622a882a65 100644
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -1963,6 +1963,7 @@ struct WorkerPrivate::TimeoutInfo
, mNestingLevel(0)
, mIsInterval(false)
, mCanceled(false)
+ , mOnChromeWorker(false)
{
MOZ_COUNT_CTOR(mozilla::dom::workers::WorkerPrivate::TimeoutInfo);
}
@@ -1992,7 +1993,8 @@ struct WorkerPrivate::TimeoutInfo
void CalculateTargetTime() {
auto target = mInterval;
- if (mNestingLevel >= kClampTimeoutNestingLevel) {
+ // Clamp timeout for workers, except chrome workers
+ if (mNestingLevel >= kClampTimeoutNestingLevel && !mOnChromeWorker) {
target = TimeDuration::Max(
mInterval,
TimeDuration::FromMilliseconds(Preferences::GetInt("dom.min_timeout_value")));
@@ -2007,6 +2009,7 @@ struct WorkerPrivate::TimeoutInfo
uint32_t mNestingLevel;
bool mIsInterval;
bool mCanceled;
+ bool mOnChromeWorker;
};
class WorkerJSContextStats final : public JS::RuntimeStats
@@ -6100,6 +6103,7 @@ WorkerPrivate::SetTimeout(JSContext* aCx,
}
nsAutoPtr<TimeoutInfo> newInfo(new TimeoutInfo());
+ newInfo->mOnChromeWorker = mIsChromeWorker;
newInfo->mIsInterval = aIsInterval;
newInfo->mId = timerId;
newInfo->AccumulateNestingLevel(this->mCurrentTimerNestingLevel);
diff --git a/dom/workers/WorkerPrivate.h b/dom/workers/WorkerPrivate.h
index 018d14321a..9effdccc9a 100644
--- a/dom/workers/WorkerPrivate.h
+++ b/dom/workers/WorkerPrivate.h
@@ -213,6 +213,9 @@ protected:
RefPtr<EventTarget> mEventTarget;
nsTArray<RefPtr<WorkerRunnable>> mPreStartRunnables;
+ // True if the worker is used in the UI
+ bool mIsChromeWorker;
+
private:
WorkerPrivate* mParent;
nsString mScriptURL;
@@ -242,7 +245,6 @@ private:
uint32_t mParentWindowPausedDepth;
Status mParentStatus;
bool mParentFrozen;
- bool mIsChromeWorker;
bool mMainThreadObjectsForgotten;
// mIsSecureContext is set once in our constructor; after that it can be read
// from various threads. We could make this const if we were OK with setting