Sikulix hanging on region.exists(target,timeout),screen.exists(target,timeout) method, Region or Screen

Asked by johnny doe

Hello sometimes when I run my bot in java it hangs in the method exists for unknown reason. Must be a unchecked loop without a timeout. My current workaround is wrap the exist method in ExecutorService and exit the function for 2 seconds if stuck. Would be better if it does not need ExecutorService because it eats cpu resources.

Question information

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

What version of SikuliX?

Always the same exists statement?

Pls. provide a usage example.

Revision history for this message
johnny doe (edison2214) said (last edit ):
#2

Sikulix 2.0.5
if(screen.exists(imageName,0)!=null)
It stuck in the if statement

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

Made some tests and did not find any reason, why exists(..., 0) should hang internally.
There are loops, but none of them is "unchecked".

Adding
Debug.on(3)
reveals some internal logging, that shows, how the find op proceeds.

If you do not trust the exists(..., 0) (because of a possible internal "unchecked loop"), a possible wrapper/substitute could be:
try {
    return screen.find(imagename);
} catch {
    return null;
}

find internally only searches once and does not have a wait loop internally.

For the above I suppose that you are not using the features handleImageMissing and handleFindFailed, which would be a more complex situation.

Revision history for this message
johnny doe (edison2214) said :
#5

it happens after a few of hours of running

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

then it might be a good idea, to cut the process into subprocesses, that only run for an hour.

I do not have any experiences with long running scripts.

Might be a good idea, to set up a long running test and track the resources.

Revision history for this message
johnny doe (edison2214) said (last edit ):
#7

Sir please check the video. It hangs at region.exists(target,timeout)
https://youtu.be/FH19nxhYg3I?t=7276
It also hangs in adbScreen.captureScreen()
This bot doesn't have the ExecutorService implemented.

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

No one has the time to look at lengthy videos.

If you have problems, then post some code and a very good description of the problem.

adb... is currently not supported anyways.

Since you are using Java, you probably can debug.

Revision history for this message
johnny doe (edison2214) said (last edit ):
#10

It's sad that adb is not supported anymore I've been using this library for everything in my daily life. Thank you for developing the library to what it is today. I need to move on to other libraries if adb is not supported anymore.

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

Ok, you have deleted comment #9 --- no problem.
All you said is true. My priority is to keep the stuff running on Windows, Mac and Linux. Over the time I am trying to revise the code, but it is much effort, when you try to keep the stuff backwards compatible.
And on top there is the support for Jython based scripting with the IDE.
So I have to set priorities based on what the majority of users is asking for.
Anyways I am always open for suggestions and contributions.

--- at comment #10
I had to learn, that supporting SikuliX features on USB-connected Android devices is possible, but a huge effort on top, to keep it up-to-date. So I decided, to let others kick that ball.
One of those others is scrcpy, which looks rather mature and handy: https://github.com/Genymobile/scrcpy

All the best.