[1.1.4] macOS 10.14.5 - Taking a screenshot with SikuliIDE on an external monitor with a Retina primary display

Asked by corn

I have a retina macbook plugged into an external monitor. A normal screenshot from both monitors produces images like this:

Primary:
https://imgur.com/J4C7Fcl

External:
https://imgur.com/w7q19Xl

When I use SikuliIDE's "Take screenshot" functionality, it seems to resize everything in an odd way:

Primary:
https://imgur.com/1ZzqMXT

External:
https://imgur.com/sygNmDc

When running the capture tool, it seems that Sikuli is changing the resolution of my external monitor (possibly halving it?). Is this something that's happening to deal with retina display? Dividing the resolution by 2?

Currently, it's impossible to take a screenshot on the external monitor. I'm also having problems with Sikuli finding anything on the external monitor.

Does Sikuli support a setup that includes a primary retina display with an external non-retina display?

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

SikuliX version?

Revision history for this message
corn (ccabob) said :
#2

I'm running Version 1.1.4 (2019-07-22_15:03 (Build 339)) and Java 11. My external monitor is 2560 x 1440 (QHD/WQHD - Wide Quad High Definition)

It's possible Sikuli doesn't handle the HD external monitor correctly?

Revision history for this message
corn (ccabob) said :
#3

I've been trying to get Sikuli to recognize images on the external monitor, but with no luck. I've done a sample test to see if it could pick up lines of text in a document, but that doesn't work very well either.

https://imgur.com/a/JGDGQyI

Here is the relevant code to test line detection:

```
s = Screen(1)
r = s.grow(-485, -1750, -250, -1000)
r.highlight()

for l in r.collectLines():
    l.highlight()

wait(3)
```

It seems that highlighting the region works correctly, but the actual image that is captured by Sikuli is coming from Screen(0)? It seems to be stitching everything together incorrectly.

I used the "Matching Preview" feature of the IDE and this is how Sikuli is representing the dual monitor setup:

https://imgur.com/a/PjNGxGl

I actually have four documents open. "Document 1", "Document 2", "Document 3", & "Document 4". The first two documents are on Screen(0) and the second two documents are on Screen(1).

You can that documents 1 & 2 are visible from the primary monitor. Document 3, from the second monitor, is only partially visible and document 4, to the right of document 3, is completely out of the view.

Revision history for this message
RaiMan (raimund-hocke) said :
#4

Thanks for reporting.

Confirmed if running with Java 12 (supposing 9, 10, 11 also, but not tested).

When using Java 8, it works as expected.

Not sure, how fast this can be fixed.

Revision history for this message
RaiMan (raimund-hocke) said :
#5

I made it a bug.

Revision history for this message
Jeff Harmon (phototacopodcast) said :
#6

I have a similar issue to the original reporter, though my primary display is the external monitor.

I have a Retina MacbookPro connected to an external display. The external display has a resolution of 2560x1440 but is not treated as Retina by MacOS (Big Sur). I have the dock on the external display, which for Sikuli I believe means it is Screen 0. Sikuli sees Screen 1 as the native screen of the MacBook Pro (Retina) positioned to the left through Display configuration. Here is Screen.showMonitors() from Java using Sikuli API:

*** monitor configuration [ 2 Screen(s)] ***
*** Primary is Screen 0
Screen 0: R[0,0 2560x1440]@S(0)
Screen 1: R[-1680,284 1680x1050]@S(1)
*** end monitor configuration ***

With the configuration this way, I can reliably find images on Screen 0, but the pixel dimensions are so far off on Screen 1 (the Retina screen) I can't reliably do finds. Sikuli API doesn't seem to be capturing things correctly on the Retina screen in this configuration.

See https://github.com/harmonjeff/sikuli-retina-bug/tree/master/FailedCaptureImages

To illustrate the issue I created a test Java application that uses the Sikuli API to capture the screens. I opened up two windows of TextEdit, placing one on each screen. I sized the TextEdit window to cover the entire screen (except the dock on Screen 0). You can see the source here:

https://github.com/harmonjeff/sikuli-retina-bug

In researching what could be going on I discovered a system property that seems to make things function correctly as far as Siklui API capturing and finding images using Java. If I set the "sun.java2d.uiScale" property to be "1.0" then the captures in the sample application function correctly.

https://github.com/harmonjeff/sikuli-retina-bug/tree/master/SuccessCaptureImages

This solution works for me with everything except that my use case for Sikuli API is to drive an application using reference images I capture using Siklui beforehand. Images captured using Siklui on the Retina display do not match well when the application is on the non-Retina screen and vice-versa. I can capture the reference images to be used by the UI automated testing from both but I need to detect if the application is on the Retina screen or the non-Retina screen to know which reference images to use.

The best way I have seen to detect if an application window is on a Retina screen in Java 9+ is in the same code, the isRetina method. The method only works if the system property is not defined. I don't have a way to both detect the application is running in a Retina screen and have the capture/find Sikuli API functions work properly.

Can you help with this problem?

Provide an answer of your own, or ask corn for more information if necessary.

To post a message you must log in.