Bug 1585114 - Don't return shutdown pending processes from ContentParent::GetNewOrUsedBrowserProcess. r=mattwoodrow
authorAndrew McCreight <continuation@gmail.com>
Wed, 13 Nov 2019 01:16:10 +0000
changeset 501676 37b70cca0d2fafeb578520983bae2c0a5fd8e540
parent 501675 4c34130cc58ff8d8efbbd2c1e8190f4982ee4223
child 501677 4b4f0fb8292c18cd114e92ed3f1c57f187a7d5eb
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1585114
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1585114 - Don't return shutdown pending processes from ContentParent::GetNewOrUsedBrowserProcess. r=mattwoodrow ContentParent::GetNewOrUsedBrowserProcess can end up returning a content parent that is in the middle of shutting down if the nsIContentProcessProvider implementation threw an error because we'd fall back to MinTabSelect(), which didn't exclude content parents that were being shutdown. This patch fixes that. The reason that the existing implementations of nsIContentProcessProviders fail is that the array that is passed to them can contain null entries which the code does not expect. I'll fix that in a separate bug. Differential Revision: https://phabricator.services.mozilla.com/D52774
dom/ipc/ContentParent.cpp
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -801,17 +801,17 @@ already_AddRefed<ContentParent> ContentP
   uint32_t min = INT_MAX;
   RefPtr<ContentParent> candidate;
   ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
 
   for (uint32_t i = 0; i < maxSelectable; i++) {
     ContentParent* p = aContentParents[i];
     NS_ASSERTION(p->IsAlive(),
                  "Non-alive contentparent in sBrowserContentParents?");
-    if (p->mOpener == aOpener) {
+    if (!p->mShutdownPending && p->mOpener == aOpener) {
       uint32_t tabCount = cpm->GetBrowserParentCountByProcessId(p->ChildID());
       if (tabCount < min) {
         candidate = p;
         min = tabCount;
       }
     }
   }