foundryvtt / foundryvtt

Public issue tracking and documentation for Foundry Virtual Tabletop - software connecting RPG gamers in a shared multiplayer environment with an intuitive interface and powerful API.
https://foundryvtt.com/
202 stars 10 forks source link

Audio/Video communication was unable to start because one of the configured input devices was unavailable #4197

Closed aaclayton closed 2 years ago

aaclayton commented 3 years ago

Originally in GitLab by @ibelimb

Environment Details

Please share the following basic details about your setup.

Issue Description

I am getting the error "Audio/Video communication was unable to start because one of the configured input devices was unavailable." I previously had it working on version 0.6.6. From what I can see, it does not appear the Foundry is even requesting access to the devices from the browser. If I do not force mic/camera permissions in Firefox, going into Foundry's settings shows "Default Device" and "Unknown Device" as my choices. If I force Firefox to allow Foundry access to the mic/camera, the correct device names show up instead of "Unknown Device" but the "Audio/Video communication was unable to start because one of the configured input devices was unavailable." error still shows. No errors in the web console or debug/error logs on the server.

I have attempted the following fixes:

aaclayton commented 2 years ago

Originally in GitLab by @fyorl

This might have been resolved by the fix for #5468.

aaclayton commented 2 years ago

Originally in GitLab by @ihillway

As a layperson reading all of this I found it incredibly helpful, thank you everyone. Potential fixes through editing Foundry files or future fixes aside, I found a quick immediate fix was to install a virtual camera, after which the "Audio/Video communication was unable to start because one of the configured input devices was unavailable" error goes away completely for me.

I downloaded an older version of ManyCam from back when it was free (version 2.6.1) here and it solved the issue.

aaclayton commented 3 years ago

Originally in GitLab by @bekit

I realized that my fixes still had some cases where audio or video tracks wouldn't work and it would refuse to create either. I ended up taking some of the logic from older versions of Foundry and trying to load audio and video separately if both didn't work. The new logic in the jitsi module is here: JitsiRTCClient._initializeLocal

aaclayton commented 3 years ago

Thanks @nyatto I can evaluate pulling that provided fix forward into a sooner update if there is a known resolution to this issue that can be explored.

aaclayton commented 3 years ago

Originally in GitLab by @nyatto

I can confirm this issue happens when you don't have a video camera.

