Bug 1382889 - Part 1: Clear the preloaded process after closing tabs. r=bc
authorEric Rahm <erahm@mozilla.com>
Wed, 26 Jul 2017 12:07:16 -0700
changeset 422442 92d9a593abdad1174fe96840233ebd6bca1bc1e7
parent 422441 1efacc8c49ba68b524de18c6b30153cb78e524d2
child 422443 484096481587c8c66e27a4d834ec62f596ae55f3
push id1517
push userjlorenzo@mozilla.com
push dateThu, 14 Sep 2017 16:50:54 +0000
treeherdermozilla-release@3b41fd564418 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbc
bugs1382889
milestone56.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 1382889 - Part 1: Clear the preloaded process after closing tabs. r=bc Clears the preloaded process that can be kept alive by various new features so that our 'TabsClosed' metrics continue to measure the same thing, mainly 1 chrome process and 1 content process sticking around. MozReview-Commit-ID: L4g45o4mTzR
testing/awsy/awsy/test_memory_usage.py
--- a/testing/awsy/awsy/test_memory_usage.py
+++ b/testing/awsy/awsy/test_memory_usage.py
@@ -121,16 +121,44 @@ class TestMemoryUsage(MarionetteTestCase
                 self.logger.error("gBrowser.removeCurrentTab() Unexpected error: %s" % sys.exc_info()[0])
             else:
                 self.logger.info(result)
             time.sleep(0.25)
 
         self._tabs = self.marionette.window_handles
         self.marionette.switch_to_window(self._tabs[0])
 
+    def clear_preloaded_browser(self):
+        """
+        Clears out the preloaded browser.
+
+        Note: Does nothing on older builds that don't have a
+              `gBrowser.removePreloadedBrowser` method.
+        """
+        self.logger.info("closing preloaded browser")
+        script = """
+            if ("removePreloadedBrowser" in gBrowser) {
+                return gBrowser.removePreloadedBrowser();
+            } else {
+                return "gBrowser.removePreloadedBrowser not available";
+            }
+            """
+        try:
+            result = self.marionette.execute_script(script,
+                                                    script_timeout=180000)
+        except JavascriptException, e:
+            self.logger.error("gBrowser.removePreloadedBrowser() JavaScript error: %s" % e)
+        except ScriptTimeoutException:
+            self.logger.error("gBrowser.removePreloadedBrowser() timed out")
+        except:
+            self.logger.error("gBrowser.removePreloadedBrowser() Unexpected error: %s" % sys.exc_info()[0])
+        else:
+            if result:
+              self.logger.info(result)
+
     def do_full_gc(self):
         """Performs a full garbage collection cycle and returns when it is finished.
 
         Returns True on success and False on failure.
         """
         # NB: we could do this w/ a signal or the fifo queue too
         self.logger.info("starting gc...")
         gc_script = """
@@ -337,16 +365,19 @@ class TestMemoryUsage(MarionetteTestCase
             self.marionette.switch_to_window(self._tabs[0])
             self.logger.info("switched to first window")
             with self.marionette.using_context('content'):
                 self.logger.info("navigating to about:blank")
                 self.marionette.navigate("about:blank")
                 self.logger.info("navigated to about:blank")
             self.signal_user_active()
 
+            # Clear out the retained processes and measure again.
+            self.clear_preloaded_browser()
+
             create_checkpoint("TabsClosed", itr)
             time.sleep(self._settleWaitTime)
             create_checkpoint("TabsClosedSettled", itr)
             self.assertTrue(self.do_full_gc(), "GC ran")
             create_checkpoint("TabsClosedForceGC", itr)
 
         # TODO(ER): Temporary hack until bug 1121139 lands
         self.logger.info("setting results")