question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Firefox Web Audio API is not working properly in docker image since v1.24.0-focal

See original GitHub issue

Context:

  • Playwright Version: from v1.24.0 to v1.27.1
  • Operating System: Linux
  • Node.js version: v16.16.0 - v16.17.1
  • Browser: Firefox
  • Extra: The bug only occurs i in the official docker images from mcr.microsoft.com/playwright:v1.24.0-focal to mcr.microsoft.com/playwright:v1.27.1-focal

Code Snippet

Help us help you! Put down a short code snippet that illustrates your bug and that we can run and debug locally. For example:

import { test, expect } from '@playwright/test';

test('web audio', async ({ page }) => {
  const detected = await page.evaluate(async () => {
    const context = new AudioContext();
    const oscillator = new OscillatorNode(context, {type: 'square', frequency: 1000});
    const analyser = new AnalyserNode(context);
    oscillator.connect(analyser);
    oscillator.start();

    const buffer = new  Float32Array(analyser.fftSize);

    const THRESHOLD = 1 / 32767;
    const verifySamples = () => {
      const first = buffer[0] ?? 0;
      const last = buffer[buffer.length - 1] ?? 0;
      return ((Math.abs(first) > THRESHOLD) && Math.abs(last) > THRESHOLD);
    };

    const result = await new Promise<boolean>(resolve => {
      const intervalId = setInterval(() => {
        analyser.getFloatTimeDomainData(buffer);
        if (verifySamples()) {
          clearInterval(intervalId);
          clearTimeout(timeoutId);
          resolve(true);
        }
      }, 50);
      const timeoutId = setTimeout(() => {
        clearInterval(intervalId);
        analyser.getFloatTimeDomainData(buffer);
        resolve(verifySamples());
      }, 5000);
    });

    await context.close();

    return result;
  });

  expect(detected).toBeTruthy();
});

Describe the bug Since the docker image upgrade from v1.24.0, Firefox fails to get audio data with web audio API inside the container as shown above. It works as expected in mcr.microsoft.com/playwright:v1.23.4-focal, and it works properly when not using the docker image.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
skyuplamcommented, Oct 21, 2022

@aslushnikov Oh, thanks for your quick response and I have just tried it and it works when I installed the pulseaudio and started it.

0reactions
skyuplamcommented, Nov 9, 2022

@aslushnikov really appreciated for your reply. We use Web Audio APIs a lot test test audio related parts of our app, and would like to avoid the complications of setting up PulseAudio for testing the app with Firefox. I would really appreciate if you can post some updates (if any) of your findings from the mozilla folks. 🙇🏻‍♂️

Read more comments on GitHub >

github_iconTop Results From Across the Web

[BUG] Firefox Web Audio API is not working properly in docker ...
[BUG] Firefox Web Audio API is not working properly in docker image since v1.24.0-focal.
Read more >
Fix common audio and video issues | Firefox Help
Sometimes, the video or audio content in a web page cannot be properly downloaded or played in Firefox. This article will help you...
Read more >
Web Audio API not loading in Firefox 59 - Stack Overflow
I have written a code in ReactJS front end to play an audio file. It was working earlier but now I have hit...
Read more >
firefox audio · Issue #410 · jessfraz/dockerfiles - GitHub
The fix from #376 seems to be unrelated. If I add pulseaudio client library libpulse0 to jess/firefox , I can set up a...
Read more >
playwright - bytemeta
[Feature] Allow to skip tests by their name and file path ... [BUG] Firefox Web Audio API is not working properly in docker...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found