Bug 1465261 [wpt PR 11236] - Fix flaky k-rate-panner test, a=testonly
authorRaymond Toy <rtoy@chromium.org>
Fri, 06 Jul 2018 17:39:53 +0000
changeset 425842 2f482d496e26dcab03cfa48a0dde791df4790252
parent 425841 ba6aaf04e9df95b2b96b9eb5152d922772b4921e
child 425843 a04e1c8a9b691e1a80c879b3f1bab5a91ed079a9
push id105141
push userjames@hoppipolla.co.uk
push dateWed, 11 Jul 2018 07:44:38 +0000
treeherdermozilla-inbound@b06fa226ba6d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1465261, 11236, 841856, 1076809, 568100
milestone63.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 1465261 [wpt PR 11236] - Fix flaky k-rate-panner test, a=testonly Automatic update from web-platform-testsFix flaky k-rate-panner test Change the testing scheme for k-rate panner to verify that the output is piecewise constant for a constant source when the automation rate is set to k-rate. Reduce the duration of the test as well; Just a few render quanta is enough to verify that the output is piece-wise constant and different from the a-rate output. Also updated k-rate-constant-source.html to use the same doTest method since the special case is supported. Didn't actually figure out the underlying flakiness of the original test. Bug: 841856 Change-Id: I8e9807e530fc3b1452bae521a2660be3fbe104f9 Reviewed-on: https://chromium-review.googlesource.com/1076809 Reviewed-by: Hongchan Choi <hongchan@chromium.org> Commit-Queue: Raymond Toy <rtoy@chromium.org> Cr-Commit-Position: refs/heads/master@{#568100} -- wpt-commits: 901c2f9f0e4fd894297def0eac89e61d325a5643 wpt-pr: 11236
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/webaudio/the-audio-api/the-audioparam-interface/automation-rate-testing.js
testing/web-platform/tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-constant-source.html
testing/web-platform/tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-panner.html
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -621462,17 +621462,17 @@
    "c9e8ab0b530ad296654697dabf44c6403afbade7",
    "testharness"
   ],
   "webaudio/the-audio-api/the-audioparam-interface/audioparam-summingjunction.html": [
    "debf11e342633d931eb7c14e673a70b8e4ec84c6",
    "testharness"
   ],
   "webaudio/the-audio-api/the-audioparam-interface/automation-rate-testing.js": [
-   "abd017009aff151436f4f17ea51fe94e20c1cf6a",
+   "90314b367161c720ccbb880e53d65bedc209d0bd",
    "support"
   ],
   "webaudio/the-audio-api/the-audioparam-interface/automation-rate.html": [
    "b02f43f108b7e1ba9c33aa0b872ee1bc60d31a25",
    "testharness"
   ],
   "webaudio/the-audio-api/the-audioparam-interface/event-insertion.html": [
    "a41ff42bd211f135a9942e885f2134fa41a1e1d7",
@@ -621486,33 +621486,33 @@
    "cfe68d4899ed1582d2827f6dea5cf8960ac4e192",
    "testharness"
   ],
   "webaudio/the-audio-api/the-audioparam-interface/k-rate-biquad.html": [
    "17ad5f8770ff9836d177bd296b44a2690d9d5538",
    "testharness"
   ],
   "webaudio/the-audio-api/the-audioparam-interface/k-rate-constant-source.html": [
-   "094368fb4cff58ea97aa8e1b365a359aed3dc6af",
+   "1cf2706025fe92649f859608b195387346cdb1fd",
    "testharness"
   ],
   "webaudio/the-audio-api/the-audioparam-interface/k-rate-delay.html": [
    "b99ace2c8272741e2b61a69b8471b21562d05bbf",
    "testharness"
   ],
   "webaudio/the-audio-api/the-audioparam-interface/k-rate-gain.html": [
    "e4dd622b0e59ec52000f454c35c4d12d70c4102c",
    "testharness"
   ],
   "webaudio/the-audio-api/the-audioparam-interface/k-rate-oscillator.html": [
    "27ef7b81142066b162f7ad3a810ed72755135b3d",
    "testharness"
   ],
   "webaudio/the-audio-api/the-audioparam-interface/k-rate-panner.html": [
-   "8f679c80f0cbd8d91b699e3024eeae9fb9410916",
+   "0a6da33c2aa03a7d34a517c7b52023f3b4178ec5",
    "testharness"
   ],
   "webaudio/the-audio-api/the-audioparam-interface/k-rate-stereo-panner.html": [
    "d393a8c44000c1fd442998e48e70fb090057d0a4",
    "testharness"
   ],
   "webaudio/the-audio-api/the-audioparam-interface/retrospective-exponentialRampToValueAtTime.html": [
    "12e1f35dca3f0b28d421ab39bdb2a98dc18abb3d",
--- a/testing/web-platform/tests/webaudio/the-audio-api/the-audioparam-interface/automation-rate-testing.js
+++ b/testing/web-platform/tests/webaudio/the-audio-api/the-audioparam-interface/automation-rate-testing.js
@@ -1,12 +1,18 @@
 // Test k-rate vs a-rate AudioParams.
 //
 // |options| describes how the testing of the AudioParam should be done:
 //
+//   sourceNodeName: name of source node to use for testing; defaults to
+//                   'OscillatorNode'.  If set to 'none', then no source node
+//                   is created for testing and it is assumed that the AudioNode
+//                   under test are sources and need to be started.
+//   verifyPieceWiseConstant: if true, verify that the k-rate output is
+//                            piecewise constant for each render quantum.
 //   nodeName:  name of the AudioNode to be tested
 //   nodeOptions:  options to be used in the AudioNode constructor
 //
 //   prefix: Prefix for all output messages (to make them unique for
 //           testharness)
 //
 //   rateSettings: A vector of dictionaries specifying how to set the automation
 //                 rate(s):
@@ -37,17 +43,24 @@
 // the the automations did different things, as expected.
 //
 // The promise from |startRendering| is returned.
 function doTest(context, should, options) {
   let merger = new ChannelMergerNode(
       context, {numberOfInputs: context.destination.numberOfChannels});
   merger.connect(context.destination);
 
-  let src = new OscillatorNode(context);
+  let src = null;
+
+  // Skip creating a source to drive the graph if |sourceNodeName| is 'none'.
+  // If |sourceNodeName| is given, use that, else default to OscillatorNode.
+  if (options.sourceNodeName !== 'none') {
+    src = new window[options.sourceNodeName || 'OscillatorNode'](context);
+  }
+
   let kRateNode = new window[options.nodeName](context, options.nodeOptions);
   let aRateNode = new window[options.nodeName](context, options.nodeOptions);
   let inverter = new GainNode(context, {gain: -1});
 
   // Set kRateNode filter to use k-rate params.
   options.rateSettings.forEach(setting => {
     kRateNode[setting.name].automationRate = setting.value;
     // Mostly for documentation in the output.  These should always
@@ -76,26 +89,40 @@ function doTest(context, should, options
       // Most for documentation in the output.  These should never throw.
       let message = `${param.name}.${method.name}(${method.options})`
       should(() => {
         aRateNode[param.name][method.name](...method.options);
       }, options.prefix + ': a-rate node:' + message).notThrow();
     });
   });
 
+  // Connect the source, if specified.
+  if (src) {
+    src.connect(kRateNode);
+    src.connect(aRateNode);
+  }
+
   // The k-rate result is channel 0, and the a-rate result is channel 1.
-  src.connect(kRateNode).connect(merger, 0, 0);
-  src.connect(aRateNode).connect(merger, 0, 1);
+  kRateNode.connect(merger, 0, 0);
+  aRateNode.connect(merger, 0, 1);
 
   // Compute the difference between the a-rate and k-rate results and send
   // that to channel 2.
   kRateNode.connect(merger, 0, 2);
   aRateNode.connect(inverter).connect(merger, 0, 2);
 
-  src.start();
+  if (src) {
+    src.start();
+  } else {
+    // If there's no source, then assume the test nodes are sources and start
+    // them.
+    kRateNode.start();
+    aRateNode.start();
+  }
+
   return context.startRendering().then(renderedBuffer => {
     let kRateOutput = renderedBuffer.getChannelData(0);
     let aRateOutput = renderedBuffer.getChannelData(1);
     let diff = renderedBuffer.getChannelData(2);
 
     // Some informative messages to print out values of the k-rate and
     // a-rate outputs.  These should always pass.
     should(
@@ -108,10 +135,21 @@ function doTest(context, should, options
     // The real test.  If k-rate AudioParam is working correctly, the
     // k-rate result MUST differ from the a-rate result.
     should(
         diff,
         `${
            options.prefix
          }: Difference between a-rate and k-rate ${options.nodeName}`)
         .notBeConstantValueOf(0);
+
+    if (options.verifyPieceWiseConstant) {
+      // Verify that the output from the k-rate parameter is step-wise
+      // constant.
+      for (let k = 0; k < kRateOutput.length; k += 128) {
+        should(
+            kRateOutput.slice(k, k + 128),
+            `${options.prefix} k-rate output [${k}: ${k + 127}]`)
+            .beConstantValueOf(kRateOutput[k]);
+      }
+    }
   });
 }
--- a/testing/web-platform/tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-constant-source.html
+++ b/testing/web-platform/tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-constant-source.html
@@ -1,16 +1,17 @@
 <!doctype html>
 <html>
   <head>
     <title>Test k-rate AudioParam of ConstantSourceNode</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
     <script src="/webaudio/resources/audit-util.js"></script>
     <script src="/webaudio/resources/audit.js"></script>
+    <script src="automation-rate-testing.js"></script>
   </head>
 
   <body>
     <script>
       let audit = Audit.createTaskRunner();
 
       audit.define('ConstantSource k-rate offset', (task, should) => {
         // Arbitrary sample rate and duration.
@@ -20,62 +21,30 @@
         let testDuration = 4 * 128 / sampleRate;
 
         let context = new OfflineAudioContext({
           numberOfChannels: 3,
           sampleRate: sampleRate,
           length: testDuration * sampleRate
         });
 
-        let merger = new ChannelMergerNode(
-            context, {numberOfInputs: context.numberOfChannels});
-        merger.connect(context.destination);
-        let inverter = new GainNode(context, {gain: -1});
-        inverter.connect(merger, 0, 2);
-
-        let kRateNode = new ConstantSourceNode(context);
-        let aRateNode = new ConstantSourceNode(context);
-
-        kRateNode.connect(merger, 0, 0);
-        aRateNode.connect(merger, 0, 1);
-
-        kRateNode.connect(merger, 0, 2);
-        aRateNode.connect(inverter);
-
-        // Set the rate
-        kRateNode.offset.automationRate = 'k-rate';
-
-        // Automate the offset
-        kRateNode.offset.setValueAtTime(0, 0);
-        kRateNode.offset.linearRampToValueAtTime(10, testDuration);
-
-        aRateNode.offset.setValueAtTime(0, 0);
-        aRateNode.offset.linearRampToValueAtTime(10, testDuration);
-
-        kRateNode.start();
-        aRateNode.start();
-
-        context.startRendering()
-            .then(audioBuffer => {
-              let kRateOut = audioBuffer.getChannelData(0);
-              let aRateOut = audioBuffer.getChannelData(1);
-              let diff = audioBuffer.getChannelData(2);
-
-              // Verify that the outputs are different.
-              should(diff, 'Difference between a-rate and k-rate outputs')
-                  .notBeConstantValueOf(0);
-
-              // Verify that the constant source node output is step-wise
-              // constant.
-              for (let k = 0; k < kRateOut.length; k += 128) {
-                should(
-                    kRateOut.slice(k, k + 128),
-                    `k-rate output [${k}: ${k + 127}]`)
-                    .beConstantValueOf(kRateOut[k]);
+        doTest(context, should, {
+          sourceNodeName: 'none',
+          verifyPieceWiseConstant: true,
+          nodeName: 'ConstantSourceNode',
+          prefix: 'k-rate offset',
+          rateSettings: [{name: 'offset', value: 'k-rate'}],
+          automations: [{
+            name: 'offset',
+            methods: [
+              {name: 'setValueAtTime', options: [0, 0]}, {
+                name: 'linearRampToValueAtTime',
+                options: [10, testDuration]
               }
-            })
-            .then(() => task.done());
+            ]
+          }]
+        }).then(() => task.done());
       });
 
       audit.run();
     </script>
   </body>
 </html>
--- a/testing/web-platform/tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-panner.html
+++ b/testing/web-platform/tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-panner.html
@@ -18,44 +18,46 @@
       // params of a biquad.
       //
       // Each entry gives the name of the AudioParam, an initial value to be
       // used with setValueAtTime, and a final value to be used with
       // linearRampToValueAtTime. (See |doTest| for details as well.)
 
       [{name: 'positionX', initial: 0, final: 1000},
        {name: 'positionY', initial: 0, final: 1000},
-       {name: 'orientationX', initial: .1, final: 1000},
-       {name: 'orientationY', initial: .1, final: 1000},
-       {name: 'orientationZ', initial: .1, final: 1000},
+       {name: 'orientationX', initial: 1, final: 10},
+       {name: 'orientationY', initial: 1, final: 10},
+       {name: 'orientationZ', initial: 1, final: 10},
       ].forEach(paramProperty => {
         audit.define('Panner k-rate ' + paramProperty.name, (task, should) => {
           // Arbitrary sample rate and duration.
           let sampleRate = 8000;
-          let testDuration = 1;
+          let testDuration = 5 * 128 / sampleRate;
           let context = new OfflineAudioContext({
             numberOfChannels: 3,
             sampleRate: sampleRate,
             length: testDuration * sampleRate
           });
 
           doTest(context, should, {
+            sourceNodeName: 'ConstantSourceNode',
+            verifyPieceWiseConstant: true,
             nodeName: 'PannerNode',
             // Make the source directional so orientation matters, and set some
             // defaults for the position and orientation so that we're not on an
             // axis where the azimuth and elevation might be constant when
             // moving one of the AudioParams.
             nodeOptions: {
               distanceModel: 'inverse',
               coneOuterAngle: 360,
-              coneInnerAngle: 10,
-              positionX: 10,
-              positionY: 10,
-              positionZ: 10,
-              orientationX: 1,
+              coneInnerAngle: 0,
+              positionX: 1,
+              positionY: 1,
+              positionZ: 1,
+              orientationX: 0,
               orientationY: 1,
               orientationZ: 1
             },
             prefix: `k-rate ${paramProperty.name}`,
             // Just set the frequency to k-rate
             rateSettings: [
               {name: paramProperty.name, value: 'k-rate'},
             ],