Electron screen capture not getting the right content with fullscreen window

787 views Asked by At

I'm working in a project for Games Overlay using Electron with desktopCapturer to capture some screenshots from a fullscreen window outside electron. I'm using the default aproach you can find in the Electron documentation:

  • Getting the source with desktopCapturer.getSources();
  • Starting the video stream with navigator.mediaDevices.getUserMedia();
  • Creating a tag and set the video stream using video.srcObject = stream;
  • Drawing the video content in a with ctx.drawImage(video, 0, 0, canvas.width, canvas.height); and exporting it using callback(canvas.toDataURL('image/png'));

It works perfectly in almost all applications, but in this particularly fullscren game i have a problem: It works fine and print the screen correctly UNTIL there is something ABOVE the game window, some examples:

  1. Window menu open via window keyboard key;
  2. Draging another notfullscreen window above it;
  3. Overlay a transparent electron windown above it;

The result on the images generate by the canvas seems to be the last know state before the game is open: sometimes my desktop working area, sometimes another app that was opened at the time, and sometimes the loading screen from the game itself.

The solution i have now is hiding my overlay window before take a printscreen and showint it again after that, but i have to set a 100+- ms timeout to this solution work, and this is causing a ugly flickering in my overlay.

I tested the same code in some other fullscreen games and it worked just fine.

Any thoughts about it? I don't know if the problem could be in Electron or if the game has some window configuration that is causing this.

Thx in advance!

0

There are 0 answers