Skip to content

[Bug]: getUserMedia to get system-wide or window audio capture on Windows errors or terminates renderer #42765

Closed as not planned

Description

@CynicalBusiness

Preflight Checklist

Electron Version

31.1.0

What operating system are you using?

Windows

Operating System Version

Windows 11 Version 23H2

What arch are you using?

x64

Last Known Working Electron version

No response

Expected Behavior

System audio can be accessed with getUserMedia.

Actual Behavior

System audio is inaccessible.

When requesting audio + video from the desktopCapturer docs:

await navigator.mediaDevices.getUserMedia({
  audio: {
    mandatory: {
      chromeMediaSource: 'desktop'
    }
  },
  video: {
    mandatory: {
      chromeMediaSource: 'desktop'
    }
  }
});

I get: DOMException: Could not start audio source (and this error has no stack)

Even if I specify a chromeMediaSourceId to either screen:0:0 or any window, the same error occurs.

When requesting only audio:

await navigator.mediaDevices.getUserMedia({
  audio: {
    mandatory: {
      chromeMediaSource: 'desktop'
    }
  }
});

The entire renderer process is instantly terminated and a message appears from the main process: [48728:0703/162757.047:ERROR:bad_message.cc(29)] Terminating renderer for bad IPC message, reason 263

Testcase Gist URL

No response

Additional Information

My end goal with part of the application is to record system audio; I do not care about video. The solution only needs to work on Windows for now.

I investigated a solution like pulseaudio2 as well, but with Electron lacking a good method to send data streams between main and renderer AFAIK, not sure about that one either.

Activity

  1. moved this to 👀 Unsorted Items in 31-x-yon Jul 3, 2024
  2. CynicalBusiness commented on Jul 4, 2024

    @CynicalBusiness
    Author

    An update:
    In doing some research I saw a mention somewhere that Logitech audio drivers break Chromium's underlying audio engine, so I tried playing with that.

    Turns out, after completely unplugging (not just turning off) my Logitech headset, Electron's audio now works as expected up until I plug it back in, then the error re-appears.

    This headset works in other Electron-powered apps (Discord, Teams, etc.) so I'm unsure why its mere presence breaks my own Electron v31 app if the issue is upstream (unless it's fairly new).

  3. added
    status/confirmed
    on Jul 8, 2024
  4. moved this to 👀 Unsorted Items in 32-x-yon Jul 8, 2024
  5. codebytere commented on Jul 8, 2024

    @codebytere
    Member

    See #41024 (comment)

    There's not much we can do here, sorry 😓

  6. CynicalBusiness commented on Jul 8, 2024

    @CynicalBusiness
    Author

    See #41024 (comment)

    There's not much we can do here, sorry 😓

    I took a look at the comment and the mentioned getUserMedia() function, and while this works to capture a mic or output to a speaker, I can't capture system audio with this otherwise.
    There is getDisplayMedia(), but trying to use this within an electron renderer gives me DOMException: Not supported (and I've tried a bunch of different constraints).

    I can switch to another API, but what is now the supported method for capturing system (either window or whole desktop) video/audio? To enumerate window/screens?

    Edit: would it be setDisplayMediaRequestHandler? I can't seem to get this API to give me window-level audio.

  7. moved this from 👀 Unsorted Items to 👍 Does Not Block Stable in 32-x-yon Jul 10, 2024
  8. moved this from 👀 Unsorted Items to 🛠️ Fixed for Next Release in 31-x-yon Jul 17, 2024
  9. Alpha-T30 commented on Dec 5, 2024

    @Alpha-T30

    An update: In doing some research I saw a mention somewhere that Logitech audio drivers break Chromium's underlying audio engine, so I tried playing with that.

    Turns out, after completely unplugging (not just turning off) my Logitech headset, Electron's audio now works as expected up until I plug it back in, then the error re-appears.

    This headset works in other Electron-powered apps (Discord, Teams, etc.) so I'm unsure why its mere presence breaks my own Electron v31 app if the issue is upstream (unless it's fairly new).

    Did you get any solution for the Logitech device ???

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    31-x-y32-x-ybug 🪲crash 💥status/confirmed

    Type

    No type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions