RaiMan / SikuliX-2014

SikuliX version 1.1.2 (until February 2018)
http://sikulix.com
806 stars 235 forks source link

xvfb-run runsikulix fails at wmctrl #305

Open taylordowns2000 opened 6 years ago

taylordowns2000 commented 6 years ago

I've got a working installation of sikulix 1.1.1 and have been developing a script that runs successfully on Ubuntu 16.04. Recently, I've tried to get the same script running on either a standard xvfb display, or using xvfb-run runsiklix -r my_script.sikuli --args state.json (the latter being preferable for our implementation) but I'm getting this "Hoping for the best error" message. I paired down the script to something very simple and testable, and still can't get it working with xvfb.

Here is the script:

import json
import shutil
import sys.argv

with open(sys.argv[1]) as json_data:
    d = json.load(json_data)
type("t", Key.CTRL + Key.ALT)
wait(2)
type("google-chrome https://www.bundesliga.com/de/bundesliga/")
type(Key.ENTER)
wait(5)
screenshot = capture(SCREEN)
shutil.move(screenshot, "/home/taylor/my_script.sikuli/tmp/screenshot.png")

Here is the log:

 ~  xvfb-run ~/runsikulix -r ~/my_script.sikuli --args ~/my_script.sikuli/tmp/state.json
