mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-08 00:07:30 +09:00
Issue #2453 - Don't try to directly access pref on worker thread.
This commit is contained in:
parent
f44db6a28b
commit
4f83e877a8
2 changed files with 20 additions and 5 deletions
|
|
@ -1995,13 +1995,27 @@ struct WorkerPrivate::TimeoutInfo
|
|||
mNestingLevel = kClampTimeoutNestingLevel;
|
||||
}
|
||||
|
||||
void CalculateTargetTime() {
|
||||
void CalculateTargetTime(JSContext* aCx) {
|
||||
auto target = mInterval;
|
||||
int32_t minTimeoutValue;
|
||||
|
||||
if (NS_IsMainThread()) {
|
||||
// We can get the pref value directly.
|
||||
minTimeoutValue = Preferences::GetInt("dom.min_timeout_value");
|
||||
} else {
|
||||
// We're on a worker thread; go through WorkerPrivate.
|
||||
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
|
||||
if (workerPrivate) {
|
||||
minTimeoutValue = workerPrivate->DOMMinTimoutValue();
|
||||
} else {
|
||||
// fall back to default 4 ms
|
||||
minTimeoutValue = 4;
|
||||
}
|
||||
}
|
||||
|
||||
// Clamp timeout for workers, except chrome workers
|
||||
if (mNestingLevel >= kClampTimeoutNestingLevel && !mOnChromeWorker) {
|
||||
target = TimeDuration::Max(
|
||||
mInterval,
|
||||
TimeDuration::FromMilliseconds(Preferences::GetInt("dom.min_timeout_value")));
|
||||
target = TimeDuration::Max(mInterval,TimeDuration::FromMilliseconds(minTimeoutValue));
|
||||
}
|
||||
mTargetTime = TimeStamp::Now() + target;
|
||||
}
|
||||
|
|
@ -6387,7 +6401,7 @@ WorkerPrivate::RunExpiredTimeouts(JSContext* aCx)
|
|||
// Reschedule intervals.
|
||||
// Reschedule a timeout and, if needed, increase the nesting level.
|
||||
info->AccumulateNestingLevel(info->mNestingLevel);
|
||||
info->CalculateTargetTime();
|
||||
info->CalculateTargetTime(aCx);
|
||||
// Don't re-sort the list here, we'll do that at the end.
|
||||
++index;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue