Bug 1424505 - Avoid recycling content process when accessibility is active. r=aklotz
authorJim Mathies <jmathies@mozilla.com>
Thu, 08 Mar 2018 19:33:47 -0600
changeset 462441 cb808626c8df4679b351e184c955d1d15cc2c2bf
parent 462440 017dbfcb23698b9484a4467221e86a0dca980326
child 462442 d028bee2fa0edb25eb14789709f2f7e3f95a5859
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaklotz
bugs1424505
milestone60.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 1424505 - Avoid recycling content process when accessibility is active. r=aklotz MozReview-Commit-ID: 6rgOzR7qGfS
dom/ipc/ContentParent.cpp
dom/ipc/PreallocatedProcessManager.cpp
dom/ipc/PreallocatedProcessManager.h
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -2913,16 +2913,19 @@ ContentParent::Observe(nsISupports* aSub
     Unused << SendUnlinkGhosts();
   }
   else if (!strcmp(aTopic, "last-pb-context-exited")) {
     Unused << SendLastPrivateDocShellDestroyed();
   }
 #ifdef ACCESSIBILITY
   else if (aData && !strcmp(aTopic, "a11y-init-or-shutdown")) {
     if (*aData == '1') {
+      // Shut down the preallocated process manager to avoid recycled
+      // content processes.
+      PreallocatedProcessManager::Disable();
       // Make sure accessibility is running in content process when
       // accessibility gets initiated in chrome process.
 #if defined(XP_WIN)
       // Don't init content a11y if we detect an incompat version of JAWS in use.
       if (!mozilla::a11y::Compatibility::IsOldJAWS()) {
         Unused << SendActivateA11y(::GetCurrentThreadId(),
                                    a11y::AccessibleWrap::GetContentProcessIdFor(ChildID()));
       }
--- a/dom/ipc/PreallocatedProcessManager.cpp
+++ b/dom/ipc/PreallocatedProcessManager.cpp
@@ -38,16 +38,17 @@ public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIOBSERVER
 
   // See comments on PreallocatedProcessManager for these methods.
   void AddBlocker(ContentParent* aParent);
   void RemoveBlocker(ContentParent* aParent);
   already_AddRefed<ContentParent> Take();
   bool Provide(ContentParent* aParent);
+  void Disable();
 
 private:
   static mozilla::StaticRefPtr<PreallocatedProcessManagerImpl> sSingleton;
 
   PreallocatedProcessManagerImpl();
   ~PreallocatedProcessManagerImpl() {}
   DISALLOW_EVIL_CONSTRUCTORS(PreallocatedProcessManagerImpl);
 
@@ -55,17 +56,16 @@ private:
 
   bool CanAllocate();
   void AllocateAfterDelay();
   void AllocateOnIdle();
   void AllocateNow();
 
   void RereadPrefs();
   void Enable();
-  void Disable();
   void CloseProcess();
 
   void ObserveProcessShutdown(nsISupports* aSubject);
 
   bool mEnabled;
   bool mShutdown;
   RefPtr<ContentParent> mPreallocatedProcess;
   nsTHashtable<nsUint64HashKey> mBlockers;
@@ -330,9 +330,15 @@ PreallocatedProcessManager::Take()
 }
 
 /* static */ bool
 PreallocatedProcessManager::Provide(ContentParent* aParent)
 {
   return GetPPMImpl()->Provide(aParent);
 }
 
+/* static */ void
+PreallocatedProcessManager::Disable()
+{
+  GetPPMImpl()->Disable();
+}
+
 } // namespace mozilla
--- a/dom/ipc/PreallocatedProcessManager.h
+++ b/dom/ipc/PreallocatedProcessManager.h
@@ -50,18 +50,30 @@ public:
    * 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<ContentParent> Take();
 
+  /**
+   * ContentParent entry point for recycling existing content processes that are
+   * no longer in use. This class currently only caches one instance. It is safe
+   * to call this repeatedly with the same process.
+   *
+   * @returns boolean indicating if aParent is cached for reuse.
+   */
   static bool Provide(ContentParent* aParent);
 
+  /**
+   * Disables this service and discards any cached content processes.
+   */
+  static void Disable();
+
 private:
   PreallocatedProcessManager();
   DISALLOW_EVIL_CONSTRUCTORS(PreallocatedProcessManager);
 };
 
 } // namespace mozilla
 
 #endif // defined mozilla_PreallocatedProcessManager_h