running SikuliX: -Xmx512M -Dfile.encoding=UTF-8 -Dsikuli.FromCommandLine
-jar /home/taylor/sikulix.jar -r /home/taylor/my_script.sikuli --args /home/taylor/my_script.sikuli/tmp/state.json
[info] runcmd: lsb_release -i -r -s 
[info] App: command wmctrl ran, but failed: `org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)'. Hoping for the best
[log] ( Ctrl+Alt )  TYPE "t"
[log]  TYPE "google-chrome https://www.bundesliga.com/de/bundesliga/"
[log]  TYPE "#ENTER."

The resulting screenshot is blank for xvfb and looks as it should, with the website loaded, when I run it with the normal display server.

The error message that I can't figure out is [info] App: command wmctrl ran, but failed: 'org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)'. Hoping for the best. I've got wmctrl installed, and don't see this message when I run without xvfb. Is it possible that this is a bug with 1.1.1?

Thanks in advance for your consideration!

Taylor

RaiMan commented 6 years ago

On Linux systems at startup the usability of the command wmctrl is tested. It is later used with the features of The App class. Apparently you have a problem with wmctrl in this xvfb-run situation (it is run in subprocess). So to check, you should run wmctrl with xvfb-run. If the problem persists, the you cannot use the App class features. You might try with 1.1.2 nightly, that handles the mwctrl problem a bit more graceful.

... but this has nothing to do with the core features of Sikuli.

Run as runsikulix -d 3 ....

to get more debug output especially about the screen as it is seen by SikuliX

taylordowns2000 commented 6 years ago

Wow, thanks for the swift response. OK—you're right that it's an xvfb-run and wmctrl issue, not a Sikuli issue.

Without xvfb-run:

 ~  wmctrl -m         
Name: Compiz
Class: N/A
PID: N/A
Window manager's "showing the desktop" mode: OFF

With xvfb-run:

 ~  xvfb-run wmctrl -m
Cannot get window manager info properties.
(_NET_SUPPORTING_WM_CHECK or _WIN_SUPPORTING_WM_CHECK)

As a final question, I've seen so many different threads about xvfb and sikulix—is there a definitive guide or thread you'd recommend for trying to get sikuli to run with xvfb for Ubuntu 16.04?

Adding my verbose logs here, before you close the issue, for posterity. I'll keep messing around with xvfb and wmctrl. Thanks again, @RaiMan , for your quick support!

Logs:

 ~  xvfb-run ~/runsikulix -d 3 -r ~/my_script.sikuli --args ~/my_script.sikuli/tmp/state.json
running SikuliX: -Xmx512M -Dfile.encoding=UTF-8 -Dsikuli.FromCommandLine
-jar /home/taylor/sikulix.jar -d 3 -r /home/taylor/my_script.sikuli --args /home/taylor/my_script.sikuli/tmp/state.json
[debug] RunTimeINIT: lsb_release -i -r -s 
[debug] RunTimeINIT: loadOptions: check: /home/taylor
[debug] RunTimeINIT: loadOptions: check: /home/taylor
[debug] RunTimeINIT: loadOptions: check: /home/taylor/.Sikulix/SikulixStore
[debug] RunTimeINIT: global init: entering as: IDE
[debug] RunTimeINIT: ScreenDevice 0 has (0,0) --- will be primary Screen(0)
[debug] RunTimeINIT: Monitor 0: (0, 0) 640 x 480
[debug] RunTimeINIT: runs as sikulix.jar in: /home/taylor
[debug] RunTimeINIT: exists libs folder at: /home/taylor/.Sikulix/SikulixLibs_201703300100
***** show environment for IDE (build 201703300100)
user.home: /home/taylor
user.dir (work dir): /home/taylor
user.name: taylor
java.io.tmpdir: /tmp
running 64Bit on Linux (0 Ubuntu 16.04) from a jar
java 8-64 version 1.8.0_151-8u151-b12-0ubuntu0.16.04.2-b12 vm 25.151-b12 class 52.0 arch amd64
app data folder: /home/taylor/.Sikulix
libs folder: /home/taylor/.Sikulix/SikulixLibs_201703300100
executing jar: /home/taylor/sikulix.jar
*** classpath dump sikulix
  0: /home/taylor/sikulix.jar
*** classpath dump end
***** show environment end
[debug] RunTimeIDE: global init: leaving
[debug] RunTimeIDE: initIDEbefore: entering
[debug] RunTimeIDE: initIDEbefore: leaving
[debug] RunTimeIDE: initAPI: entering
[debug] RunTimeIDE: resourceList: enter
[debug] RunTimeIDE: resourceLocation: (class org.sikuli.ide.SikuliIDE) /Lib/sikuli
[debug] RunTimeIDE: resourceList: having jar: jar:file:/home/taylor/sikulix.jar!/Lib/sikuli
[debug] RunTimeIDE: files exported: 7 from: Lib/sikuli to:
 /home/taylor/.Sikulix/Lib/sikuli
[debug] RunTimeIDE: initAPI: leaving
[debug] IDE: Switching to ScriptRunner with option -r, -t or -i
[debug] Runner: commandline: -d 3 -r /home/taylor/my_script.sikuli --args /home/taylor/my_script.sikuli/tmp/state.json
[debug] --- Sikuli parameters ---
[debug] 1: -d
[debug] 2: 3
[debug] 3: -r
[debug] 4: /home/taylor/my_script.sikuli
[debug] --- User parameters ---
[debug] 1: /home/taylor/my_script.sikuli/tmp/state.json
[debug] ScriptingSupport: givenScriptName:
/home/taylor/my_script.sikuli
[debug] ScriptingSupport: Trying to run script:
/home/taylor/my_script.sikuli/my_script.py
[debug] ScriptingSupport: initScriptingSupport: enter
[debug] JythonSupport: init: starting
[debug] JythonSupport: init: success
[debug] JythonSupport: added as Jython::sys.path[0]:
/home/taylor/.Sikulix/Lib/site-packages
[debug] JythonSupport: ***** Jython sys.path
 0: /home/taylor/.Sikulix/Lib/site-packages
 1: /home/taylor/Lib
 2: /home/taylor/sikulix.jar/Lib
 3: __classpath__
 4: __pyclasspath__/
[debug] JythonSupport: ***** Jython sys.path end
[debug] Jython: sikuli: Sikuli: starting init
[debug] RunTimeIDE: loadLib: libVisionProxy.so
[debug] Mouse: init start
[debug] Mouse: init end
[info] App: command wmctrl ran, but failed: `org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)'. Hoping for the best
[debug] App: command wmctrl ran, but failed: `org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)'. Hoping for the best
[debug] Jython: requested to use as default region: S(0)[0,0 640x480]
[debug] Jython: sikuli: Sikuli: ending init
[debug] JythonScriptRunner: running Jython 2.7.1 
[debug] ScriptingSupport: initScriptingSupport: added: jython
[debug] ScriptingSupport: initScriptingSupport: exit with defaultrunner: jython (py)
[debug] ImagePath: new BundlePath:
/home/taylor/my_script.sikuli/
[debug] Jython: requested to use as default region: S(0)[0,0 640x480]
[debug] JythonScriptRunner: runPython: running script: 
/home/taylor/my_script.sikuli
[debug] ( Ctrl+Alt )  TYPE "t"
[debug] Region: ( Ctrl+Alt )  TYPE "t"
[debug]  TYPE "google-chrome https://www.bundesliga.com/de/bundesliga/"
[debug] Region:  TYPE "google-chrome https://www.bundesliga.com/de/bundesliga/"
[debug]  TYPE "#ENTER."
[debug] Region:  TYPE "#ENTER."
[debug] RunTimeIDE: final cleanup
[debug] FileManager: deleteFileOrFolder:
/tmp/Sikulix_132991707
RaiMan commented 6 years ago

Thanks for your feedback.

Sorry no, I do not have any experiences with this Linux related stuff. Especially not about usage scenarios of xvfb.

I only use it with version 2 on Travis:CI to run tests ... and it simply works ;-)

But may be you should more look for "xvfb java headless".

toschneck commented 6 years ago

Hi you can use our headless vnc Docker contaier for your usecase I think: https://github.com/ConSol/docker-headless-vnc-container