Skip to content

Commit c6491c0

Browse files
Iunusovdsmithpadilla
authored andcommitted
Bug 2002517 - FIX Extension native messaging performance a=diannaS
- added a chrome worker exception Original Revision: https://phabricator.services.mozilla.com/D274356 Differential Revision: https://phabricator.services.mozilla.com/D274614
1 parent 70c4c51 commit c6491c0

5 files changed

Lines changed: 19 additions & 8 deletions

File tree

‎dom/base/TimeoutManager.cpp‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ bool TimeoutManager::IsBackground() const {
9898

9999
bool TimeoutManager::IsActive() const {
100100
// A window/worker is considered active if:
101-
// * It is a chrome window
101+
// * It is a chrome window/worker
102102
// * It is playing audio
103103
//
104104
// Note that a window/worker can be considered active if it is either in the
@@ -109,6 +109,10 @@ bool TimeoutManager::IsActive() const {
109109
return true;
110110
}
111111

112+
if (mIsChromeWorker) {
113+
return true;
114+
}
115+
112116
// Check if we're playing audio
113117
if (mGlobalObject.IsPlayingAudio()) {
114118
return true;
@@ -326,7 +330,8 @@ TimeDuration TimeoutManager::CalculateDelay(Timeout* aTimeout) const {
326330
TimeDuration result = aTimeout->mInterval;
327331

328332
if (aTimeout->mNestingLevel >=
329-
StaticPrefs::dom_clamp_timeout_nesting_level()) {
333+
StaticPrefs::dom_clamp_timeout_nesting_level() &&
334+
!mIsChromeWorker) {
330335
uint32_t minTimeoutValue = StaticPrefs::dom_min_timeout_value();
331336
result = TimeDuration::Max(result,
332337
TimeDuration::FromMilliseconds(minTimeoutValue));
@@ -408,7 +413,8 @@ uint32_t TimeoutManager::sNestingLevel = 0;
408413

409414
TimeoutManager::TimeoutManager(nsIGlobalObject& aHandle,
410415
uint32_t aMaxIdleDeferMS,
411-
nsISerialEventTarget* aEventTarget)
416+
nsISerialEventTarget* aEventTarget,
417+
bool aIsChromeWorker)
412418
: mGlobalObject(aHandle),
413419
mExecutor(new TimeoutExecutor(this, false, 0)),
414420
mIdleExecutor(new TimeoutExecutor(this, true, aMaxIdleDeferMS)),
@@ -429,7 +435,8 @@ TimeoutManager::TimeoutManager(nsIGlobalObject& aHandle,
429435
mBudgetThrottleTimeouts(false),
430436
mIsLoading(false),
431437
mEventTarget(aEventTarget),
432-
mIsWindow(aHandle.GetAsInnerWindow()) {
438+
mIsWindow(aHandle.GetAsInnerWindow()),
439+
mIsChromeWorker(aIsChromeWorker) {
433440
MOZ_LOG(gTimeoutLog, LogLevel::Debug,
434441
("TimeoutManager %p created, tracking bucketing %s\n", this,
435442
StaticPrefs::privacy_trackingprotection_annotate_channels()

‎dom/base/TimeoutManager.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ class TimeoutManager final {
3030

3131
public:
3232
TimeoutManager(nsIGlobalObject& aHandle, uint32_t aMaxIdleDeferMS,
33-
nsISerialEventTarget* aEventTarget);
33+
nsISerialEventTarget* aEventTarget,
34+
bool aIsChromeWorker = false);
3435
~TimeoutManager();
3536
TimeoutManager(const TimeoutManager& rhs) = delete;
3637
void operator=(const TimeoutManager& rhs) = delete;
@@ -268,6 +269,8 @@ class TimeoutManager final {
268269

269270
const bool mIsWindow;
270271

272+
const bool mIsChromeWorker;
273+
271274
uint32_t mNestingLevel{0};
272275

273276
static uint32_t sNestingLevel;

‎dom/workers/WorkerScope.cpp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,8 @@ WorkerGlobalScopeBase::WorkerGlobalScopeBase(
270270
mClientSource(std::move(aClientSource)),
271271
mSerialEventTarget(aWorkerPrivate->HybridEventTarget()) {
272272
mTimeoutManager = MakeUnique<dom::TimeoutManager>(
273-
*this, /* not used on workers */ 0, mSerialEventTarget);
273+
*this, /* not used on workers */ 0, mSerialEventTarget,
274+
mWorkerPrivate->IsChromeWorker());
274275
LOG(("WorkerGlobalScopeBase::WorkerGlobalScopeBase [%p]", this));
275276
MOZ_ASSERT(mWorkerPrivate);
276277
#ifdef DEBUG

‎toolkit/components/extensions/test/xpcshell/test_ext_native_messaging_perf.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// on slow, resource-constrained devices. See
1111
// https://bugzilla.mozilla.org/show_bug.cgi?id=1951522#c31
1212

13-
let max_round_trip_time_ms = 90;
13+
let max_round_trip_time_ms = 30;
1414

1515
const MAX_ROUND_TRIP_TIME_MS = max_round_trip_time_ms;
1616

‎toolkit/modules/subprocess/test/xpcshell/test_subprocess_perf.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// https://bugzilla.mozilla.org/show_bug.cgi?id=1729546#c4 and
1010
// https://bugzilla.mozilla.org/show_bug.cgi?id=1951522#c31
1111

12-
let max_round_trip_time_ms = 90;
12+
let max_round_trip_time_ms = 30;
1313

1414
const MAX_ROUND_TRIP_TIME_MS = max_round_trip_time_ms;
1515

0 commit comments

Comments
 (0)