web-platform-tests / wpt

Test suites for Web platform specs — including WHATWG, W3C, and others
https://web-platform-tests.org/
Other
4.89k stars 3.06k forks source link

Intermittent wpt-chrome-dev-stability audioworkletnode-output-channel-count.https.html FAIL X The expected output channel count is not equal to 17. Got 1 #20646

Open karlt opened 4 years ago

karlt commented 4 years ago

e.g. https://community-tc.services.mozilla.com/tasks/LjF7rW4JQzGDF14Q6PP3bA

 0:25.30 INFO | `/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-output-channel-count.https.html` | `  The expected output channel count is equal to 17.`                                                     | **PASS: 9/10, MISSING: 1/10** |                                        |
 0:25.30 INFO | `/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-output-channel-count.https.html` | `< [Dynamically change the channel count to if unspecified.] All assertions passed. (total 1 assertions)` | **PASS: 9/10, MISSING: 1/10** |                                        |
 0:25.30 INFO | `/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-output-channel-count.https.html` | `# AUDIT TASK RUNNER FINISHED: 2 tasks ran successfully.`                                                 | **PASS: 9/10, MISSING: 1/10** |                                        |
 0:25.30 INFO | `/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-output-channel-count.https.html` | `X The expected output channel count is not equal to 17. Got 1.`                                          | **FAIL: 1/10, MISSING: 9/10** | `assert_true: expected true got false` |
 0:25.30 INFO | `/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-output-channel-count.https.html` | `< [Dynamically change the channel count to if unspecified.] 1 out of 1 assertions were failed.`          | **FAIL: 1/10, MISSING: 9/10** | `assert_true: expected true got false` |
 0:25.30 INFO | `/webaudio/the-audio-api/the-audioworklet-interface/audioworkletnode-output-channel-count.https.html` | `# AUDIT TASK RUNNER FINISHED: 1 out of 2 tasks were failed.`                                             | **FAIL: 1/10, MISSING: 9/10** | `assert_true: expected true got false` |

IIUC Chrome's implementation can allow ChannelCountProcessor.process() to be called between AudioWorkletNode construction and connection and the subsequent start() on the connected source. This would be spec compliant but ChannelCountProcessor.process() would then find channel counts of 1 because source has not yet started and so is not actively processing. i.e. I think the problem is in the test.

(I guess I need to reference the pull request conversation to link the records.)

guest271314 commented 4 years ago

One issue appears to be

await context.audioWorklet.addModule('channel-count-processor.js')

is not executed for the second test?

<!DOCTYPE html>
<html>

<head>
  <title>
    Test the construction of AudioWorkletNode with real-time context
  </title>
</head>

<body>
  <script id="layout-test-code">
    const context = new AudioContext();
    (async function() {
      Promise.all([
          new Promise(async resolve => {
            await context.audioWorklet.addModule(
              'channel-count-processor.js');
            // Test if the output channe count dynamically changes if the input
            // and output is 1.
            //audit.define(
            //    {label: 'Dynamically change the channel count to if unspecified.'},
            //    (task, should) => {
            // Use arbitrary parameters for the test.
            const buffer = new AudioBuffer({
              numberOfChannels: 17,
              length: 1,
              sampleRate: context.sampleRate,
            });
            const source = new AudioBufferSourceNode(context);
            source.buffer = buffer;
            const node = new AudioWorkletNode(context, 'channel-count', {
              numberOfInputs: 1,
              numberOfOutputs: 1,
            });
            node.port.onmessage = (message) => {
              const expected = message.data;
              resolve([expected.outputChannel, 'The expected output channel count is 17']) // 17
            };
            // We need to make an actual connection becasue the channel count
            // change happen when the rendering starts. It is to test if the
            // channel count adapts to the upstream node correctly.
            source.connect(node).connect(context.destination);
            source.start();
          }),
          //   });
          // Test if outputChannelCount is honored as expected even if the input
          // and output is 1.
          //audit.define(
          //    {label: 'Givien outputChannelCount must be honored.'},
          //    (task, should) => {
          new Promise(async resolve => {
            await context.audioWorklet.addModule(
              'channel-count-processor.js');
            const node = new AudioWorkletNode(
              context, 'channel-count', {
                numberOfInputs: 1,
                numberOfOutputs: 1,
                outputChannelCount: [2],
              });
            node.port.onmessage = (message) => {
              const expected = message.data;
              resolve([expected.outputChannel, 'The expected output channel count 2']) // 2
                // task.done();
            };
            // We need to make an actual connection becasue the channel count
            // change might happen when the rendering starts. It is to test
            // if the specified channel count is kept correctly.
            node.connect(context.destination);
          })
        ]).then(([
          [a],
          [b]
        ]) => console.log(a === 17 && b === 2, {
          a, b
        }))
        //audit.run();
    })();
  </script>
</body>
</html>