Backed out changeset 5ed325ce740b (bug 1740335) for causing serviceworker related failures. CLOSED TREE

This commit is contained in:
criss
2021-12-02 17:24:08 +02:00
parent 21fefb11cf
commit ccfcd14710
9 changed files with 22 additions and 288 deletions

View File

@@ -5,7 +5,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "ServiceWorkerManager.h"
#include "ServiceWorkerPrivateImpl.h"
#include <algorithm>
@@ -97,13 +96,6 @@
# undef PostMessage
#endif
mozilla::LazyLogModule sWorkerTelemetryLog("WorkerTelemetry");
#ifdef LOG
# undef LOG
#endif
#define LOG(_args) MOZ_LOG(sWorkerTelemetryLog, LogLevel::Debug, _args);
using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::ipc;
@@ -111,11 +103,6 @@ using namespace mozilla::ipc;
namespace mozilla {
namespace dom {
// Counts the number of registered ServiceWorkers, and the number that
// handle Fetch, for reporting in Telemetry
uint32_t gServiceWorkersRegistered = 0;
uint32_t gServiceWorkersRegisteredFetch = 0;
static_assert(
nsIHttpChannelInternal::CORS_MODE_SAME_ORIGIN ==
static_cast<uint32_t>(RequestMode::Same_origin),
@@ -432,8 +419,6 @@ NS_IMPL_RELEASE(ServiceWorkerManager)
NS_INTERFACE_MAP_BEGIN(ServiceWorkerManager)
NS_INTERFACE_MAP_ENTRY(nsIServiceWorkerManager)
NS_INTERFACE_MAP_ENTRY(nsIObserver)
NS_INTERFACE_MAP_ENTRY(nsITimerCallback)
NS_INTERFACE_MAP_ENTRY(nsINamed)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIServiceWorkerManager)
NS_INTERFACE_MAP_END
@@ -443,9 +428,6 @@ ServiceWorkerManager::ServiceWorkerManager()
ServiceWorkerManager::~ServiceWorkerManager() {
// The map will assert if it is not empty when destroyed.
mRegistrationInfos.Clear();
if (mTelemetryTimer) {
mTelemetryTimer->Cancel();
}
// This can happen if the browser is started up in ProfileManager mode, in
// which case XPCOM will startup and shutdown, but there won't be any
@@ -510,22 +492,6 @@ void ServiceWorkerManager::Init(ServiceWorkerRegistrar* aRegistrar) {
}
mActor = static_cast<ServiceWorkerManagerChild*>(actor);
constexpr uint32_t period_ms = 10 * 1000;
NS_NewTimerWithCallback(getter_AddRefs(mTelemetryTimer), this, period_ms,
nsITimer::TYPE_REPEATING_SLACK);
}
NS_IMETHODIMP
ServiceWorkerManager::Notify(nsITimer* aTimer) {
ServiceWorkerPrivateImpl::ReportRunning();
return NS_OK;
}
// nsINamed implementation
NS_IMETHODIMP ServiceWorkerManager::GetName(nsACString& aNameOut) {
aNameOut.AssignLiteral("ServiceWorkerManager");
return NS_OK;
}
RefPtr<GenericErrorResultPromise> ServiceWorkerManager::StartControllingClient(
@@ -567,7 +533,7 @@ RefPtr<GenericErrorResultPromise> ServiceWorkerManager::StartControllingClient(
1);
// Always check to see if we failed to actually control the client. In
// that case remove the client from our list of controlled clients.
// that case removed the client from our list of controlled clients.
return promise->Then(
GetMainThreadSerialEventTarget(), __func__,
[](bool) {
@@ -885,6 +851,7 @@ RefPtr<ServiceWorkerRegistrationPromise> ServiceWorkerManager::Register(
queue->ScheduleJob(job);
MOZ_ASSERT(NS_IsMainThread());
Telemetry::Accumulate(Telemetry::SERVICE_WORKER_REGISTRATIONS, 1);
return cb->Promise();
}
@@ -1532,7 +1499,7 @@ void ServiceWorkerManager::LoadRegistration(
// If active worker script matches our expectations for a "current worker",
// then we are done. Since scripts with the same URL might have different
// contents such as updated scripts or scripts with different LoadFlags, we
// use the CacheName to judge whether the two scripts are identical, where
// use the CacheName to judje whether the two scripts are identical, where
// the CacheName is an UUID generated when a new script is found.
if (registration->GetActive() &&
registration->GetActive()->CacheName() == aRegistration.cacheName()) {
@@ -1567,21 +1534,10 @@ void ServiceWorkerManager::LoadRegistration(
void ServiceWorkerManager::LoadRegistrations(
const nsTArray<ServiceWorkerRegistrationData>& aRegistrations) {
MOZ_ASSERT(NS_IsMainThread());
uint32_t fetch = 0;
for (uint32_t i = 0, len = aRegistrations.Length(); i < len; ++i) {
LoadRegistration(aRegistrations[i]);
if (aRegistrations[i].currentWorkerHandlesFetch()) {
fetch++;
}
}
gServiceWorkersRegistered = aRegistrations.Length();
gServiceWorkersRegisteredFetch = fetch;
Telemetry::ScalarSet(Telemetry::ScalarID::SERVICEWORKER_REGISTRATIONS,
u"All"_ns, gServiceWorkersRegistered);
Telemetry::ScalarSet(Telemetry::ScalarID::SERVICEWORKER_REGISTRATIONS,
u"Fetch"_ns, gServiceWorkersRegisteredFetch);
LOG(("LoadRegistrations: %u, fetch %u\n", gServiceWorkersRegistered,
gServiceWorkersRegisteredFetch));
}
void ServiceWorkerManager::StoreRegistration(

View File

@@ -44,9 +44,6 @@ class PrincipalInfo;
namespace dom {
extern uint32_t gServiceWorkersRegistered;
extern uint32_t gServiceWorkersRegisteredFetch;
class ContentParent;
class ServiceWorkerInfo;
class ServiceWorkerJobQueue;
@@ -101,8 +98,6 @@ class ServiceWorkerUpdateFinishCallback {
* }
*/
class ServiceWorkerManager final : public nsIServiceWorkerManager,
public nsITimerCallback,
public nsINamed,
public nsIObserver {
friend class GetRegistrationsRunnable;
friend class GetRegistrationRunnable;
@@ -117,8 +112,6 @@ class ServiceWorkerManager final : public nsIServiceWorkerManager,
NS_DECL_ISUPPORTS
NS_DECL_NSISERVICEWORKERMANAGER
NS_DECL_NSIOBSERVER
NS_DECL_NSITIMERCALLBACK
NS_DECL_NSINAMED
// Return true if the given principal and URI matches a registered service
// worker which handles fetch event.
@@ -421,8 +414,6 @@ class ServiceWorkerManager final : public nsIServiceWorkerManager,
};
nsTArray<UniquePtr<PendingReadyData>> mPendingReadyList;
nsCOMPtr<nsITimer> mTelemetryTimer;
};
} // namespace dom

View File

@@ -47,7 +47,6 @@
#include "mozilla/dom/InternalHeaders.h"
#include "mozilla/dom/InternalRequest.h"
#include "mozilla/dom/ReferrerInfo.h"
#include "mozilla/dom/RemoteType.h"
#include "mozilla/dom/RemoteWorkerControllerChild.h"
#include "mozilla/dom/RemoteWorkerManager.h" // RemoteWorkerManager::GetRemoteType
#include "mozilla/dom/ServiceWorkerBinding.h"
@@ -58,35 +57,12 @@
#include "mozilla/net/CookieJarSettings.h"
#include "mozilla/RemoteLazyInputStreamStorage.h"
extern mozilla::LazyLogModule sWorkerTelemetryLog;
#ifdef LOG
# undef LOG
#endif
#define LOG(_args) MOZ_LOG(sWorkerTelemetryLog, LogLevel::Debug, _args);
namespace mozilla {
using namespace ipc;
namespace dom {
uint32_t ServiceWorkerPrivateImpl::sRunningServiceWorkers = 0;
uint32_t ServiceWorkerPrivateImpl::sRunningServiceWorkersFetch = 0;
uint32_t ServiceWorkerPrivateImpl::sRunningServiceWorkersMax = 0;
uint32_t ServiceWorkerPrivateImpl::sRunningServiceWorkersFetchMax = 0;
/*static*/ void ServiceWorkerPrivateImpl::ReportRunning() {
if (sRunningServiceWorkers > 0) {
LOG(("ServiceWorkers running %d (%d Fetch)", sRunningServiceWorkers,
sRunningServiceWorkersFetch));
}
Telemetry::Accumulate(Telemetry::SERVICE_WORKER_RUNNING, "All"_ns,
sRunningServiceWorkers);
Telemetry::Accumulate(Telemetry::SERVICE_WORKER_RUNNING, "Fetch"_ns,
sRunningServiceWorkersFetch);
}
ServiceWorkerPrivateImpl::RAIIActorPtrHolder::RAIIActorPtrHolder(
already_AddRefed<RemoteWorkerControllerChild> aActor)
: mActor(aActor) {
@@ -979,19 +955,6 @@ void ServiceWorkerPrivateImpl::TerminateWorker() {
mOuter->mIdleWorkerTimer->Cancel();
mOuter->mIdleKeepAliveToken = nullptr;
if (!WorkerIsDead()) {
// we end up calling either Terminated *or* TerminateWorker, so decrement in
// both places
MOZ_ASSERT(sRunningServiceWorkers > 0);
sRunningServiceWorkers--;
if (mHandlesFetch) {
MOZ_ASSERT(sRunningServiceWorkersFetch > 0);
sRunningServiceWorkersFetch--;
}
LOG(("(TerminateWorker): ServiceWorkers running now %d/%d",
sRunningServiceWorkers, sRunningServiceWorkersFetch));
}
Shutdown();
}
@@ -1094,15 +1057,8 @@ void ServiceWorkerPrivateImpl::CreationFailed() {
MOZ_ASSERT(mOuter);
MOZ_ASSERT(mControllerChild);
if (mRemoteWorkerData.remoteType().Find(SERVICEWORKER_REMOTE_TYPE) !=
kNotFound) {
Telemetry::AccumulateTimeDelta(
Telemetry::SERVICE_WORKER_ISOLATED_LAUNCH_TIME,
mServiceWorkerLaunchTimeStart);
} else {
Telemetry::AccumulateTimeDelta(Telemetry::SERVICE_WORKER_LAUNCH_TIME_2,
mServiceWorkerLaunchTimeStart);
}
Telemetry::AccumulateTimeDelta(Telemetry::SERVICE_WORKER_LAUNCH_TIME_2,
mServiceWorkerLaunchTimeStart);
Shutdown();
}
@@ -1113,44 +1069,10 @@ void ServiceWorkerPrivateImpl::CreationSucceeded() {
MOZ_ASSERT(mOuter);
MOZ_ASSERT(mControllerChild);
if (mRemoteWorkerData.remoteType().Find(SERVICEWORKER_REMOTE_TYPE) !=
kNotFound) {
Telemetry::AccumulateTimeDelta(
Telemetry::SERVICE_WORKER_ISOLATED_LAUNCH_TIME,
mServiceWorkerLaunchTimeStart);
} else {
Telemetry::AccumulateTimeDelta(Telemetry::SERVICE_WORKER_LAUNCH_TIME_2,
mServiceWorkerLaunchTimeStart);
}
Telemetry::AccumulateTimeDelta(Telemetry::SERVICE_WORKER_LAUNCH_TIME_2,
mServiceWorkerLaunchTimeStart);
mOuter->RenewKeepAliveToken(ServiceWorkerPrivate::WakeUpReason::Unknown);
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
nsCOMPtr<nsIPrincipal> principal = mOuter->mInfo->Principal();
RefPtr<ServiceWorkerRegistrationInfo> regInfo =
swm->GetRegistration(principal, mOuter->mInfo->Scope());
if (regInfo) {
mHandlesFetch = regInfo->GetActive()->HandlesFetch();
}
sRunningServiceWorkers++;
if (sRunningServiceWorkers > sRunningServiceWorkersMax) {
sRunningServiceWorkersMax = sRunningServiceWorkers;
LOG(("ServiceWorker max now %d", sRunningServiceWorkersMax));
Telemetry::ScalarSet(Telemetry::ScalarID::SERVICEWORKER_RUNNING_MAX,
u"All"_ns, sRunningServiceWorkersMax);
}
if (mHandlesFetch) {
sRunningServiceWorkersFetch++;
if (sRunningServiceWorkersFetch > sRunningServiceWorkersFetchMax) {
sRunningServiceWorkersFetchMax = sRunningServiceWorkersFetch;
LOG(("ServiceWorker Fetch max now %d", sRunningServiceWorkersFetchMax));
Telemetry::ScalarSet(Telemetry::ScalarID::SERVICEWORKER_RUNNING_MAX,
u"Fetch"_ns, sRunningServiceWorkersFetchMax);
}
}
LOG(("ServiceWorkers running now %d/%d", sRunningServiceWorkers,
sRunningServiceWorkersFetch));
}
void ServiceWorkerPrivateImpl::ErrorReceived(const ErrorValue& aError) {
@@ -1174,17 +1096,6 @@ void ServiceWorkerPrivateImpl::Terminated() {
MOZ_ASSERT(mOuter);
MOZ_ASSERT(mControllerChild);
// we end up calling either Terminated *or* TerminateWorker, so decrement in
// both places
MOZ_ASSERT(sRunningServiceWorkers > 0);
sRunningServiceWorkers--;
if (mHandlesFetch) {
MOZ_ASSERT(sRunningServiceWorkersFetch > 0);
sRunningServiceWorkersFetch--;
}
LOG(("ServiceWorkers running now %d/%d", sRunningServiceWorkers,
sRunningServiceWorkersFetch));
Shutdown();
}

View File

@@ -50,8 +50,6 @@ class ServiceWorkerPrivateImpl final : public ServiceWorkerPrivate::Inner,
RefPtr<GenericPromise> SetSkipWaitingFlag();
static void ReportRunning();
private:
class RAIIActorPtrHolder;
@@ -245,15 +243,6 @@ class ServiceWorkerPrivateImpl final : public ServiceWorkerPrivate::Inner,
RemoteWorkerData mRemoteWorkerData;
TimeStamp mServiceWorkerLaunchTimeStart;
// Counters for Telemetry - totals running simultaneously, and those that
// handle Fetch, plus Max values for each
static uint32_t sRunningServiceWorkers;
static uint32_t sRunningServiceWorkersFetch;
static uint32_t sRunningServiceWorkersMax;
static uint32_t sRunningServiceWorkersFetchMax;
bool mHandlesFetch{false};
};
} // namespace dom

View File

@@ -5,7 +5,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "ServiceWorkerRegistrar.h"
#include "ServiceWorkerManager.h"
#include "mozilla/dom/ServiceWorkerRegistrarTypes.h"
#include "mozilla/dom/DOMException.h"
#include "mozilla/net/MozURL.h"
@@ -46,13 +45,6 @@
using namespace mozilla::ipc;
extern mozilla::LazyLogModule sWorkerTelemetryLog;
#ifdef LOG
# undef LOG
#endif
#define LOG(_args) MOZ_LOG(sWorkerTelemetryLog, LogLevel::Debug, _args);
namespace mozilla {
namespace dom {
@@ -289,18 +281,6 @@ void ServiceWorkerRegistrar::UnregisterServiceWorker(
for (uint32_t i = 0; i < mData.Length(); ++i) {
if (Equivalent(tmp, mData[i])) {
gServiceWorkersRegistered--;
if (mData[i].currentWorkerHandlesFetch()) {
gServiceWorkersRegisteredFetch--;
}
// Update Telemetry
Telemetry::ScalarSet(Telemetry::ScalarID::SERVICEWORKER_REGISTRATIONS,
u"All"_ns, gServiceWorkersRegistered);
Telemetry::ScalarSet(Telemetry::ScalarID::SERVICEWORKER_REGISTRATIONS,
u"Fetch"_ns, gServiceWorkersRegisteredFetch);
LOG(("Unregister ServiceWorker: %u, fetch %u\n",
gServiceWorkersRegistered, gServiceWorkersRegisteredFetch));
mData.RemoveElementAt(i);
mDataGeneration = GetNextGeneration();
deleted = true;
@@ -920,14 +900,8 @@ void ServiceWorkerRegistrar::RegisterServiceWorkerInternal(
bool found = false;
for (uint32_t i = 0, len = mData.Length(); i < len; ++i) {
if (Equivalent(aData, mData[i])) {
found = true;
if (mData[i].currentWorkerHandlesFetch()) {
// Decrement here if we found it, in case the new registration no
// longer handles Fetch. If it continues to handle fetch, we'll
// bump it back later.
gServiceWorkersRegisteredFetch--;
}
mData[i] = aData;
found = true;
break;
}
}
@@ -935,20 +909,7 @@ void ServiceWorkerRegistrar::RegisterServiceWorkerInternal(
if (!found) {
MOZ_ASSERT(ServiceWorkerRegistrationDataIsValid(aData));
mData.AppendElement(aData);
// We didn't find an entry to update, so we have 1 more
gServiceWorkersRegistered++;
}
// Handles bumping both for new registrations and updates
if (aData.currentWorkerHandlesFetch()) {
gServiceWorkersRegisteredFetch++;
}
// Update Telemetry
Telemetry::ScalarSet(Telemetry::ScalarID::SERVICEWORKER_REGISTRATIONS,
u"All"_ns, gServiceWorkersRegistered);
Telemetry::ScalarSet(Telemetry::ScalarID::SERVICEWORKER_REGISTRATIONS,
u"Fetch"_ns, gServiceWorkersRegisteredFetch);
LOG(("Register: %u, fetch %u\n", gServiceWorkersRegistered,
gServiceWorkersRegisteredFetch));
mDataGeneration = GetNextGeneration();
}

View File

@@ -33,9 +33,6 @@
mozilla::LazyLogModule gRemoteWorkerManagerLog("RemoteWorkerManager");
#ifdef LOG
# undef LOG
#endif
#define LOG(fmt) \
MOZ_LOG(gRemoteWorkerManagerLog, mozilla::LogLevel::Verbose, fmt)

View File

@@ -13211,18 +13211,6 @@
"alert_emails": ["sw-telemetry@mozilla.com", "echuang@mozilla.com"],
"description": "Time (ms) for spawning a service worker in the remote content process."
},
"SERVICE_WORKER_ISOLATED_LAUNCH_TIME": {
"record_in_processes": ["main", "content"],
"products": ["firefox", "fennec"],
"expires_in_version": "never",
"bug_numbers": [1740335],
"kind": "exponential",
"high": 30000,
"n_buckets": 25,
"releaseChannelCollection": "opt-out",
"alert_emails": ["sw-telemetry@mozilla.com", "rjesup@mozilla.com", "echuang@mozilla.com"],
"description": "Time (ms) for spawning a service worker in an isolated content process."
},
"SERVICE_WORKER_REGISTRATION_LOADING": {
"record_in_processes": ["main", "content"],
"products": ["firefox", "fennec"],
@@ -13922,6 +13910,13 @@
"alert_emails": ["tdsmith@mozilla.com", "compatibility@lists.mozilla.org"],
"description": "Number of dedicated workers destroyed; used in conjunction with use counter histograms"
},
"SERVICE_WORKER_REGISTRATIONS": {
"record_in_processes": ["main", "content"],
"products": ["firefox", "fennec"],
"expires_in_version": "50",
"kind": "count",
"description": "Count how many registrations occurs. File bugs in Core::DOM in case of a Telemetry regression."
},
"SERVICE_WORKER_CONTROLLED_DOCUMENTS": {
"record_in_processes": ["main", "content"],
"products": ["firefox", "fennec"],
@@ -13939,37 +13934,12 @@
"SERVICE_WORKER_LIFE_TIME": {
"record_in_processes": ["main", "content"],
"products": ["firefox", "fennec"],
"expires_in_version": "102",
"expires_in_version": "50",
"kind": "exponential",
"high": 120000,
"n_buckets": 20,
"alert_emails": ["sw-telemetry@mozilla.com", "rjesup@mozilla.com", "echuang@mozilla.com"],
"description": "Tracking how long a ServiceWorker stays alive after it is spawned. File bugs in Core::DOM in case of a Telemetry regression."
},
"SERVICE_WORKER_RUNNING": {
"record_in_processes": ["main"],
"products": ["firefox", "fennec"],
"expires_in_version": "102",
"kind": "linear",
"high": 31,
"n_buckets": 30,
"keyed": true,
"keys": ["All", "Fetch"],
"bug_numbers": [1740335],
"alert_emails": ["sw-telemetry@mozilla.com", "rjesup@mozilla.com", "echuang@mozilla.com"],
"description": "The sampled number of simultaneous running ServiceWorkers in a session, sampled once each minute"
},
"SERVICE_WORKER_FETCH_RUNNING": {
"record_in_processes": ["main"],
"products": ["firefox", "fennec"],
"expires_in_version": "102",
"kind": "linear",
"high": 31,
"n_buckets": 30,
"bug_numbers": [1740335],
"alert_emails": ["sw-telemetry@mozilla.com", "rjesup@mozilla.com", "echuang@mozilla.com"],
"description": "The sampled number of simultaneous running ServiceWorkers handling Fetch in a session, sampled every minute"
},
"GRAPHICS_SANITY_TEST": {
"record_in_processes": ["main", "content"],
"products": ["firefox", "fennec"],

View File

@@ -4674,51 +4674,6 @@ sw:
- 'main'
- 'content'
serviceworker:
registrations:
description: >
Count how many registrations occur. File bugs in Core::DOM in case of a Telemetry regression.
record_in_processes:
- 'main'
products:
- 'firefox'
- 'fennec'
expires: "102"
kind: uint
bug_numbers:
- 1740335
notification_emails:
- sw-telemetry@mozilla.com
- rjesup@mozilla.com
- echuang@mozilla.com
keyed: true
keys:
- All
- Fetch
running_max:
description: >
The maximum number of simultaneous running ServiceWorkers in a session.
record_in_processes:
- 'main'
products:
- 'firefox'
- 'fennec'
expires: "102"
kind: uint
bug_numbers:
- 1740335
notification_emails:
- sw-telemetry@mozilla.com
- rjesup@mozilla.com
- echuang@mozilla.com
keyed: true
keys:
- All
- Fetch
widget:
ime_name_on_windows:
bug_numbers:
@@ -7942,7 +7897,7 @@ content:
The maximum number of content processes, submitted when a
new maximum is reached. Replaces CONTENT_PROCESS_MAX and
CONTENT_PROCESS_PRECISE_MAX.
notification_emails:
- kmadan@mozilla.com
- perf-telemetry-alerts@mozilla.com

View File

@@ -303,6 +303,8 @@
"REQUESTS_OF_ORIGINAL_CONTENT",
"SAFE_MODE_USAGE",
"SERVICE_WORKER_CONTROLLED_DOCUMENTS",
"SERVICE_WORKER_LIFE_TIME",
"SERVICE_WORKER_REGISTRATIONS",
"SERVICE_WORKER_REGISTRATION_LOADING",
"SERVICE_WORKER_SPAWN_ATTEMPTS",
"SERVICE_WORKER_UPDATED",
@@ -767,6 +769,7 @@
"SEARCH_SERVICE_US_TIMEZONE_MISMATCHED_COUNTRY",
"SERVICE_WORKER_CONTROLLED_DOCUMENTS",
"SERVICE_WORKER_LIFE_TIME",
"SERVICE_WORKER_REGISTRATIONS",
"SERVICE_WORKER_REGISTRATION_LOADING",
"SERVICE_WORKER_SPAWN_ATTEMPTS",
"SERVICE_WORKER_UPDATED",
@@ -1161,6 +1164,7 @@
"SEARCH_SERVICE_US_COUNTRY_MISMATCHED_TIMEZONE",
"SEARCH_SERVICE_US_TIMEZONE_MISMATCHED_COUNTRY",
"SERVICE_WORKER_CONTROLLED_DOCUMENTS",
"SERVICE_WORKER_REGISTRATIONS",
"SERVICE_WORKER_SPAWN_ATTEMPTS",
"SERVICE_WORKER_SPAWN_GETS_QUEUED",
"SERVICE_WORKER_UPDATED",