Bug 1051658 - Part 3: Release decoders more aggressively for it is easy to exceed the limit of active cubeb streams on OSX 10.6 and cause decode errors and test failures. r=kinetik
authorJW Wang <jwwang@mozilla.com>
Wed, 01 Oct 2014 18:36:00 -0400
changeset 208701 9e8624c37de04d02a1e66e1d957c019d73ecb38f
parent 208700 423127691c488953a63ed68f6788870e1ce531b5
child 208702 645d5e930e2348f9f67b816c20b7f6cacdc782af
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewerskinetik
bugs1051658
milestone35.0a1
Bug 1051658 - Part 3: Release decoders more aggressively for it is easy to exceed the limit of active cubeb streams on OSX 10.6 and cause decode errors and test failures. r=kinetik
content/media/test/manifest.js
content/media/test/test_bug448534.html
content/media/test/test_bug465498.html
--- a/content/media/test/manifest.js
+++ b/content/media/test/manifest.js
@@ -814,41 +814,48 @@ function MediaTestManager() {
         !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();
+      var onCleanup = function() {
+        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();
+      }.bind(this);
+      mediaTestCleanup(onCleanup);
       return;
     }
   }
 }
 
 // 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() {
+function mediaTestCleanup(callback) {
     var V = document.getElementsByTagName("video");
     for (i=0; i<V.length; i++) {
       removeNodeAndSource(V[i]);
       V[i] = null;
     }
     var A = document.getElementsByTagName("audio");
     for (i=0; i<A.length; i++) {
       removeNodeAndSource(A[i]);
       A[i] = null;
     }
-    SpecialPowers.forceGC();
+    var cb = function() {
+      if (callback) {
+        callback();
+      }
+    }
+    SpecialPowers.exactGC(window, cb);
 }
 
 (function() {
   // Ensure that preload preferences are comsistent
   var prefService = SpecialPowers.wrap(SpecialPowers.Components)
                                  .classes["@mozilla.org/preferences-service;1"]
                                  .getService(SpecialPowers.Ci.nsIPrefService);
   var branch = prefService.getBranch("media.");
--- a/content/media/test/test_bug448534.html
+++ b/content/media/test/test_bug448534.html
@@ -34,16 +34,17 @@ function started(event) {
 }
 
 function stopped(event) {
   var v = event.target;
   if (v._finished)
     return;
   v._finished = true;
   ok(v.paused, "Video should be paused after removing from the Document");
+  removeNodeAndSource(v);
   manager.finished(v.token);
 }
 
 
 function startTest(test, token) {
   var v = document.createElement('video');
   v.preload = "metadata";
   v.token = token;
--- a/content/media/test/test_bug465498.html
+++ b/content/media/test/test_bug465498.html
@@ -37,17 +37,17 @@ function seekEnded(e) {
   var v = e.target;
   info(v._name + " seeked");
   if (v._finished)
     return;
   ok(v.currentTime == 0, "Checking currentTime after seek: " +
      v.currentTime  + " for " + v._name);
   ok(!v.ended, "Checking ended is false for " + v._name);
   v._finished = true;
-  v.parentNode.removeChild(v);
+  removeNodeAndSource(v);
   manager.finished(v.token);
 }
 
 function seeking(e) {
   var v = e.target;
   info(v._name + " seeking");
 }