Bug 1957994 - worker background state change should update timeout manager backgound state, r=smaug

call TimeoutManager::UpdateBackgroundState() in order to schedule the TimeoutExecutor in case the throttling is enabled and MinSchedulingDelay() is changed

Differential Revision: https://phabricator.services.mozilla.com/D244184
This commit is contained in:
aiunusov@mozilla.com
2025-04-03 16:49:59 +00:00
parent 24829fe667
commit f742f18fae

View File

@@ -4531,6 +4531,15 @@ bool WorkerPrivate::ChangeBackgroundStateInternal(bool aIsBackground) {
AssertIsOnWorkerThread(); AssertIsOnWorkerThread();
mIsInBackground = aIsBackground; mIsInBackground = aIsBackground;
auto data = mWorkerThreadAccessible.Access(); auto data = mWorkerThreadAccessible.Access();
if (StaticPrefs::dom_workers_timeoutmanager_AtStartup() &&
StaticPrefs::dom_workers_throttling_enabled_AtStartup()) {
auto* timeoutManager =
data->mScope ? data->mScope->GetTimeoutManager() : nullptr;
if (timeoutManager) {
timeoutManager->UpdateBackgroundState();
}
}
for (uint32_t index = 0; index < data->mChildWorkers.Length(); index++) { for (uint32_t index = 0; index < data->mChildWorkers.Length(); index++) {
if (aIsBackground) { if (aIsBackground) {
data->mChildWorkers[index]->SetIsRunningInBackground(); data->mChildWorkers[index]->SetIsRunningInBackground();