I can also confirm that applying @bekit's patch to the following function in foundry.js resolves the issue.

 /* -------------------------------------------- */

  /**
   * Create an open a local stream when initially connecting to the server.
   * This local stream becomes the "master" stream which tracks your own device inputs.
   * The master stream is cloned to provide a stream to every connected peer.
   * @private
   */
  async _openLocalStream(audioSrc, videoSrc, temporary=false) {

    // Close an already opened stream
    const streamName = temporary ? "temporary" : null;
    this._closeLocalStream(temporary);
    const settings = this.settings.getUser(game.user.id);

    // Handle missing video device
    const videoSources = await this.getVideoSources();
    if (Object.entries(videoSources).length === 0 || (videoSrc !== "default" && !(videoSrc in videoSources))) {
      videoSrc = null;
    }

    // Handle missing audio device
    const audioSources = await this.getAudioSources();
    if (Object.entries(audioSources).length === 0 || (audioSrc !== "default" && !(audioSrc in audioSources))) {
      audioSrc = null;
    }

    // Configure data channels
    easyrtc.enableDataChannels(false);
    easyrtc.enableAudio(audioSrc != null);
    easyrtc.enableVideo(videoSrc != null);
    ...
aaclayton commented 3 years ago

Originally in GitLab by @bekit

I'm not sure if this helps, but I had to solve this problem with the JitsiRTC module as well. This is the change that I put in place at the time to resolve it for us: https://github.com/luvolondon/fvtt-module-jitsiwebrtc/pull/43

aaclayton commented 3 years ago

Originally in GitLab by @foresto

Same problem here, with both Firefox and Chromium on linux:

If no camera is present on the host machine, Foundry shows the "Audio/Video communication was unable to start because one of the configured devices was unavailable" popup. The browser doesn't prompt for mic or camera access at all, and Foundry shows no floating window to represent my presence in a conference. The problem occurs even when A/V Conferencing Mode is "Audio Only" and Video Capture Device is "Disable Sending Camera", and with no modules enabled.

Reproduced with Foundry 0.7.7 and 0.7.8.

If I plug in a camera, the problem goes away, and I can finally use voice chat.

Other WebRTC apps ( https://letsmeet.no/ https://meet.jit.si/ ) work just fine with no camera attached, so surely there must be a way to fix this.

aaclayton commented 3 years ago

Originally in GitLab by @ibelimb

That is correct Andrew. Now that I think about it, we should test to see if the issue is present on 0.6.6 now, as that would indicate it was a change in the browser not Foundry itself. I will attempt this later today unless someone else beats me to it.

aaclayton commented 3 years ago

Interesting feedback. This may be a little tricky - the software doesn't know what devices are (or are not) available until after it has asked the browser for permission to access them. The reason it asks permission for the camera is because it must first ask permission in order to discover whether there is a camera available. Once permission has been granted to the browser, it will be able to discover the list of devices which can be used.

Am i understanding the issue correctly that the software does not prompt for permission to access devices at all (including audio only) if there is no camera device present on the system?

aaclayton commented 3 years ago

Originally in GitLab by @j-frost

Just confirmed this. Macbook and Chromebook have webcams built in. When I attached a USB cam to the Windows 10 machine, both Chrome and Firefox suddenly asked for Cam + Mic permissions, and when I gave them, setup worked as normal.

So a known workaround for now is to just make any camera available so that Foundry can ask for one.

aaclayton commented 3 years ago

Originally in GitLab by @ibelimb

I came across this comment from Crusatyr on the Discord, where he said he had a similar issue and was able to resolve it by giving Foundry access to a camera. I do not normally have my camera plugged in, and did not have a camera setup when I was having this issue.

I just tried plugging in my webcam, and sure enough the permissions prompt came up in Firefox and I was able to use the microphone. So it seems the problem is that Foundry is attempting to ask for both a camera and microphone even if no camera is present on the device (this seems to happen regardless of whether "Audio only" is selected in the settings).

EDIT: I should also add that I did not have a camera plugged in when I was using 0.6.6 and the permissions worked properly. So I'm guessing the issue was caused by a change to the audio/video setup during 0.6.6 - 0.7.7.

aaclayton commented 3 years ago

Originally in GitLab by @j-frost

@aaclayton if you'd like to collect additional data, we can schedule a screen sharing session if that's convenient for you.

aaclayton commented 3 years ago

I'll reopen this and shift it to the 0.8.1 milestone where I have planned to look at audio-related improvements. I don't know how to address this problem though.

aaclayton commented 3 years ago

Originally in GitLab by @j-frost

I'm not entirely sure what you mean by fallback device since I couldn't find a setting with that exact name in Windows. I'm not a Windows power user. But I do have a bunch of audio output devices available:

image

The list in foundry looks like this:

image

Number of devices doesn't match up (there's a bunch more for monitor speakers etc).

aaclayton commented 3 years ago

Originally in GitLab by @ibelimb

On my device I have two devices, a primary and what I would assume would be a fallback. But as I stated in the original issue, I don't think this is a problem with there being no fallback, it's that the web browser isn't getting asked to use the microphone. Both devices show up as Unknown because the browser hasn't given Foundry permission to access the devices.

Normally you would login to Foundry, Firefox would ask for permission and what device to let the website use, and then Foundry would have access to the microphone. What happens now is I login to Foundry and Firefox does not prompt for microphone permissions at all.

aaclayton commented 3 years ago

Is there a fallback device available if your preferred device is unavailable? Or is it a situation where your preferred device is the only device and removing it leaves no available devices?

aaclayton commented 3 years ago

Originally in GitLab by @j-frost

Hey @aaclayton can we revisit this? I'm having the same issue as is one of my players. Google Chrome and Firefox on Windows 10 both. Interestingly, this doesn't happen when connecting from a Chromebook or a Macbook, or even my Pixel phone.

What other information might be helpful for debugging this issue?

aaclayton commented 3 years ago

I tried to reproduce this issue in Firefox by configuring A/V to use my preferred devices (peripherals). Then I disconnected one of those peripherals at a time and observed that the software correctly fell-back to the default device:

For example, with microphone unplugged:

image

Or with the webcam unplugged:

image

The steps I followed precisely to try and reproduce this issue were:

  1. Open Foundry VTT in Firefox.
  2. Configure the website to be allowed for the Use the Camera and Use the Microphone permissions.
  3. Configure A/V settings to assign my preferred devices.
  4. Refresh Foundry VTT to confirm everything was working properly with preferred devices available.
  5. Unplug one of those devices.
  6. Refresh Foundry VTT, observe that the unplugged device has fallen back to the default device and A/V started successfully.

I am going to close this issue as nonrepro, but @ibelimb if you have more information or precise reproduction steps that verifies this bug please feel free to reopen with more evidence.