Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--use-file-for-fake-audio-capture doesn't work on Chrome #5592

Closed
tomoyamachi opened this issue Nov 4, 2019 · 11 comments
Closed

--use-file-for-fake-audio-capture doesn't work on Chrome #5592

tomoyamachi opened this issue Nov 4, 2019 · 11 comments

Comments

@tomoyamachi
Copy link

tomoyamachi commented Nov 4, 2019

Current behavior:

I use --use-file-for-fake-audio-capture for testing getUserMedia behaviour on Chrome.
#4160

But cypress v3.5.0 and v3.6.0, --use-file-for-fake-audio-capture doesn't work it.

Desired behavior:

--use-file-for-fake-audio-capture works on Chrome.

Steps to reproduce: (app code and test code)

// plugins/index.js
module.exports = (on, config) => {
    on('before:browser:launch', (browser = {}, args) => {
        if (browser.name === 'chrome') {
            args.push('--use-fake-device-for-media-stream')
            args.push('--use-fake-ui-for-media-stream')
            args.push('--use-file-for-fake-audio-capture=cypress/fixtures/sample.wav')
        }
        return args
    })
}

and args output

[ '--test-type',
  '--ignore-certificate-errors',
  '--start-maximized',
  '--silent-debugger-extension-api',
  '--no-default-browser-check',
  '--no-first-run',
  '--noerrdialogs',
  '--enable-fixed-layout',
  '--disable-popup-blocking',
  '--disable-password-generation',
  '--disable-save-password-bubble',
  '--disable-single-click-autofill',
  '--disable-prompt-on-repos',
  '--disable-background-timer-throttling',
  '--disable-renderer-backgrounding',
  '--disable-renderer-throttling',
  '--disable-restore-session-state',
  '--disable-translate',
  '--disable-new-profile-management',
  '--disable-new-avatar-menu',
  '--allow-insecure-localhost',
  '--reduce-security-for-testing',
  '--enable-automation',
  '--disable-device-discovery-notifications',
  '--disable-infobars',
  '--autoplay-policy=no-user-gesture-required',
  '--disable-site-isolation-trials',
  '--metrics-recording-only',
  '--disable-prompt-on-repost',
  '--disable-hang-monitor',
  '--disable-sync',
  '--disable-web-resources',
  '--safebrowsing-disable-auto-update',
  '--safebrowsing-disable-download-protection',
  '--disable-client-side-phishing-detection',
  '--disable-component-update',
  '--disable-default-apps',
  '--use-fake-ui-for-media-stream',
  '--use-fake-device-for-media-stream',
  '--disable-ipc-flooding-protection',
  '--disable-backgrounding-occluded-window',
  '--disable-breakpad',
  '--password-store=basic',
  '--use-mock-keychain',
  '--proxy-server=http://localhost:65342',
  '--proxy-bypass-list=<-loopback>',
  '--remote-debugging-port=65349',
  '--use-file-for-fake-audio-capture=cypress/fixtures/sample.wav' ]

I tried to absolute wav file path, but it doesn't work too.

Versions

Cypress v3.5.0, 3.6.0
OS : macOS 10.15
Chrome 78.0.3904.87, 79.0.3945.16

following version worked fine
Cypress v3.4.1
OS : macOS 10.15
Chrome 78.0.3904.87

@cypress-bot cypress-bot bot added the stage: needs investigating Someone from Cypress needs to look at this label Nov 4, 2019
@jennifer-shehane
Copy link
Member

I see the arg reading in the Chrome args output as the same path you specified: --use-file-for-fake-audio-capture=cypress/fixtures/sample.wav

Can you detail what the actual issue is? Is the audio file eventually not playing within the web application? What is the error point?

@cypress-bot cypress-bot bot added stage: needs information Not enough info to reproduce the issue and removed stage: needs investigating Someone from Cypress needs to look at this labels Nov 4, 2019
@IhorPryyma
Copy link

IhorPryyma commented Dec 16, 2019

I'm facing the same issue with MAC Chrome. Did you find a solution?

@AliakseiK
Copy link

AliakseiK commented Dec 18, 2019

Issue reproduced for me as well. --use-file-for-fake-audio-capture doesn't work for 79 version of chrome on Mac OS. Sample audio isn't playing. I verified it on 76 version and works fine. Issue isn't related cypress, it is related to Chrome.

@guest271314
Copy link

guest271314 commented Dec 31, 2019

To output audio to speakers when using --use-fake-file-for-audio-capture flag try using AudioContext MediaStreamAudioSourceNode or HTML <audio> element

navigator.mediaDevices.getUserMedia({audio: true})
.then(stream => {
  const audio = new Audio();
  audio.autoplay = true;
  audio.srcObject = stream;
});
navigator.mediaDevices.getUserMedia({audio: true})
.then(mediaStream => {
  const ac = new AudioContext();
  const source = ac.createMediaStreamSource(mediaStream);
  source.connect(ac.destination);
});

Command line

chromium-browser --allow-file-access-from-files --autoplay-policy=no-user-gesture-required --use-fake-device-for-media-stream --use-fake-ui-for-media-stream --use-file-for-fake-audio-capture=$HOME/test.wav%noloop --user-data-dir=$HOME/test 'file:///home/user/testUseFileForFakeAudioCaptureChromium.html'

Tested at Chromium 80.0.3987.7 (32-bit) *nix (both file: protocol and launching Chromium point to "https://github.com" and running the code at console).

To test download attached .txt file, save as .html, adjust paths at above command.

testUseFileForFakeAudioCaptureChromium.txt

@tomoyamachi
Copy link
Author

Sorry for the late reply.
It looks fail to play audio. But there is no error logs.

BTW, I ran @guest271314's scripts on Mac, and I got error message.
I put test.wav to a target path, but fail to read it.

$ /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --version

Google Chrome 79.0.3945.88

$ /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
  --allow-file-access-from-files \
  --autoplay-policy=no-user-gesture-required \
  --use-fake-device-for-media-stream \
  --use-fake-ui-for-media-stream \
  --use-file-for-fake-audio-capture=$HOME/test/test.wav \
  --user-data-dir=$HOME/test/data \
  file://$HOME/test/testUseFileForFakeAudioCaptureChromium.html

[39131:86787:0104/000139.036863:ERROR:simple_sources.cc(30)] Failed to read /Users/xxxx/test/test.wav as input to the fake device.

@guest271314
Copy link

Can you upload the wav file that you are testing here or print the output of mediainfo test.wav or mkvmerge -J test.wav? The path to the file or URL to load should be a string.

@davidhennemann
Copy link

I think its an issue with chromium and not cypress. I created a bug report in their issue tracker.

https://bugs.chromium.org/p/chromium/issues/detail?id=1032604

@jennifer-shehane
Copy link
Member

Since this issue hasn't had activity in a while, we'll close the issue until we can confirm this is still happening. Please comment if there is new information to provide concerning the original issue and we'd be happy to reopen.

@jennifer-shehane jennifer-shehane removed the stage: needs information Not enough info to reproduce the issue label Feb 3, 2021
@andreieftimie
Copy link

Did anyone manage to get this working (found some workaround)?

@loszer
Copy link

loszer commented Mar 2, 2021

according to
https://bugs.chromium.org/p/chromium/issues/detail?id=1032604#c37
plugin/index.js add chrome args "--no-sandbox"
demo code:

on('before:browser:launch', (browser = {}, launchOptions = { args: [] }) => {
    if (browser.name === 'chrome') {
      // https://bugs.chromium.org/p/chromium/issues/detail?id=1032604#c37
      launchOptions.args.push('--no-sandbox')
      launchOptions.args.push('--allow-file-access-from-files')
      launchOptions.args.push('--use-fake-ui-for-media-stream')
      launchOptions.args.push('--use-fake-device-for-media-stream')
      // mp3 not work
      launchOptions.args.push('--use-file-for-fake-audio-capture=tests/fixtures/hello.wav')
    }
    return launchOptions
  })

@mattrussell-sonocent
Copy link

@loszer Adding --no-sandbox worked a treat for us, thanks for sharing the workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants