import from UXP: Issue #2323 - Part 3: Exclude chrome workers from worker timer clamping. (2ca57151)

This commit is contained in:
2023-10-03 22:33:36 +08:00
parent 28e325ff80
commit efe9ce4bb9
2 changed files with 8 additions and 2 deletions
+5 -1
View File
@@ -1921,6 +1921,7 @@ struct WorkerPrivate::TimeoutInfo
, mNestingLevel(0)
, mIsInterval(false)
, mCanceled(false)
, mOnChromeWorker(false)
{
MOZ_COUNT_CTOR(mozilla::dom::workers::WorkerPrivate::TimeoutInfo);
}
@@ -1950,7 +1951,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")));
@@ -1965,6 +1967,7 @@ struct WorkerPrivate::TimeoutInfo
uint32_t mNestingLevel;
bool mIsInterval;
bool mCanceled;
bool mOnChromeWorker;
};
class WorkerJSContextStats final : public JS::RuntimeStats
@@ -6040,6 +6043,7 @@ WorkerPrivate::SetTimeout(JSContext* aCx,
}
nsAutoPtr<TimeoutInfo> newInfo(new TimeoutInfo());
newInfo->mOnChromeWorker = mIsChromeWorker;
newInfo->mIsInterval = aIsInterval;
newInfo->mId = timerId;
newInfo->AccumulateNestingLevel(this->mCurrentTimerNestingLevel);
+3 -1
View File
@@ -214,6 +214,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;
@@ -243,7 +246,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