bencevans / screenshot-desktop

💻 Capture a screenshot of your local machine
https://www.npmjs.com/package/screenshot-desktop
437 stars 91 forks source link

Getting Error: No Displays Detected try dropping screen option #171

Open NirmanSonawane opened 4 years ago

NirmanSonawane commented 4 years ago

Describe the bug In Mac os 10.15.5, when i call screenshot({ format: 'png', filename: path.join('check.png') }) I am getting Error: No Displays Detected try dropping screen option

Expected behavior The screenshot should get captured

Screenshots system_profiler SPDisplaysDataType; output

Screenshot 2020-08-26 at 12 02 10 PM

Environment (please complete the following information):

Additional context Add any other context about the problem here.

bencevans commented 4 years ago

Hi @NirmanSonawane have you given it the Mac permission https://github.com/bencevans/screenshot-desktop/issues/156#issuecomment-583008800

NirmanSonawane commented 4 years ago

Hi @NirmanSonawane have you given it the Mac permission #156 (comment)

yes

NirmanSonawane commented 4 years ago

In my other machine, it is getting captured, the only difference is that in the machine in which it is not working the system_profiler SPDisplaysDataType output has no display params and the one in which it is working has display info I am not able to figure out why

bencevans commented 4 years ago

:thinking: Hmmm, I'm really not sure. From a quick browse I can only find this StackExchange question that has some familiarity to this issue and a suggestion that the graphics card needs to be replaced and 'Apple increased the warranty on the graphics card because of a too high number of failures on the specific card' - https://apple.stackexchange.com/questions/12366/graphic-cards-issue

bencevans commented 4 years ago

@NirmanSonawane did you find anything further?

NirmanSonawane commented 4 years ago

@NirmanSonawane did you find anything further?

Nope, I had to remove the main display detection code and directly execute the screencapture process For now, it works for me, will have to check with multiple displays attached though

quentinwendegass commented 3 years ago

Hey, I'm running into the same issue where no physical screen is connected to our Mac mini. We use a HDMI dummy plug to simulate a connected display so the GPU isn't throttled, but system_profiler SPDisplaysDataType doesn't return any displays unfortunately with this plug. When I use the screencapture tool directly I can take a screenshot without problems.

Maybe an option could be added to ignore how many screens are available and just try to execute the screencapture command? Or maybe this could be the default behavior when no screens are available (not sure which implications that would have)?

ArtemAvramenko commented 2 years ago

@bencevans I have tested all possible scenarios with and without physical displays enabled, with one and two monitors, via VNC, and via Chrome Remote Desktop. When a monitor is connected, gpu.Displays returns it in the list.

With remote access and physical monitors unplugged, this method returns nothing. This problem became especially critical after office workers switched to remote work.

Nevertheless, capturescreenshot works if you specify a single file name. So it will be enough just to add a fallback:

if (displayinfos.length === 0) {
  displayinfos.push({ name: 'Remote', primary: true })
}