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

[Feature Request]: Expose setDisplayMediaRequestHandler disable_local_echo flag to enable audio output during recording #37293

Closed
3 tasks done
theogravity opened this issue Feb 16, 2023 · 0 comments · Fixed by #37315

Comments

@theogravity
Copy link
Contributor

theogravity commented Feb 16, 2023

Preflight Checklist

Problem Description

  • We want to record the electron browser window for both audio and video.
  • The BrowserWindow instance loads an external URL, which calls window.navigator.mediaDevices.getDisplayMedia() at some point.
  • We've attached a handler to setDisplayMediaRequestHandler() in our preload, which returns the following: callback({ video: source, audio: mainBrowser.webContents.mainFrame });
    • The video source is obtained through desktopCapturer, but I don't think that has anything to do with this bug.
  • When we assemble the stream to the MediaRecorder and perform recording, the browser window loses audio output when the recording starts, and resumes output when the recording stops.
  • The recording itself properly records video and any audio made from the window during that time.

After a lot of investigation, I noticed a flag here in the PR that implements setDisplayMediaRequestHandler() (#30702):

shell/browser/electron_browser_context.cc

    } else if (result_dict.Get("audio", &rfh)) {
      devices.audio_device = blink::MediaStreamDevice(
          request.audio_type,
          content::WebContentsMediaCaptureId(rfh->GetProcess()->GetID(),
                                             rfh->GetRoutingID(),
                                             /* disable_local_echo= */ true)

And thought disable_local_echo might control audio loopback behavior.

I compiled a custom version of electron with that flag set to false and repeated the above steps, which correctly allowed audio to come through the speakers while recording was happening. The recording itself retained video and audio.

I am on an M2 Mac running Ventura 13.2.1.

(I have zero C++ experience and just used intuition to find this while looking at the PR for setDisplayMediaRequestHandler and followed the electron build guides to test my hypothesis.)

Proposed Solution

May I ask that an option be exposed for setDisplayMediaRequestHandler that controls the value of that particular flag? Or, have the option be part of the callback for the handler.

Alternatives Considered

Have not discovered any alternatives. Literature around setDisplayMediaRequestHandler is limited as it's a recently-released feature.

Additional Information

This bug ticket describes the behavior we experienced, although the context is a bit different (It references getUserMedia and chrome.tabCapture.

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

@theogravity theogravity changed the title [Feature Request]: Expose setDisplayMediaRequestHandler disable_local_echo flag to enable audio output [Feature Request]: Expose setDisplayMediaRequestHandler disable_local_echo flag to enable audio output during recording Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant