<ul dir="auto">
<li>Electron version: 1.7.x</li>
<li>Operating system: Windows 10</li>
</ul>
<h3 dir="auto">Expected behavior</h3>
<p dir="auto">You should be able to share any screen connected on the computer, see the content of the screen you selected locally, as well as the other participants.</p>
<h3 dir="auto">Actual behavior</h3>
<p dir="auto">Once you select the screen you want to share on a multi-screen computer running Windows 10, you immediately get a black screen as the local stream when you select some of the screens. The other participants also get a black screen as the remote stream.</p>
<h3 dir="auto">How to reproduce</h3>
<ol dir="auto">
<li>On a Windows 10 computer or VM, with multiple screens connected, start sharing your screen with any Electron-based app. I reproduced the issue with the Symphony client, but also with this one which is fully open source:<br>
$ git clone <a href="https://github.com/jitsi/jitsi-meet-electron/">https://github.com/jitsi/jitsi-meet-electron/</a><br>
$ npm install<br>
$ npm start</li>
<li>Once you select the screen you want to share, you immediately get a black screen as the local stream. The other participants also get a black screen as the remote stream. The issue appears to affect the screens randomly, sometimes the impacted screens are the screens number 2, 4, 6, sometimes after a reboot, 4, 5, 6, etc...</li>
</ol>
<h3 dir="auto">Root cause analysis</h3>
<p dir="auto">At the system level, the way Windows 10 enumerates the screens is slightly different when a virtual video driver is involved.</p>
<p dir="auto">On Electron, the picker window is managed by the DesktopCapturerSource object: <a href="https://github.com/electron/electron/blob/master/docs/api/structures/desktop-capturer-source.md">https://github.com/electron/electron/blob/master/docs/api/structures/desktop-capturer-source.md</a> and the mapping relies on a naming rule <a href="https://github.com/electron/electron/blob/master/atom/browser/api/atom_api_desktop_capturer.cc">https://github.com/electron/electron/blob/master/atom/browser/api/atom_api_desktop_capturer.cc</a> that fails when a non-conventional video driver is involved.</p>
<p dir="auto">At Symphony, we experienced the exact same issue with CEF/Paragon. This is how we fixed the problem of the screen IDs enumeration: <a class="commit-link" href="https://github.com/symphonyoss/SFE-DesktopClient-pgx/commit/85f0d719a11ffa9c03587ebe192b0009a721b7ff#diff-7e750064e4ad7245e99d95316f830119">symphonyoss/SFE-DesktopClient-pgx@<tt>85f0d71</tt>#diff-7e750064e4ad7245e99d95316f830119</a><br>
This fix also addresses a similar issue we had with one monitor, but with Citrix XenDesktop installed (<a href="https://www.citrix.com/products/xenapp-xendesktop/" rel="nofollow">https://www.citrix.com/products/xenapp-xendesktop/</a>), which also alters how Windows enumerates the screens.<br>
FYI, this is how the WebRTC native code that does enumeration: <a href="https://webrtc.googlesource.com/src/+/master/modules/desktop_capture/win/screen_capture_utils.cc" rel="nofollow">https://webrtc.googlesource.com/src/+/master/modules/desktop_capture/win/screen_capture_utils.cc</a></p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/1677767/34426920-971be4e8-ebf0-11e7-916d-53a8dc53fa8a.png"><img src="https://user-images.githubusercontent.com/1677767/34426920-971be4e8-ebf0-11e7-916d-53a8dc53fa8a.png" alt="2017-12-21_18-19-38" style="max-width: 100%;"></a><br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/1677767/34426919-970559e4-ebf0-11e7-9c30-4b3e2d1798aa.png"><img src="https://user-images.githubusercontent.com/1677767/34426919-970559e4-ebf0-11e7-9c30-4b3e2d1798aa.png" alt="2017-12-21_18-18-07" style="max-width: 100%;"></a></p>
<ul dir="auto">
<li>Electron version: 1.7.3 - not sure when this was introduced, works fine in latest production build based on 1.4.15</li>
<li>Operating system: Windows</li>
</ul>
<h3 dir="auto">Expected behavior</h3>
<p dir="auto">I have three screens connected to my computer. <code class="notranslate">desktopCapturer.getSources({types: ['screen']})</code> correctly identifies three sources.</p>
<p dir="auto">I want to share my first screen and set <code class="notranslate">chromeMediaSourceId</code> to the matching id <code class="notranslate">screen:0:0</code> in the constraints when requesting the MediaStream using <code class="notranslate">navigator.mediaDevices.getUserMedia()</code>. I should get a MediaStream containing a video track with the content of the first screen.</p>
<h3 dir="auto">Actual behavior</h3>
<p dir="auto">The stream returned will show the  content of the second screen. If I ask for the second screen, I get the third screen. If I ask for the third screen, I get a black screen.</p>
<h3 dir="auto">How to reproduce</h3>
<p dir="auto"><a href="https://github.com/wireapp/wire-desktop">https://github.com/wireapp/wire-desktop</a></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="git clone https://github.com/wireapp/wire-desktop.git
npm install
npm run prod"><pre class="notranslate"><code class="notranslate">git clone https://github.com/wireapp/wire-desktop.git
npm install
npm run prod
</code></pre></div>
<ul dir="auto">
<li>Log in or create a Wire account. Feel free to connect to me (<a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/gregor/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/gregor">@gregor</a>)</li>
<li>Start audio or video call</li>
<li>Click on share your screen</li>
<li>Select screen to be shared</li>
</ul>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/10243309/27835989-b897f902-60dd-11e7-8dfc-555b4958fc99.png"><img src="https://user-images.githubusercontent.com/10243309/27835989-b897f902-60dd-11e7-8dfc-555b4958fc99.png" alt="electron" style="max-width: 100%;"></a><br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/10243309/27835988-b8943060-60dd-11e7-881c-f3dfdad6cc65.png"><img src="https://user-images.githubusercontent.com/10243309/27835988-b8943060-60dd-11e7-881c-f3dfdad6cc65.png" alt="electron2" style="max-width: 100%;"></a></p>