Skip to content

Crazy region based screenshot behavior on macOS #194

@svettwer

Description

@svettwer

Version
next

Short overview
Screenshots based on Regions on macOS are do not reflect screen content.

Issue occurs on

  • Virtual machine
  • Docker container
  • Dev/Host system

Detailed error description
I'm using the following workaround from #154 to create a screenshot of a region

  const regionCapture = async (
    selectedRegion: NutRegion,
    outputFilename: string
  ) => {
    const regionImage = await (<any>screen).vision.grabScreenRegion(
      selectedRegion
    );
    await (<any>screen).vision.saveImage(regionImage, outputFilename);
  };

Based on the provided region, I receive various errors or incorrect images.
I'm working on a 1920x1080 build agent and configured it as described here.

with new NutRegion(0, 100, 650, 200) I get:
ocr-screenshot

with new NutRegion(0, 50, 325, 100) I get:
ocr-screenshot
Just thought a reduction of the resolution could help.

with new NutRegion(0, 0, 1900, 1000) I get:

[Wed Dec 09 2020 13:04:35 GMT+0000 (Coordinated Universal Time)] ERROR: Error in testcase getTextFromRegion: Error: Given width exceeds display dimensions
Error: Error: Given width exceeds display dimensions
    at Object.module.exports.screen.capture (/Users/runner/work/sakuli-ocr/sakuli-ocr/packages/sakuli-ocr/node_modules/@nut-tree/libnut-darwin/index.js:32:16)
    at /Users/runner/work/sakuli-ocr/sakuli-ocr/packages/sakuli-ocr/node_modules/@nut-tree/nut-js/dist/lib/provider/native/libnut-screen-action.class.js:30:46
    at new Promise (<anonymous>)
    at ScreenAction.grabScreenRegion (/Users/runner/work/sakuli-ocr/sakuli-ocr/packages/sakuli-ocr/node_modules/@nut-tree/nut-js/dist/lib/provider/native/libnut-screen-action.class.js:29:16)
    at VisionAdapter.grabScreenRegion (/Users/runner/work/sakuli-ocr/sakuli-ocr/packages/sakuli-ocr/node_modules/@nut-tree/nut-js/dist/lib/adapter/vision.adapter.class.js:43:28)

Whole screen
Funny enough, when I take a screenshot with grabScreen, it looks as expected.
2020-12-09T13-22-21_error_e2e-suite_getTextFromRegion

Steps to reproduce error
As this happens on a build agent and because I've no mac myself, I cannot provide any information, unfortunately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    wontfixThis will not be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions