[Linux] Screen goes black when trying to take a screenshot using sikulix IDE

Asked by Akshay T P

accepted bug ---- follow up on GitHub: https://github.com/RaiMan/SikuliX1/issues/568
----------------------------------------------------

Problem:
Screen goes black when trying to take a screenshot using sikulix IDE on Redhat 8.6

sikulix version: 2.0.4
I have launched sikulix IDE using "java -jar sikulixide-2.0.4.jar" command.
Trying to take a screen shot. But when I click on the button screen goes black completely and a text on top of it in white colour which says "Select an Image". that text disappears after sometime.

I have tried to capture the screen using below code and that output also complete black image.

screen = Screen()
scr_img = screen.capture(screen.getBounds())
scr_img.save("<path>","test")

Please help here.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Jakob Heiden (entengummitiger) said :
#2

I have the same issue with Ubuntu 22.04.1

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

Please try with 2.0.5 or even 2.0.6-snapshot.

Java should be 11 or 17 (LTS versions).

Revision history for this message
Jakob Heiden (entengummitiger) said (last edit ):
#4

Sorry, I should have specified, I have the issue with 2.0.5, both on Java 11 and Java 17.
I cannot find a download for 2.0.6, it appears that currently nightly build downloads are disabled...?

Another, likely related issue: if I try to use Matching Preview, it will display a black background and a loading icon that spins forever.

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

The snapshots are here:

https://github.com/RaiMan/SikuliX1

Revision history for this message
Jakob Heiden (entengummitiger) said :
#6

I tried with the August 17th, 2022 release of 2.0.6, both on java 11 and 17 still the same issue

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

ok. sorry.

I have to setup a new Ubuntu dev environment, which will take some time.

Did not ask about your screen setup: pls try with only one system screen.
Is it native Ubuntu or some virtual setup?

Revision history for this message
Jakob Heiden (entengummitiger) said :
#8

Thank you for developing this thing and looking into this bug.

Issue persists with only one display.

This is a very recent install of native Ubuntu

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

I now have a native install of Ubuntu 22.04 and can confirm the situation.

The reason behind is a known Java Robot problem with the new Wayland DisplayServerProtokoll (instead of classic Xorg).
This problem is still there in Java 19.

Have a look into the post on GitHub for a workaround:
https://github.com/RaiMan/SikuliX1/issues/568

Revision history for this message
Akshay T P (tpakshay) said :
#10

My issue resolved after changing $XDG_SESSION_TYPE in my machine,

Please find the steps I have done,

1. check which display system your ubuntu using
     echo $XDG_SESSION_TYPE

If above command outputs "wayland" then your system is using wayland.

To use screensharing we have to disable wayland and enable xorg(x11).

2. Open /etc/gdm3/custom.conf and uncomment below line,
   WaylandEnable=false
save the changes and reboot your system.

3, do. echo $XDG_SESSION_TYPE and it should display x11.

Now launch sikuli IDE and try to take snapshots, It should work.

Thanks,
Akshay

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

@Akshay T P
Thanks for the confirmation and the additional info
I will add a startup-check and some info how to handle the situation.

follow up is on Github:
https://github.com/RaiMan/SikuliX1/issues/568

Revision history for this message
RaiMan (raimund-hocke) said :
#12
Revision history for this message
Jakob Heiden (entengummitiger) said :
#13

I used the workaround described in #9 and everything works fine now. Thank you

Revision history for this message
Pedro Henrique dos Santos Gonçalves (phgon) said :
#14

Hello, I'm having a similar problem to the item above. But with some differences.

I'm using Ubuntu 18.04 with windows wls.
I have already executed the commands,

sudo apt-get install xorg openbox,
sudo apt-get install gdm3.

The echo $XDG_SESSION_TYPE command is returning empty.

What's missing from my linux.