Bug 941314 - Use SpecialPowers.exactGC in media mochitests to hopefully improve their reliability. r=kinetik
authorChris Pearce <cpearce@mozilla.com>
Fri, 06 Dec 2013 17:15:13 +1300
changeset 174776 dee18b5520fb04844f0c703274720a706d138331
parent 174775 dba508605c1b4c40ff47436d5a345b67e7b38074
child 174777 2762cab83d31e5082a740d71f48050cbcef4227d
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskinetik
bugs941314
milestone28.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 941314 - Use SpecialPowers.exactGC in media mochitests to hopefully improve their reliability. r=kinetik
content/media/test/manifest.js
--- a/content/media/test/manifest.js
+++ b/content/media/test/manifest.js
@@ -641,54 +641,54 @@ function MediaTestManager() {
     if (this.tokens.length < PARALLEL_TESTS) {
       this.nextTest();
     }
   }
 
   // Starts the next batch of tests, or finishes if they're all done.
   // Don't call this directly, call finished(token) when you're done.
   this.nextTest = function() {
-    // Force a GC after every completed testcase. This ensures that any decoders
-    // with live threads waiting for the GC are killed promptly, to free up the
-    // thread stacks' address space.
-    SpecialPowers.forceGC();
+    // Force an exact  GC after every completed testcase. This ensures that any
+    // decoders with live threads waiting for the GC are killed promptly, to free
+    // up the thread stacks' address space, and destroy decoder resources.
+    SpecialPowers.exactGC(window, function(){
+      while (this.testNum < this.tests.length && this.tokens.length < PARALLEL_TESTS) {
+        var test = this.tests[this.testNum];
+        var token = (test.name ? (test.name + "-"): "") + this.testNum;
+        this.testNum++;
 
-    while (this.testNum < this.tests.length && this.tokens.length < PARALLEL_TESTS) {
-      var test = this.tests[this.testNum];
-      var token = (test.name ? (test.name + "-"): "") + this.testNum;
-      this.testNum++;
+        if (DEBUG_TEST_LOOP_FOREVER && this.testNum == this.tests.length) {
+          this.testNum = 0;
+        }
 
-      if (DEBUG_TEST_LOOP_FOREVER && this.testNum == this.tests.length) {
-        this.testNum = 0;
+        // Ensure we can play the resource type.
+        if (test.type && !document.createElement('video').canPlayType(test.type))
+          continue;
+
+        // Do the init. This should start the test.
+        this.startTest(test, token);
       }
 
-      // Ensure we can play the resource type.
-      if (test.type && !document.createElement('video').canPlayType(test.type))
-        continue;
-
-      // Do the init. This should start the test.
-      this.startTest(test, token);
-    }
-
-    if (this.testNum == this.tests.length &&
-        !DEBUG_TEST_LOOP_FOREVER &&
-        this.tokens.length == 0 &&
-        !this.isShutdown)
-    {
-      this.isShutdown = true;
-      if (this.onFinished) {
-        this.onFinished();
+      if (this.testNum == this.tests.length &&
+          !DEBUG_TEST_LOOP_FOREVER &&
+          this.tokens.length == 0 &&
+          !this.isShutdown)
+      {
+        this.isShutdown = true;
+        if (this.onFinished) {
+          this.onFinished();
+        }
+        mediaTestCleanup();
+        var end = new Date();
+        SimpleTest.info("Finished at " + end + " (" + (end.getTime() / 1000) + "s)");
+        SimpleTest.info("Running time: " + (end.getTime() - this.startTime.getTime())/1000 + "s");
+        SimpleTest.finish();
+        return;
       }
-      mediaTestCleanup();
-      var end = new Date();
-      SimpleTest.info("Finished at " + end + " (" + (end.getTime() / 1000) + "s)");
-      SimpleTest.info("Running time: " + (end.getTime() - this.startTime.getTime())/1000 + "s");
-      SimpleTest.finish();
-      return;
-    }
+    }.bind(this));
   }
 }
 
 // Ensures we've got no active video or audio elements in the document, and
 // forces a GC to release the address space reserved by the decoders' threads'
 // stacks.
 function mediaTestCleanup() {
     var V = document.getElementsByTagName("video");