electron: [Bug]: `desktopCapturer.getSources` does not return the Electron window (on Windows)
Preflight Checklist
- I have read the Contributing Guidelines for this project.
- I agree to follow the Code of Conduct that this project adheres to.
- I have searched the issue tracker for a bug report that matches the one I want to file, without success.
Electron Version
21.1.1
What operating system are you using?
Windows
Operating System Version
Windows 11 Home 10.0.22000
What arch are you using?
x64
Last Known Working Electron version
18.0.0-alpha.5
Expected Behavior
This code:
const sources = await desktopCapturer.getSources({ types:['window'] })
console.log('sources:', sources.map(s => s.name))
Should print the names of all the windows you have open, including the window for the Electron application. We were using this functionality to allow users to record their screen while using our application.
Actual Behavior
getSources
returns all of the windows except the window of the Electron application. This issue affects Windows. macOS is not affected. Have not tested on Linux.
Testcase Gist URL
https://gist.github.com/srmagura/b0725ae0d9488e97d665a78daf768729
Additional Information
I did a bisection through Electron Fiddle and found that this broke between 18.0.0-alpha.5 and 18.0.0-beta.1. Here is the range of commits that Electron Fiddle produced when the bisection was completed.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 3
- Comments: 16 (2 by maintainers)
find a workaround for this issue:
Why hasn’t there been an official fix for this problem?
Still have this issue on Electron 26 under Windows. Anyone know how to accomplish this when using
webContents.session.setDisplayMediaRequestHandler()
? The main issue is I can’t use the media source id since the callback looks like this:callback({ video: source, audio: mainBrowser.webContents.mainFrame, enableLocalEcho: true });
Edit:
The following seems to have worked for me:
@frank-niu-github I do not have a fix for it. Waiting for the Electron team to fix it. 🤞