Skip to content

Commit 1e19379

Browse files
committed
Bug 1689953: Harmonize shutdown phase definitions across nsTerminator and AppShutdown r=dthayer,chutten
This patch wants to solve several quirks around the shutdown terminator. - Use the same shutdown phase definitions in AppShutdown and nsTerminator. This touches quite a few files. - Ensure that the terminator phase shift is handled before any shutdown observer notifications are sent and reduce its heartbeat duration. - Add missing phases to the shutdown telemetry. Please note that this changes the unit of "tick" to 100ms rather than 1s. As a side effect, we also remove the obsolete "shutdown-persist" context. While the existing test coverage continues to prove the most important functions, we acknowledge the wish for better test coverage with [[ https://bugzilla.mozilla.org/show_bug.cgi?id=1693966 | bug 1693966 ]]. Differential Revision: https://phabricator.services.mozilla.com/D103626
1 parent 67edd19 commit 1e19379

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+372
-235
lines changed

accessible/ipc/win/DocAccessibleChild.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ DocAccessibleChild::DocAccessibleChild(DocAccessible* aDoc, IProtocol* aManager)
2222
MOZ_COUNT_CTOR_INHERITED(DocAccessibleChild, DocAccessibleChildBase);
2323
if (!sPlatformChild) {
2424
sPlatformChild = new PlatformChild();
25-
ClearOnShutdown(&sPlatformChild, ShutdownPhase::Shutdown);
25+
ClearOnShutdown(&sPlatformChild, ShutdownPhase::XPCOMShutdown);
2626
}
2727

2828
SetManager(aManager);

browser/components/enterprisepolicies/tests/browser/browser_policy_cookie_settings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ async function fake_profile_change() {
2828
}, "cookie-db-closed");
2929
Services.cookies
3030
.QueryInterface(Ci.nsIObserver)
31-
.observe(null, "profile-before-change", "shutdown-persist");
31+
.observe(null, "profile-before-change", null);
3232
});
3333
await new Promise(resolve => {
3434
Services.obs.addObserver(function waitForDBOpen() {

dom/ipc/ContentChild.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ ContentChild::ContentChild()
575575
// happens without requiring the observer service at this time.
576576
if (!sShutdownCanary) {
577577
sShutdownCanary = new ShutdownCanary();
578-
ClearOnShutdown(&sShutdownCanary, ShutdownPhase::Shutdown);
578+
ClearOnShutdown(&sShutdownCanary, ShutdownPhase::XPCOMShutdown);
579579
}
580580
}
581581

dom/ipc/ContentParent.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2839,7 +2839,7 @@ bool ContentParent::InitInternal(ProcessPriority aInitialPriority) {
28392839
// can't init the process without it, and since we're going to be canceling
28402840
// whatever load attempt that initiated this process creation anyway, just
28412841
// bail out now if shutdown has already started.
2842-
if (PastShutdownPhase(ShutdownPhase::Shutdown)) {
2842+
if (PastShutdownPhase(ShutdownPhase::XPCOMShutdown)) {
28432843
return false;
28442844
}
28452845

dom/media/MediaCache.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ RefPtr<MediaCache> MediaCache::GetMediaCache(int64_t aContentLength,
773773
thread->Shutdown();
774774
}
775775
} sClearThread;
776-
ClearOnShutdown(&sClearThread, ShutdownPhase::ShutdownThreads);
776+
ClearOnShutdown(&sClearThread, ShutdownPhase::XPCOMShutdownThreads);
777777
}
778778

779779
if (!sThread) {

dom/media/doctor/DecoderDoctorLogger.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,11 @@ bool DecoderDoctorLogger::EnsureLogIsEnabled() {
116116
TaskCategory::Other,
117117
NS_NewRunnableFunction("DDLogger shutdown setup", [] {
118118
sDDLogShutdowner = MakeUnique<DDLogShutdowner>();
119-
ClearOnShutdown(&sDDLogShutdowner, ShutdownPhase::Shutdown);
119+
ClearOnShutdown(&sDDLogShutdowner,
120+
ShutdownPhase::XPCOMShutdown);
120121
sDDLogDeleter = MakeUnique<DDLogDeleter>();
121-
ClearOnShutdown(&sDDLogDeleter, ShutdownPhase::ShutdownThreads);
122+
ClearOnShutdown(&sDDLogDeleter,
123+
ShutdownPhase::XPCOMShutdownThreads);
122124
})));
123125

124126
// Nobody else should change the state when *we* are enabling logging.

dom/media/mediacapabilities/MediaCapabilities.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ already_AddRefed<Promise> MediaCapabilities::DecodingInfo(
257257
NS_NewRunnableFunction(
258258
"MediaCapabilities::AllocPolicy:Video", []() {
259259
ClearOnShutdown(&sVideoAllocPolicy,
260-
ShutdownPhase::ShutdownThreads);
260+
ShutdownPhase::XPCOMShutdownThreads);
261261
}));
262262
return new SingleAllocPolicy(TrackInfo::TrackType::kVideoTrack,
263263
taskQueue);

dom/media/platforms/AllocationPolicy.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ NotNull<AllocPolicy*> GlobalAllocPolicy::Instance(TrackType aTrack) {
9797
TaskCategory::Other,
9898
NS_NewRunnableFunction(
9999
"GlobalAllocPolicy::GlobalAllocPolicy:Audio", []() {
100-
ClearOnShutdown(&sAudioPolicy, ShutdownPhase::ShutdownThreads);
100+
ClearOnShutdown(&sAudioPolicy,
101+
ShutdownPhase::XPCOMShutdownThreads);
101102
}));
102103
return new AllocPolicyImpl(MediaDecoderLimitDefault());
103104
}();
@@ -108,7 +109,8 @@ NotNull<AllocPolicy*> GlobalAllocPolicy::Instance(TrackType aTrack) {
108109
TaskCategory::Other,
109110
NS_NewRunnableFunction(
110111
"GlobalAllocPolicy::GlobalAllocPolicy:Audio", []() {
111-
ClearOnShutdown(&sVideoPolicy, ShutdownPhase::ShutdownThreads);
112+
ClearOnShutdown(&sVideoPolicy,
113+
ShutdownPhase::XPCOMShutdownThreads);
112114
}));
113115
return new AllocPolicyImpl(MediaDecoderLimitDefault());
114116
}();

dom/media/webrtc/CubebDeviceEnumerator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ CubebDeviceEnumerator* CubebDeviceEnumerator::GetInstance() {
3030
sInstance = new CubebDeviceEnumerator();
3131
static bool clearOnShutdownSetup = []() -> bool {
3232
auto setClearOnShutdown = []() -> void {
33-
ClearOnShutdown(&sInstance, ShutdownPhase::ShutdownThreads);
33+
ClearOnShutdown(&sInstance, ShutdownPhase::XPCOMShutdownThreads);
3434
};
3535
if (NS_IsMainThread()) {
3636
setClearOnShutdown();

dom/media/webrtc/transport/nr_socket_prsock.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ class SingletonThreadHolder final {
241241
static StaticRefPtr<SingletonThreadHolder> sThread;
242242

243243
static void ClearSingletonOnShutdown() {
244-
ClearOnShutdown(&sThread, ShutdownPhase::ShutdownLoaders);
244+
ClearOnShutdown(&sThread, ShutdownPhase::XPCOMShutdownLoaders);
245245
}
246246
#endif
247247

0 commit comments

Comments
 (0)