From 34d12babb2c07f81db89b36f21be27c5a7c492b9 Mon Sep 17 00:00:00 2001 From: Narcis Beleuzu Date: Sat, 23 May 2020 23:45:59 +0300 Subject: [PATCH] Backed out 5 changesets (bug 1602757, bug 1612063) for marionette failures on test_crash.py Backed out changeset 232da017dc6a (bug 1602757) Backed out changeset 32851bed1929 (bug 1602757) Backed out changeset 1c6a6bfaaeef (bug 1602757) Backed out changeset 45e22f062bce (bug 1612063) Backed out changeset a7d7edf158a4 (bug 1602757) --- dom/base/ChromeUtils.cpp | 4 - dom/chrome-webidl/ChromeUtils.webidl | 1 - dom/ipc/ContentChild.cpp | 33 +-- dom/ipc/ContentParent.cpp | 268 ++---------------- dom/ipc/ContentParent.h | 16 +- dom/ipc/PreallocatedProcessManager.cpp | 233 ++++----------- dom/ipc/PreallocatedProcessManager.h | 29 +- dom/ipc/ProcessPriorityManager.cpp | 3 - .../browser_resource_uri.js | 8 - dom/media/tests/mochitest/mochitest.ini | 2 +- modules/libpref/init/StaticPrefList.yaml | 9 +- .../tests/browser/browser_DynamicScalars.js | 16 +- .../en-US/toolkit/global/processTypes.ftl | 3 - widget/ProcInfo.h | 4 +- 14 files changed, 114 insertions(+), 515 deletions(-) diff --git a/dom/base/ChromeUtils.cpp b/dom/base/ChromeUtils.cpp index 426cdeba6856..879c12aa6cf6 100644 --- a/dom/base/ChromeUtils.cpp +++ b/dom/base/ChromeUtils.cpp @@ -760,7 +760,6 @@ static WebIDLProcType ProcTypeToWebIDL(mozilla::ProcType aType) { #ifdef MOZ_ENABLE_FORKSERVER PROCTYPE_TO_WEBIDL_CASE(ForkServer, ForkServer); #endif - PROCTYPE_TO_WEBIDL_CASE(Preallocated, Preallocated); PROCTYPE_TO_WEBIDL_CASE(Unknown, Unknown); } @@ -862,9 +861,6 @@ already_AddRefed ChromeUtils::RequestProcInfo(GlobalObject& aGlobal, } else if (remoteType.EqualsLiteral( LARGE_ALLOCATION_REMOTE_TYPE)) { type = mozilla::ProcType::WebLargeAllocation; - } else if (remoteType.EqualsLiteral( - PREALLOC_REMOTE_TYPE)) { - type = mozilla::ProcType::Preallocated; } else { MOZ_CRASH("Unknown remoteType"); } diff --git a/dom/chrome-webidl/ChromeUtils.webidl b/dom/chrome-webidl/ChromeUtils.webidl index f6023a80aa05..bb327e919eff 100644 --- a/dom/chrome-webidl/ChromeUtils.webidl +++ b/dom/chrome-webidl/ChromeUtils.webidl @@ -517,7 +517,6 @@ enum WebIDLProcType { #ifdef MOZ_ENABLE_FORKSERVER "forkServer", #endif - "preallocated", "unknown", }; diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index b22d5ec8ff27..7f3314a63f56 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -29,7 +29,6 @@ #include "mozilla/Unused.h" #include "mozilla/SchedulerGroup.h" #include "mozilla/StaticPrefs_dom.h" -#include "mozilla/StaticPrefs_fission.h" #include "mozilla/StaticPrefs_media.h" #include "mozilla/TelemetryIPC.h" #include "mozilla/RemoteDecoderManagerChild.h" @@ -2567,27 +2566,12 @@ mozilla::ipc::IPCResult ContentChild::RecvAppInfo( mozilla::ipc::IPCResult ContentChild::RecvRemoteType( const nsString& aRemoteType) { - if (!DOMStringIsNull(mRemoteType)) { - // Preallocated processes are type PREALLOC_REMOTE_TYPE; they can become - // anything except a File: process. - MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, - ("Changing remoteType of process %d from %s to %s", getpid(), - NS_ConvertUTF16toUTF8(mRemoteType).get(), - NS_ConvertUTF16toUTF8(aRemoteType).get())); - // prealloc->anything (but file) or web->web allowed - MOZ_RELEASE_ASSERT(!aRemoteType.EqualsLiteral(FILE_REMOTE_TYPE) && - (mRemoteType.EqualsLiteral(PREALLOC_REMOTE_TYPE) || - (mRemoteType.EqualsLiteral(DEFAULT_REMOTE_TYPE) && - aRemoteType.EqualsLiteral(DEFAULT_REMOTE_TYPE)))); - } else { - // Initial setting of remote type. Either to 'prealloc' or the actual - // final type (if we didn't use a preallocated process) - MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, - ("Setting remoteType of process %d to %s", getpid(), - NS_ConvertUTF16toUTF8(aRemoteType).get())); - } + MOZ_ASSERT(DOMStringIsNull(mRemoteType)); - // Update the process name so about:memory's process names are more obvious. + mRemoteType.Assign(aRemoteType); + + // For non-default ("web") types, update the process name so about:memory's + // process names are more obvious. if (aRemoteType.EqualsLiteral(FILE_REMOTE_TYPE)) { SetProcessName(NS_LITERAL_STRING("file:// Content")); } else if (aRemoteType.EqualsLiteral(EXTENSION_REMOTE_TYPE)) { @@ -2596,13 +2580,7 @@ mozilla::ipc::IPCResult ContentChild::RecvRemoteType( SetProcessName(NS_LITERAL_STRING("Privileged Content")); } else if (aRemoteType.EqualsLiteral(LARGE_ALLOCATION_REMOTE_TYPE)) { SetProcessName(NS_LITERAL_STRING("Large Allocation Web Content")); - } else if (RemoteTypePrefix(aRemoteType) - .EqualsLiteral(FISSION_WEB_REMOTE_TYPE)) { - SetProcessName(NS_LITERAL_STRING("Isolated Web Content")); } - // else "prealloc", "web" or "webCOOP+COEP" type -> "Web Content" already set - - mRemoteType.Assign(aRemoteType); return IPC_OK(); } @@ -3531,6 +3509,7 @@ mozilla::ipc::IPCResult ContentChild::RecvSessionStorageData( return IPC_OK(); } + mozilla::ipc::IPCResult ContentChild::RecvOnAllowAccessFor( const MaybeDiscarded& aContext, const nsCString& aTrackingOrigin, uint32_t aCookieBehavior, diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index aed8b844f1bf..61581d1921b8 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -20,9 +20,6 @@ # include "mozilla/a11y/PDocAccessible.h" #endif #include "GeckoProfiler.h" -#ifdef MOZ_GECKO_PROFILER -# include "ProfilerMarkerPayload.h" -#endif #include "GMPServiceParent.h" #include "HandlerServiceParent.h" #include "IHistory.h" @@ -354,11 +351,6 @@ extern FileDescriptor CreateAudioIPCConnection(); namespace dom { -LazyLogModule gProcessLog("Process"); - -/* static */ -LogModule* ContentParent::GetLog() { return gProcessLog; } - #define NS_IPC_IOSERVICE_SET_OFFLINE_TOPIC "ipc:network:set-offline" #define NS_IPC_IOSERVICE_SET_CONNECTIVITY_TOPIC "ipc:network:set-connectivity" @@ -485,10 +477,6 @@ ContentParentsMemoryReporter::CollectReports( return NS_OK; } -// A hashtable (by type) of processes/ContentParents. This includes -// processes that are in the Preallocator cache (which would be type -// 'prealloc'), and recycled processes ('web' and in the future -// eTLD+1-locked) processes). nsClassHashtable>* ContentParent::sBrowserContentParents; @@ -646,10 +634,8 @@ static const char* sObserverTopics[] = { /*static*/ RefPtr ContentParent::PreallocateProcess() { RefPtr process = new ContentParent( - /* aOpener = */ nullptr, NS_LITERAL_STRING(PREALLOC_REMOTE_TYPE)); + /* aOpener = */ nullptr, NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE)); - MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, - ("Preallocating process of type " PREALLOC_REMOTE_TYPE)); return process->LaunchSubprocessAsync(PROCESS_PRIORITY_PREALLOC); } @@ -728,8 +714,6 @@ const nsDependentSubstring RemoteTypePrefix( } bool IsWebRemoteType(const nsAString& aContentProcessType) { - // Note: matches webIsolated as well as web (and webLargeAllocation, and - // webCOOP+COEP) return StringBeginsWith(aContentProcessType, NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE)); } @@ -747,7 +731,7 @@ uint32_t ContentParent::GetMaxProcessCount( RemoteTypePrefix(aContentProcessType); // Check for the default remote type of "web", as it uses different prefs. - if (processTypePrefix.EqualsLiteral(DEFAULT_REMOTE_TYPE)) { + if (processTypePrefix.EqualsLiteral("web")) { return GetMaxWebProcessCount(); } @@ -772,57 +756,27 @@ bool ContentParent::IsMaxProcessCountReached( GetMaxProcessCount(aContentProcessType); } -// Really more ReleaseUnneededProcesses() /*static*/ void ContentParent::ReleaseCachedProcesses() { - MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, - ("ReleaseCachedProcesses:")); - if (!sBrowserContentParents) { + if (!GetPoolSize(NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE))) { return; } -#ifdef DEBUG - int num = 0; - for (auto iter = sBrowserContentParents->Iter(); !iter.Done(); iter.Next()) { - nsTArray* contentParents = iter.Data().get(); - num += contentParents->Length(); - for (auto* cp : *contentParents) { - MOZ_LOG( - ContentParent::GetLog(), LogLevel::Debug, - ("%s: %zu processes", NS_ConvertUTF16toUTF8(cp->mRemoteType).get(), - contentParents->Length())); - break; - } - } -#endif - // We process the toRelease array outside of the iteration to avoid modifying - // the list (via RemoveFromList()) while we're iterating it. + // We might want to extend this for other process types as well in the + // future... + nsTArray& contentParents = + GetOrCreatePool(NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE)); nsTArray toRelease; - for (auto iter = sBrowserContentParents->Iter(); !iter.Done(); iter.Next()) { - nsTArray* contentParents = iter.Data().get(); - // Shutting down these processes will change the array so let's use another - // array for the removal. - for (auto* cp : *contentParents) { - if (cp->ManagedPBrowserParent().Count() == 0 && - !cp->HasActiveWorkerOrJSPlugin() && - cp->mRemoteType.EqualsLiteral(DEFAULT_REMOTE_TYPE)) { - toRelease.AppendElement(cp); - } else { - MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, - (" Skipping %p (%s), count %d, HasActiveWorkerOrJSPlugin %d", - cp, NS_ConvertUTF16toUTF8(cp->mRemoteType).get(), - cp->ManagedPBrowserParent().Count(), - cp->HasActiveWorkerOrJSPlugin())); - } + // Shuting down these processes will change the array so let's use another + // array for the removal. + for (auto* cp : contentParents) { + if (cp->ManagedPBrowserParent().Count() == 0) { + toRelease.AppendElement(cp); } } for (auto* cp : toRelease) { - MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, - (" Shutdown %p (%s)", cp, - NS_ConvertUTF16toUTF8(cp->mRemoteType).get())); - PreallocatedProcessManager::Erase(cp); // Start a soft shutdown. cp->ShutDownProcess(SEND_SHUTDOWN_MESSAGE); // Make sure we don't select this process for new tabs. @@ -887,19 +841,6 @@ already_AddRefed ContentParent::GetUsedBrowserProcess( // If the provider returned an existing ContentParent, use that one. if (0 <= index && static_cast(index) <= aMaxContentParents) { RefPtr retval = aContentParents[index]; -#ifdef MOZ_GECKO_PROFILER - if (profiler_thread_is_being_profiled()) { - nsPrintfCString marker("Reused process %u", - (unsigned int)retval->ChildID()); - TimeStamp now = TimeStamp::Now(); - PROFILER_ADD_MARKER_WITH_PAYLOAD("Process", DOM, TextMarkerPayload, - (marker, now, now)); - } -#endif - MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, - ("GetUsedProcess: Reused process %p (%u) for %s", retval.get(), - (unsigned int)retval->ChildID(), - NS_ConvertUTF16toUTF8(aRemoteType).get())); return retval.forget(); } } else { @@ -909,55 +850,21 @@ already_AddRefed ContentParent::GetUsedBrowserProcess( RefPtr random; if (aContentParents.Length() >= aMaxContentParents && (random = MinTabSelect(aContentParents, aOpener, aMaxContentParents))) { - MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, - ("GetUsedProcess: Reused random process %p (%d) for %s", - random.get(), (unsigned int)random->ChildID(), - NS_ConvertUTF16toUTF8(aRemoteType).get())); return random.forget(); } } - // Try to take the preallocated process except for blacklisted types. + // Try to take the preallocated process only for the default process type. // The preallocated process manager might not had the chance yet to release // the process after a very recent ShutDownProcess, let's make sure we don't // try to reuse a process that is being shut down. RefPtr p; - bool preallocated = false; - if (!aRemoteType.EqualsLiteral(FILE_REMOTE_TYPE) && - !aRemoteType.EqualsLiteral(EXTENSION_REMOTE_TYPE) && // Bug 1638119 - (p = PreallocatedProcessManager::Take(aRemoteType)) && - !p->mShutdownPending) { - // p may be a preallocated process, or (if not PREALLOC_REMOTE_TYPE) - // a perviously-used process that's being recycled. Currently this is - // only done for short-duration web (DEFAULT_REMOTE_TYPE) processes - preallocated = p->mRemoteType.EqualsLiteral(PREALLOC_REMOTE_TYPE); + if (aRemoteType.EqualsLiteral(DEFAULT_REMOTE_TYPE) && + (p = PreallocatedProcessManager::Take()) && !p->mShutdownPending) { // For pre-allocated process we have not set the opener yet. -#ifdef MOZ_GECKO_PROFILER - if (profiler_thread_is_being_profiled()) { - nsPrintfCString marker("Assigned %s process %u", - preallocated ? "preallocated" : "reused web", - (unsigned int)p->ChildID()); - TimeStamp now = TimeStamp::Now(); - PROFILER_ADD_MARKER_WITH_PAYLOAD("Process", DOM, TextMarkerPayload, - (marker, now, now)); - } -#endif - MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, - ("Adopted %s process %p for type %s", - preallocated ? "preallocated" : "reused web", p.get(), - NS_ConvertUTF16toUTF8(aRemoteType).get())); p->mOpener = aOpener; - p->mActivateTS = TimeStamp::Now(); aContentParents.AppendElement(p); - if (preallocated) { - p->mRemoteType.Assign(aRemoteType); - // Specialize this process for the appropriate eTLD+1 - Unused << p->SendRemoteType(p->mRemoteType); - } else { - // we only allow "web" to "web" for security reasons - MOZ_RELEASE_ASSERT(p->mRemoteType.EqualsLiteral(DEFAULT_REMOTE_TYPE) && - aRemoteType.EqualsLiteral(DEFAULT_REMOTE_TYPE)); - } + p->mActivateTS = TimeStamp::Now(); return p.forget(); } @@ -972,17 +879,12 @@ ContentParent::GetNewOrUsedBrowserProcessInternal(Element* aFrameElement, ContentParent* aOpener, bool aPreferUsed, bool aIsSync) { - MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, - ("GetNewOrUsedProcess for type %s", - NS_ConvertUTF16toUTF8(aRemoteType).get())); nsTArray& contentParents = GetOrCreatePool(aRemoteType); uint32_t maxContentParents = GetMaxProcessCount(aRemoteType); if (aRemoteType.EqualsLiteral( LARGE_ALLOCATION_REMOTE_TYPE) // We never want to re-use // Large-Allocation processes. && contentParents.Length() >= maxContentParents) { - MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, - ("GetNewOrUsedProcess: returning Large Used process")); return GetNewOrUsedBrowserProcessInternal( aFrameElement, NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE), aPriority, aOpener, /*aPreferUsed =*/false, aIsSync); @@ -995,18 +897,11 @@ ContentParent::GetNewOrUsedBrowserProcessInternal(Element* aFrameElement, if (contentParent) { // We have located a process. It may not have finished initializing, // this will be for the caller to handle. - MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, - ("GetNewOrUsedProcess: Used process %p (launching %d)", - contentParent.get(), contentParent->IsLaunching())); return contentParent.forget(); } // No reusable process. Let's create and launch one. // The life cycle will be set to `LifecycleState::LAUNCHING`. - MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, - ("Launching new process immediately for type %s", - NS_ConvertUTF16toUTF8(aRemoteType).get())); - contentParent = new ContentParent(aOpener, aRemoteType); if (!contentParent->BeginSubprocessLaunch(aIsSync, aPriority)) { // Launch aborted because of shutdown. Bailout. @@ -1019,12 +914,9 @@ ContentParent::GetNewOrUsedBrowserProcessInternal(Element* aFrameElement, // Until the new process is ready let's not allow to start up any // preallocated processes. The blocker will be removed once we receive // the first idle message. - contentParent->mIsAPreallocBlocker = true; - PreallocatedProcessManager::AddBlocker(aRemoteType, contentParent); + PreallocatedProcessManager::AddBlocker(contentParent); MOZ_ASSERT(contentParent->IsLaunching()); - MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, - ("GetNewOrUsedProcess: new process %p", contentParent.get())); return contentParent.forget(); } @@ -1522,8 +1414,6 @@ void ContentParent::Init() { } void ContentParent::MaybeAsyncSendShutDownMessage() { - MOZ_LOG(ContentParent::GetLog(), LogLevel::Verbose, - ("MaybeAsyncSendShutDownMessage %p", this)); MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(!TryToRecycle()); @@ -1666,8 +1556,6 @@ void ContentParent::RemoveFromList() { } void ContentParent::MarkAsDead() { - MOZ_LOG(ContentParent::GetLog(), LogLevel::Verbose, - ("Marking ContentProcess %p as dead", this)); if (!mShutdownPending) { RemoveFromList(); } @@ -1831,21 +1719,10 @@ void ContentParent::ActorDestroy(ActorDestroyReason why) { } mIdleListeners.Clear(); - MOZ_LOG(ContentParent::GetLog(), LogLevel::Verbose, - ("destroying Subprocess in ActorDestroy: ContentParent %p " - "mSubprocess %p handle %ld", - this, mSubprocess, - mSubprocess ? (long)mSubprocess->GetChildProcessHandle() : -1)); // FIXME (bug 1520997): does this really need an additional dispatch? MessageLoop::current()->PostTask(NS_NewRunnableFunction( - "DelayedDeleteSubprocessRunnable", [subprocess = mSubprocess] { - MOZ_LOG( - ContentParent::GetLog(), LogLevel::Debug, - ("destroyed Subprocess in ActorDestroy: Subprocess %p handle %ld", - subprocess, - subprocess ? (long)subprocess->GetChildProcessHandle() : -1)); - subprocess->Destroy(); - })); + "DelayedDeleteSubprocessRunnable", + [subprocess = mSubprocess] { subprocess->Destroy(); })); mSubprocess = nullptr; ContentProcessManager* cpm = ContentProcessManager::GetSingleton(); @@ -1879,53 +1756,23 @@ void ContentParent::ActorDestroy(ActorDestroyReason why) { void ContentParent::ActorDealloc() { mSelfRef = nullptr; } bool ContentParent::TryToRecycle() { - // We can only do this if we have a separate cache for recycled - // 'web' processes, and handle them differently than webIsolated ones - if (!mRemoteType.EqualsLiteral(DEFAULT_REMOTE_TYPE)) { - return false; - } // This life time check should be replaced by a memory health check (memory // usage + fragmentation). - - // Note that this is specifically to help with edge cases that rapidly - // create-and-destroy processes const double kMaxLifeSpan = 5; - MOZ_LOG( - ContentParent::GetLog(), LogLevel::Debug, - ("TryToRecycle ContentProcess %p (%u) with lifespan %f seconds", this, - (unsigned int)ChildID(), (TimeStamp::Now() - mActivateTS).ToSeconds())); - if (mShutdownPending || mCalledKillHard || !IsAlive() || !mRemoteType.EqualsLiteral(DEFAULT_REMOTE_TYPE) || - (TimeStamp::Now() - mActivateTS).ToSeconds() > kMaxLifeSpan) { - MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, - ("TryToRecycle did not take ownership of %p", this)); - // It's possible that the process was already cached via Provide() (such - // as from TabDestroyed), and we're being called from a different path, - // such as UnregisterRemoveWorkerActor(), and we're now past kMaxLifeSpan - // (or some other). Ensure that if we're going to destroy this process - // that we don't have it in the cache. - PreallocatedProcessManager::Erase(this); + (TimeStamp::Now() - mActivateTS).ToSeconds() > kMaxLifeSpan || + !PreallocatedProcessManager::Provide(this)) { return false; - } else { - // This will either cache it and take ownership, realize it was already - // cached (due to this being called a second time via a different - // path), or it will decide to not take ownership (if it has another - // already cached) - bool retval = PreallocatedProcessManager::Provide(this); - MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, - ("Provide did %stake ownership of %p", retval ? "" : "not ", this)); - if (retval) { - // The PreallocatedProcessManager took over the ownership let's not keep a - // reference to it - RemoveFromList(); - } - return retval; } + + // The PreallocatedProcessManager took over the ownership let's not keep a + // reference to it, until we don't take it back. + RemoveFromList(); return true; } -bool ContentParent::HasActiveWorkerOrJSPlugin() { +bool ContentParent::ShouldKeepProcessAlive() { if (IsForJSPlugin()) { return true; } @@ -1937,13 +1784,6 @@ bool ContentParent::HasActiveWorkerOrJSPlugin() { return true; } } - return false; -} - -bool ContentParent::ShouldKeepProcessAlive() { - if (HasActiveWorkerOrJSPlugin()) { - return true; - } if (!sBrowserContentParents) { return false; @@ -2001,8 +1841,6 @@ void ContentParent::NotifyTabDestroying() { return; } - MOZ_LOG(ContentParent::GetLog(), LogLevel::Verbose, - ("NotifyTabDestroying %p", this)); if (TryToRecycle()) { return; } @@ -2049,11 +1887,8 @@ void ContentParent::NotifyTabDestroyed(const TabId& aTabId, // There can be more than one PBrowser for a given app process // because of popup windows. When the last one closes, shut // us down. - MOZ_LOG(ContentParent::GetLog(), LogLevel::Verbose, - ("NotifyTabDestroyed %p", this)); if (ManagedPBrowserParent().Count() == 1 && !ShouldKeepProcessAlive() && !TryToRecycle()) { - MarkAsDead(); MaybeAsyncSendShutDownMessage(); } } @@ -2258,10 +2093,7 @@ void ContentParent::LaunchSubprocessReject() { // Now that communication with the child is complete, we can cleanup // the preference serializer. mPrefSerializer = nullptr; - if (mIsAPreallocBlocker) { - PreallocatedProcessManager::RemoveBlocker(mRemoteType, this); - mIsAPreallocBlocker = false; - } + PreallocatedProcessManager::RemoveBlocker(this); MarkAsDead(); } @@ -2273,16 +2105,6 @@ bool ContentParent::LaunchSubprocessResolve(bool aIsSync, mPrefSerializer = nullptr; const auto launchResumeTS = TimeStamp::Now(); -#ifdef MOZ_GECKO_PROFILER - if (profiler_thread_is_being_profiled()) { - nsPrintfCString marker("Process start%s for %u", - mIsAPreallocBlocker ? " (immediate)" : "", - (unsigned int)ChildID()); - PROFILER_ADD_MARKER_WITH_PAYLOAD( - mIsAPreallocBlocker ? "Process Immediate Launch" : "Process Launch", - DOM, TextMarkerPayload, (marker, mLaunchTS, launchResumeTS)); - } -#endif if (!sCreatedFirstContentProcess) { nsCOMPtr obs = mozilla::services::GetObserverService(); @@ -2388,7 +2210,6 @@ ContentParent::ContentParent(ContentParent* aOpener, mLaunchYieldTS(mLaunchTS), mActivateTS(mLaunchTS), mOpener(aOpener), - mIsAPreallocBlocker(false), mRemoteType(aRemoteType), mChildID(gContentChildID++), mGeolocationWatchID(-1), @@ -2431,10 +2252,6 @@ ContentParent::ContentParent(ContentParent* aOpener, NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); bool isFile = mRemoteType.EqualsLiteral(FILE_REMOTE_TYPE); mSubprocess = new GeckoChildProcessHost(GeckoProcessType_Content, isFile); - MOZ_LOG(ContentParent::GetLog(), LogLevel::Verbose, - ("CreateSubprocess: ContentParent %p mSubprocess %p handle %ld", this, - mSubprocess, - mSubprocess ? (long)mSubprocess->GetChildProcessHandle() : -1)); } ContentParent::~ContentParent() { @@ -2444,13 +2261,6 @@ ContentParent::~ContentParent() { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); - if (mIsAPreallocBlocker) { - MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, - ("Removing blocker on ContentProcess destruction")); - PreallocatedProcessManager::RemoveBlocker(mRemoteType, this); - mIsAPreallocBlocker = false; - } - // We should be removed from all these lists in ActorDestroy. MOZ_ASSERT(!sPrivateContent || !sPrivateContent->Contains(this)); if (IsForJSPlugin()) { @@ -2459,18 +2269,12 @@ ContentParent::~ContentParent() { } else { MOZ_ASSERT(!sBrowserContentParents || !sBrowserContentParents->Contains(mRemoteType) || - !sBrowserContentParents->Get(mRemoteType)->Contains(this) || - sCanLaunchSubprocesses == - false); // aka in shutdown - avoid timing issues + !sBrowserContentParents->Get(mRemoteType)->Contains(this)); } // Normally mSubprocess is destroyed in ActorDestroy, but that won't // happen if the process wasn't launched or if it failed to launch. if (mSubprocess) { - MOZ_LOG(ContentParent::GetLog(), LogLevel::Verbose, - ("DestroySubprocess: ContentParent %p mSubprocess %p handle %ld", - this, mSubprocess, - mSubprocess ? (long)mSubprocess->GetChildProcessHandle() : -1)); mSubprocess->Destroy(); } } @@ -2478,8 +2282,6 @@ ContentParent::~ContentParent() { bool ContentParent::InitInternal(ProcessPriority aInitialPriority) { XPCOMInitData xpcomInit; - MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, - ("ContentParent::InitInternal: %p", (void*)this)); nsCOMPtr io(do_GetIOService()); MOZ_ASSERT(io, "No IO service?"); DebugOnly rv = io->GetOffline(&xpcomInit.isOffline()); @@ -3059,10 +2861,7 @@ mozilla::ipc::IPCResult ContentParent::RecvFirstIdle() { // When the ContentChild goes idle, it sends us a FirstIdle message // which we use as a good time to signal the PreallocatedProcessManager // that it can start allocating processes from now on. - if (mIsAPreallocBlocker) { - PreallocatedProcessManager::RemoveBlocker(mRemoteType, this); - mIsAPreallocBlocker = false; - } + PreallocatedProcessManager::RemoveBlocker(this); return IPC_OK(); } @@ -3570,10 +3369,6 @@ void ContentParent::KillHard(const char* aReason) { } if (mSubprocess) { - MOZ_LOG(ContentParent::GetLog(), LogLevel::Verbose, - ("KillHard Subprocess: ContentParent %p mSubprocess %p handle %ld", - this, mSubprocess, - mSubprocess ? (long)mSubprocess->GetChildProcessHandle() : -1)); mSubprocess->SetAlreadyDead(); } @@ -6194,11 +5989,8 @@ void ContentParent::UnregisterRemoveWorkerActor() { } ContentProcessManager* cpm = ContentProcessManager::GetSingleton(); - MOZ_LOG(ContentParent::GetLog(), LogLevel::Verbose, - ("UnregisterRemoveWorkerActor %p", this)); if (!cpm->GetBrowserParentCountByProcessId(ChildID()) && !ShouldKeepProcessAlive() && !TryToRecycle()) { - MarkAsDead(); MaybeAsyncSendShutDownMessage(); } } @@ -6588,7 +6380,7 @@ mozilla::ipc::IPCResult ContentParent::RecvHistoryGo( HistoryGoResolver&& aResolveRequestedIndex) { if (!aContext.IsDiscarded()) { nsSHistory* shistory = - static_cast(aContext.get_canonical()->GetSessionHistory()); + static_cast(aContext.get_canonical()->GetSessionHistory()); nsTArray loadResults; nsresult rv = shistory->GotoIndex(aOffset, loadResults); if (NS_FAILED(rv)) { diff --git a/dom/ipc/ContentParent.h b/dom/ipc/ContentParent.h index 29383fe4293a..1b0da2550c32 100644 --- a/dom/ipc/ContentParent.h +++ b/dom/ipc/ContentParent.h @@ -54,16 +54,15 @@ // Process names as reported by about:memory are defined in // ContentChild:RecvRemoteType. Add your value there too or it will be called // "Web Content". -#define PREALLOC_REMOTE_TYPE "prealloc" #define DEFAULT_REMOTE_TYPE "web" +#define FISSION_WEB_REMOTE_TYPE "webIsolated" #define FILE_REMOTE_TYPE "file" #define EXTENSION_REMOTE_TYPE "extension" #define PRIVILEGEDABOUT_REMOTE_TYPE "privilegedabout" #define PRIVILEGEDMOZILLA_REMOTE_TYPE "privilegedmozilla" - -// These must start with the DEFAULT_REMOTE_TYPE above. -#define FISSION_WEB_REMOTE_TYPE "webIsolated" #define WITH_COOP_COEP_REMOTE_TYPE_PREFIX "webCOOP+COEP=" + +// This must start with the DEFAULT_REMOTE_TYPE above. #define LARGE_ALLOCATION_REMOTE_TYPE "webLargeAllocation" class nsConsoleService; @@ -166,8 +165,6 @@ class ContentParent final NS_DECLARE_STATIC_IID_ACCESSOR(NS_CONTENTPARENT_IID) - static LogModule* GetLog(); - /** * Create a subprocess suitable for use later as a content process. */ @@ -800,11 +797,6 @@ class ContentParent final */ void RemoveFromList(); - /** - * Return if the process has an active worker or JSPlugin - */ - bool HasActiveWorkerOrJSPlugin(); - /** * Decide whether the process should be kept alive even when it would normally * be shut down, for example when all its tabs are closed. @@ -1361,8 +1353,6 @@ class ContentParent final TimeStamp mActivateTS; ContentParent* mOpener; - bool mIsAPreallocBlocker; // We called AddBlocker for this ContentParent - nsString mRemoteType; ContentParentId mChildID; diff --git a/dom/ipc/PreallocatedProcessManager.cpp b/dom/ipc/PreallocatedProcessManager.cpp index 0f7aff0256fc..2baf5690d68a 100644 --- a/dom/ipc/PreallocatedProcessManager.cpp +++ b/dom/ipc/PreallocatedProcessManager.cpp @@ -11,12 +11,10 @@ #include "mozilla/dom/ContentParent.h" #include "mozilla/dom/ScriptSettings.h" #include "mozilla/StaticPrefs_dom.h" -#include "mozilla/StaticPrefs_fission.h" #include "nsIPropertyBag2.h" #include "ProcessPriorityManager.h" #include "nsServiceManagerUtils.h" #include "nsIXULRuntime.h" -#include using namespace mozilla::hal; using namespace mozilla::dom; @@ -27,8 +25,6 @@ namespace mozilla { * PreallocatedProcessManager. */ class PreallocatedProcessManagerImpl final : public nsIObserver { - friend class PreallocatedProcessManager; - public: static PreallocatedProcessManagerImpl* Singleton(); @@ -38,14 +34,13 @@ class PreallocatedProcessManagerImpl final : public nsIObserver { // See comments on PreallocatedProcessManager for these methods. void AddBlocker(ContentParent* aParent); void RemoveBlocker(ContentParent* aParent); - already_AddRefed Take(const nsAString& aRemoteType); + already_AddRefed Take(); bool Provide(ContentParent* aParent); - void Erase(ContentParent* aParent); private: static const char* const kObserverTopics[]; - static StaticRefPtr sSingleton; + static mozilla::StaticRefPtr sSingleton; PreallocatedProcessManagerImpl(); ~PreallocatedProcessManagerImpl(); @@ -59,30 +54,20 @@ class PreallocatedProcessManagerImpl final : public nsIObserver { void AllocateNow(); void RereadPrefs(); - void Enable(uint32_t aProcesses); + void Enable(); void Disable(); - void CloseProcesses(); + void CloseProcess(); void ObserveProcessShutdown(nsISupports* aSubject); - bool IsEmpty() const { - return mPreallocatedProcesses.empty() && !mLaunchInProgress; - } - bool mEnabled; bool mShutdown; bool mLaunchInProgress; - uint32_t mNumberPreallocs; - std::deque> mPreallocatedProcesses; - RefPtr mPreallocatedE10SProcess; // There can be only one - // Even if we have multiple PreallocatedProcessManagerImpls, we'll have - // one blocker counter - static uint32_t sNumBlockers; - TimeStamp mBlockingStartTime; -}; + RefPtr mPreallocatedProcess; + nsTHashtable mBlockers; -/* static */ -uint32_t PreallocatedProcessManagerImpl::sNumBlockers = 0; + bool IsEmpty() const { return !mPreallocatedProcess && !mLaunchInProgress; } +}; const char* const PreallocatedProcessManagerImpl::kObserverTopics[] = { "ipc:content-shutdown", @@ -99,22 +84,18 @@ StaticRefPtr PreallocatedProcessManagerImpl* PreallocatedProcessManagerImpl::Singleton() { MOZ_ASSERT(NS_IsMainThread()); if (!sSingleton) { - sSingleton = new PreallocatedProcessManagerImpl; + sSingleton = new PreallocatedProcessManagerImpl(); sSingleton->Init(); - ClearOnShutdown(&sSingleton, - ShutdownPhase::ShutdownPostLastCycleCollection); + ClearOnShutdown(&sSingleton); } + return sSingleton; - // PreallocatedProcessManagers live until shutdown } NS_IMPL_ISUPPORTS(PreallocatedProcessManagerImpl, nsIObserver) PreallocatedProcessManagerImpl::PreallocatedProcessManagerImpl() - : mEnabled(false), - mShutdown(false), - mLaunchInProgress(false), - mNumberPreallocs(1) {} + : mEnabled(false), mShutdown(false), mLaunchInProgress(false) {} PreallocatedProcessManagerImpl::~PreallocatedProcessManagerImpl() { // This shouldn't happen, because the promise callbacks should @@ -127,11 +108,6 @@ void PreallocatedProcessManagerImpl::Init() { // We have to respect processCount at all time. This is especially important // for testing. Preferences::AddStrongObserver(this, "dom.ipc.processCount"); - // A StaticPref, but we need to adjust the number of preallocated processes - // if the value goes up or down, so we need to run code on change. - Preferences::AddStrongObserver(this, - "dom.ipc.processPrelaunch.fission.number"); - nsCOMPtr os = services::GetObserverService(); MOZ_ASSERT(os); for (auto topic : kObserverTopics) { @@ -153,9 +129,6 @@ PreallocatedProcessManagerImpl::Observe(nsISupports* aSubject, !strcmp("profile-change-teardown", aTopic)) { Preferences::RemoveObserver(this, "dom.ipc.processPrelaunch.enabled"); Preferences::RemoveObserver(this, "dom.ipc.processCount"); - Preferences::RemoveObserver(this, - "dom.ipc.processPrelaunch.fission.number"); - nsCOMPtr os = services::GetObserverService(); MOZ_ASSERT(os); for (auto topic : kObserverTopics) { @@ -163,11 +136,11 @@ PreallocatedProcessManagerImpl::Observe(nsISupports* aSubject, } // Let's prevent any new preallocated processes from starting. ContentParent // will handle the shutdown of the existing process and the - // mPreallocatedProcesses reference will be cleared by the ClearOnShutdown - // of the manager singleton. + // mPreallocatedProcess reference will be cleared by the ClearOnShutdown of + // the manager singleton. mShutdown = true; } else if (!strcmp("memory-pressure", aTopic)) { - CloseProcesses(); + CloseProcess(); } else { MOZ_ASSERT_UNREACHABLE("Unknown topic"); } @@ -178,84 +151,47 @@ PreallocatedProcessManagerImpl::Observe(nsISupports* aSubject, void PreallocatedProcessManagerImpl::RereadPrefs() { if (mozilla::BrowserTabsRemoteAutostart() && Preferences::GetBool("dom.ipc.processPrelaunch.enabled")) { - int32_t number = 1; - if (StaticPrefs::fission_autostart()) { - number = StaticPrefs::dom_ipc_processPrelaunch_fission_number(); - } - if (number >= 0) { - Enable(number); - // We have one prealloc queue for all types except File now - if (static_cast(number) < mPreallocatedProcesses.size()) { - CloseProcesses(); - } - } + Enable(); } else { Disable(); } + + if (ContentParent::IsMaxProcessCountReached( + NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE))) { + CloseProcess(); + } } -already_AddRefed PreallocatedProcessManagerImpl::Take( - const nsAString& aRemoteType) { +already_AddRefed PreallocatedProcessManagerImpl::Take() { if (!mEnabled || mShutdown) { return nullptr; } - RefPtr process; - if (aRemoteType.EqualsLiteral(DEFAULT_REMOTE_TYPE)) { - // we can recycle processes via Provide() for e10s only - process = mPreallocatedE10SProcess.forget(); - if (process) { - MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, - ("Reuse " DEFAULT_REMOTE_TYPE " process %p", - mPreallocatedE10SProcess.get())); - } - } - if (!process && !mPreallocatedProcesses.empty()) { - process = mPreallocatedProcesses.front().forget(); - mPreallocatedProcesses.pop_front(); // holds a nullptr - // We took a preallocated process. Let's try to start up a new one - // soon. - AllocateOnIdle(); - MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, - ("Use " PREALLOC_REMOTE_TYPE " process %p", process.get())); - } - if (process) { - ProcessPriorityManager::SetProcessPriority(process, + + if (mPreallocatedProcess) { + // The preallocated process is taken. Let's try to start up a new one soon. + ProcessPriorityManager::SetProcessPriority(mPreallocatedProcess, PROCESS_PRIORITY_FOREGROUND); + AllocateOnIdle(); } - return process.forget(); + + return mPreallocatedProcess.forget(); } bool PreallocatedProcessManagerImpl::Provide(ContentParent* aParent) { - MOZ_DIAGNOSTIC_ASSERT( - aParent->GetRemoteType().EqualsLiteral(DEFAULT_REMOTE_TYPE)); - // This will take the already-running process even if there's a // launch in progress; if that process hasn't been taken by the // time the launch completes, the new process will be shut down. - if (mEnabled && !mShutdown && !mPreallocatedE10SProcess) { - MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, - ("Store for reuse " DEFAULT_REMOTE_TYPE " process %p", aParent)); - ProcessPriorityManager::SetProcessPriority(aParent, - PROCESS_PRIORITY_BACKGROUND); - mPreallocatedE10SProcess = aParent; - return true; + if (mEnabled && !mShutdown && !mPreallocatedProcess) { + mPreallocatedProcess = aParent; } // We might get a call from both NotifyTabDestroying and NotifyTabDestroyed // with the same ContentParent. Returning true here for both calls is // important to avoid the cached process to be destroyed. - return aParent == mPreallocatedE10SProcess; + return aParent == mPreallocatedProcess; } -void PreallocatedProcessManagerImpl::Erase(ContentParent* aParent) { - // Ensure this ContentParent isn't cached - if (mPreallocatedE10SProcess == aParent) { - mPreallocatedE10SProcess = nullptr; - } -} - -void PreallocatedProcessManagerImpl::Enable(uint32_t aProcesses) { - mNumberPreallocs = aProcesses; +void PreallocatedProcessManagerImpl::Enable() { if (mEnabled) { return; } @@ -265,13 +201,13 @@ void PreallocatedProcessManagerImpl::Enable(uint32_t aProcesses) { } void PreallocatedProcessManagerImpl::AddBlocker(ContentParent* aParent) { - if (sNumBlockers == 0) { - mBlockingStartTime = TimeStamp::Now(); - } - sNumBlockers++; + uint64_t childID = aParent->ChildID(); + MOZ_ASSERT(!mBlockers.Contains(childID)); + mBlockers.PutEntry(childID); } void PreallocatedProcessManagerImpl::RemoveBlocker(ContentParent* aParent) { + uint64_t childID = aParent->ChildID(); // This used to assert that the blocker existed, but preallocated // processes aren't blockers anymore because it's not useful and // interferes with async launch, and it's simpler if content @@ -279,28 +215,16 @@ void PreallocatedProcessManagerImpl::RemoveBlocker(ContentParent* aParent) { // (And preallocated processes can't AddBlocker when taken, because // it's possible for a short-lived process to be recycled through // Provide() and Take() before reaching RecvFirstIdle.) - - MOZ_DIAGNOSTIC_ASSERT(sNumBlockers > 0); - sNumBlockers--; - if (sNumBlockers == 0) { - MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, - ("Blocked preallocation for %fms", - (TimeStamp::Now() - mBlockingStartTime).ToMilliseconds())); - PROFILER_ADD_TEXT_MARKER( - "Process", NS_LITERAL_CSTRING("Blocked preallocation"), - JS::ProfilingCategoryPair::DOM, mBlockingStartTime, TimeStamp::Now()); - if (IsEmpty()) { - AllocateAfterDelay(); - } + mBlockers.RemoveEntry(childID); + if (IsEmpty() && mBlockers.IsEmpty()) { + AllocateAfterDelay(); } } bool PreallocatedProcessManagerImpl::CanAllocate() { - return mEnabled && sNumBlockers == 0 && - mPreallocatedProcesses.size() < mNumberPreallocs && !mShutdown && - (StaticPrefs::fission_autostart() || - !ContentParent::IsMaxProcessCountReached( - NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE))); + return mEnabled && mBlockers.IsEmpty() && IsEmpty() && !mShutdown && + !ContentParent::IsMaxProcessCountReached( + NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE)); } void PreallocatedProcessManagerImpl::AllocateAfterDelay() { @@ -327,7 +251,7 @@ void PreallocatedProcessManagerImpl::AllocateOnIdle() { void PreallocatedProcessManagerImpl::AllocateNow() { if (!CanAllocate()) { - if (mEnabled && !mShutdown && IsEmpty() && sNumBlockers > 0) { + if (mEnabled && !mShutdown && IsEmpty() && !mBlockers.IsEmpty()) { // If it's too early to allocate a process let's retry later. AllocateAfterDelay(); } @@ -343,22 +267,7 @@ void PreallocatedProcessManagerImpl::AllocateNow() { [self, this](const RefPtr& process) { mLaunchInProgress = false; if (CanAllocate()) { - // slight perf reason for push_back - while the cpu cache - // probably has stack/etc associated with the most recent - // process created, we don't know that it has finished startup. - // If we added it to the queue on completion of startup, we - // could push_front it, but that would require a bunch more - // logic. - mPreallocatedProcesses.push_back(process); - MOZ_LOG( - ContentParent::GetLog(), LogLevel::Debug, - ("Preallocated = %lu of %d processes", - (unsigned long)mPreallocatedProcesses.size(), mNumberPreallocs)); - - // Continue prestarting processes if needed - if (mPreallocatedProcesses.size() < mNumberPreallocs) { - AllocateOnIdle(); - } + mPreallocatedProcess = process; } else { process->ShutDownProcess(ContentParent::SEND_SHUTDOWN_MESSAGE); } @@ -375,20 +284,13 @@ void PreallocatedProcessManagerImpl::Disable() { } mEnabled = false; - CloseProcesses(); + CloseProcess(); } -void PreallocatedProcessManagerImpl::CloseProcesses() { - while (!mPreallocatedProcesses.empty()) { - RefPtr process(mPreallocatedProcesses.front().forget()); - mPreallocatedProcesses.pop_front(); - process->ShutDownProcess(ContentParent::SEND_SHUTDOWN_MESSAGE); - // drop ref and let it free - } - if (mPreallocatedE10SProcess) { - mPreallocatedE10SProcess->ShutDownProcess( - ContentParent::SEND_SHUTDOWN_MESSAGE); - mPreallocatedE10SProcess = nullptr; +void PreallocatedProcessManagerImpl::CloseProcess() { + if (mPreallocatedProcess) { + mPreallocatedProcess->ShutDownProcess(ContentParent::SEND_SHUTDOWN_MESSAGE); + mPreallocatedProcess = nullptr; } } @@ -401,14 +303,11 @@ void PreallocatedProcessManagerImpl::ObserveProcessShutdown( props->GetPropertyAsUint64(NS_LITERAL_STRING("childID"), &childID); NS_ENSURE_TRUE_VOID(childID != CONTENT_PROCESS_ID_UNKNOWN); - for (auto it = mPreallocatedProcesses.begin(); - it != mPreallocatedProcesses.end(); it++) { - if (childID == (*it)->ChildID()) { - mPreallocatedProcesses.erase(it); - break; - } + if (mPreallocatedProcess && childID == mPreallocatedProcess->ChildID()) { + mPreallocatedProcess = nullptr; } - // The ContentParent is responsible for removing itself as a blocker + + mBlockers.RemoveEntry(childID); } inline PreallocatedProcessManagerImpl* GetPPMImpl() { @@ -416,29 +315,18 @@ inline PreallocatedProcessManagerImpl* GetPPMImpl() { } /* static */ -void PreallocatedProcessManager::AddBlocker(const nsAString& aRemoteType, - ContentParent* aParent) { - MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, - ("AddBlocker: %s %p (sNumBlockers=%d)", - NS_ConvertUTF16toUTF8(aRemoteType).get(), aParent, - PreallocatedProcessManagerImpl::sNumBlockers)); +void PreallocatedProcessManager::AddBlocker(ContentParent* aParent) { GetPPMImpl()->AddBlocker(aParent); } /* static */ -void PreallocatedProcessManager::RemoveBlocker(const nsAString& aRemoteType, - ContentParent* aParent) { - MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, - ("RemoveBlocker: %s %p (sNumBlockers=%d)", - NS_ConvertUTF16toUTF8(aRemoteType).get(), aParent, - PreallocatedProcessManagerImpl::sNumBlockers)); +void PreallocatedProcessManager::RemoveBlocker(ContentParent* aParent) { GetPPMImpl()->RemoveBlocker(aParent); } /* static */ -already_AddRefed PreallocatedProcessManager::Take( - const nsAString& aRemoteType) { - return GetPPMImpl()->Take(aRemoteType); +already_AddRefed PreallocatedProcessManager::Take() { + return GetPPMImpl()->Take(); } /* static */ @@ -446,9 +334,4 @@ bool PreallocatedProcessManager::Provide(ContentParent* aParent) { return GetPPMImpl()->Provide(aParent); } -/* static */ -void PreallocatedProcessManager::Erase(ContentParent* aParent) { - GetPPMImpl()->Erase(aParent); -} - } // namespace mozilla diff --git a/dom/ipc/PreallocatedProcessManager.h b/dom/ipc/PreallocatedProcessManager.h index d22a3900a3a8..a4896f609e04 100644 --- a/dom/ipc/PreallocatedProcessManager.h +++ b/dom/ipc/PreallocatedProcessManager.h @@ -37,30 +37,23 @@ class PreallocatedProcessManager final { * background. To avoid that, the PreallocatedProcessManager won't start up * any processes while there is a blocker active. */ - static void AddBlocker(const nsAString& aRemoteType, ContentParent* aParent); - static void RemoveBlocker(const nsAString& aRemoteType, - ContentParent* aParent); + static void AddBlocker(ContentParent* aParent); + static void RemoveBlocker(ContentParent* aParent); /** - * Take the preallocated process, if we have one, or a recycled - * process cached via Provide(). Currently we only cache - * DEFAULT_REMOTE_TYPE ('web') processes and only reuse them for that - * type. If we don't have a process to return (cached or preallocated), - * this returns null. + * Take the preallocated process, if we have one. If we don't have one, this + * returns null. * - * If we use a preallocated process, it will schedule the start of - * another on Idle (AllocateOnIdle()). + * If you call Take() twice in a row, the second call is guaranteed to return + * null. + * + * After you Take() the preallocated process, you need to call one of the + * Allocate* functions (or change the dom.ipc.processPrelaunch pref from + * false to true) before we'll create a new process. */ - static already_AddRefed Take(const nsAString& aRemoteType); + static already_AddRefed Take(); - /** - * Cache a process (currently only DEFAULT_REMOTE_TYPE) for reuse later - * via Take(). Returns true if we cached the process, and false if - * another process is already cached (so the caller knows to destroy it). - * This takes a reference to the ContentParent if it is cached. - */ static bool Provide(ContentParent* aParent); - static void Erase(ContentParent* aParent); private: PreallocatedProcessManager(); diff --git a/dom/ipc/ProcessPriorityManager.cpp b/dom/ipc/ProcessPriorityManager.cpp index be982357ec8b..30c9980eb450 100644 --- a/dom/ipc/ProcessPriorityManager.cpp +++ b/dom/ipc/ProcessPriorityManager.cpp @@ -808,8 +808,6 @@ void ParticularProcessPriorityManager::TabActivityChanged( void ParticularProcessPriorityManager::ShutDown() { MOZ_ASSERT(mContentParent); - LOGP("shutdown for %p (mContentParent %p)", this, mContentParent); - UnregisterWakeLockObserver(this); if (mResetPriorityTimer) { @@ -944,7 +942,6 @@ void ProcessPriorityManager::Init() { void ProcessPriorityManager::SetProcessPriority(ContentParent* aContentParent, ProcessPriority aPriority) { MOZ_ASSERT(aContentParent); - MOZ_ASSERT(aContentParent->Pid() != -1); ProcessPriorityManagerImpl* singleton = ProcessPriorityManagerImpl::GetSingleton(); diff --git a/dom/l10n/tests/mochitest/document_l10n/non-system-principal/browser_resource_uri.js b/dom/l10n/tests/mochitest/document_l10n/non-system-principal/browser_resource_uri.js index 975affbb953d..2b76bf8b4036 100644 --- a/dom/l10n/tests/mochitest/document_l10n/non-system-principal/browser_resource_uri.js +++ b/dom/l10n/tests/mochitest/document_l10n/non-system-principal/browser_resource_uri.js @@ -24,17 +24,9 @@ L10nRegistry.registerSource(mockSource); registerCleanupFunction(() => { protocol.setSubstitution("l10n-test", null); L10nRegistry.removeSource("test"); - SpecialPowers.pushPrefEnv({ - set: [["dom.ipc.processPrelaunch.enabled", true]], - }); }); add_task(async () => { - // Bug 1640333 - windows fails (sometimes) to ever get document.l10n.ready - // if e10s process caching is enabled - await SpecialPowers.pushPrefEnv({ - set: [["dom.ipc.processPrelaunch.enabled", false]], - }); await BrowserTestUtils.withNewTab( "resource://l10n-test/test.html", async browser => { diff --git a/dom/media/tests/mochitest/mochitest.ini b/dom/media/tests/mochitest/mochitest.ini index 6ade0936c2d8..11f0ac33e06d 100644 --- a/dom/media/tests/mochitest/mochitest.ini +++ b/dom/media/tests/mochitest/mochitest.ini @@ -213,7 +213,7 @@ skip-if = toolkit == 'android' # no simulcast support on android [test_peerConnection_simulcastOddResolution.html] skip-if = toolkit == 'android' # no simulcast support on android [test_peerConnection_relayOnly.html] -disabled=bug 1612063 # test is racy +skip-if = toolkit == 'android' # Bug 1612063, this test fails on android-hw and android-em [test_peerConnection_callbacks.html] [test_peerConnection_replaceTrack.html] [test_peerConnection_replaceTrack_disabled.html] diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index 71a0c01a5b89..5130ccf0dcdd 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -1904,7 +1904,7 @@ value: false mirror: always -# Process launch delay (in milliseconds). +# Process launch delay (im milliseconds). - name: dom.ipc.processPrelaunch.delayMs type: uint32_t # This number is fairly arbitrary ... the intention is to put off @@ -1913,13 +1913,6 @@ value: 1000 mirror: always -# Process preallocation cache -# Only used in fission; in e10s we use 1 always -- name: dom.ipc.processPrelaunch.fission.number - type: uint32_t - value: 3 - mirror: always - - name: dom.ipc.processPriorityManager.enabled type: bool value: false diff --git a/toolkit/components/telemetry/tests/browser/browser_DynamicScalars.js b/toolkit/components/telemetry/tests/browser/browser_DynamicScalars.js index 024d4a5d7b13..e7ef6a3e23ab 100644 --- a/toolkit/components/telemetry/tests/browser/browser_DynamicScalars.js +++ b/toolkit/components/telemetry/tests/browser/browser_DynamicScalars.js @@ -30,19 +30,9 @@ async function waitForProcessesScalars( add_task(async function test_setup() { // Make sure the newly spawned content processes will have extended Telemetry enabled. - // Since Telemetry reads the prefs only at process startup, flush all cached - // and preallocated processes so they pick up the setting. await SpecialPowers.pushPrefEnv({ - set: [ - [TelemetryUtils.Preferences.OverridePreRelease, true], - ["dom.ipc.processPrelaunch.enabled", false], - ], + set: [[TelemetryUtils.Preferences.OverridePreRelease, true]], }); - Services.ppmm.releaseCachedProcesses(); - await SpecialPowers.pushPrefEnv({ - set: [["dom.ipc.processPrelaunch.enabled", true]], - }); - // And take care of the already initialized one as well. let canRecordExtended = Services.telemetry.canRecordExtended; Services.telemetry.canRecordExtended = true; @@ -131,9 +121,9 @@ add_task(async function test_recording() { ); // Wait for the dynamic scalars to appear non-keyed snapshots. - await waitForProcessesScalars(["dynamic"], true, scalars => { + await waitForProcessesScalars(["dynamic"], false, scalars => { // Wait for the scalars set in the content process to be available. - return "telemetry.test.dynamic.post_content_spawn_keyed" in scalars.dynamic; + return "telemetry.test.dynamic.pre_content_spawn" in scalars.dynamic; }); // Verify the content of the snapshots. diff --git a/toolkit/locales/en-US/toolkit/global/processTypes.ftl b/toolkit/locales/en-US/toolkit/global/processTypes.ftl index cd6208c7aea9..61a80cd8f3af 100644 --- a/toolkit/locales/en-US/toolkit/global/processTypes.ftl +++ b/toolkit/locales/en-US/toolkit/global/processTypes.ftl @@ -31,6 +31,3 @@ process-type-gpu = GPU # process used to perform network operations process-type-socket = Socket - -# process preallocated; may change to other types -process-type-prealloc = Preallocated diff --git a/widget/ProcInfo.h b/widget/ProcInfo.h index 4628b9e81650..5d5fe18dbc41 100644 --- a/widget/ProcInfo.h +++ b/widget/ProcInfo.h @@ -18,8 +18,7 @@ class GeckoChildProcessHost; } // Process types. When updating this enum, please make sure to update -// WebIDLProcType, ChromeUtils::RequestProcInfo and ProcTypeToWebIDL to -// mirror the changes. +// WebIDLProcType and ProcTypeToWebIDL to mirror the changes. enum class ProcType { // These must match the ones in ContentParent.h, and E10SUtils.jsm Web, @@ -43,7 +42,6 @@ enum class ProcType { #ifdef MOZ_ENABLE_FORKSERVER ForkServer, #endif - Preallocated, // Unknown type of process Unknown, Max = Unknown,