osx .observe(1) getsRuntimeError ( maximum recursion depth exceeded (Java StackOverflowError) )

Bug #1609079 reported by Joe White
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SikuliX
Opinion
Undecided
Unassigned

Bug Description

This works on the same Mac OS 10.11.6 system with SikuliX 1.1.0.
Running the same program attached give a Java StackOverflowError on
the line "sample.observe(1) # observing for 1 seconds (script pauses here - Java Stack Overflow)
It happens the very first observation.....same JDK and java versions.

############################## Log ###############################
[log] App.focus: [0:Firefox]
[log] ( ⌘ ) TYPE "t"
2016-08-02 11\:47\:42, Typed "t", KeyModifier.CMD
[log] TYPE "nist.time.gov#ENTER."
2016-08-02 11\:47\:44, Typed "nist.time.gov" + Key.ENTER
2016-08-02 11\:47\:45, Found Right now
[log] highlight M[749,127 410x25]@S(0) for 2.0 secs
[log] highlight R[793,175 350x62]@S(0) for 2.0 secs
========= Starting Observation#0 ========
[error] script [ test3 ] stopped with error in line 132
[error] RuntimeError ( maximum recursion depth exceeded (Java StackOverflowError) )
############################# Program ###########################
import sys
import subprocess
import time
import shutil
setAutoWaitTimeout(5000)
Settings.ObserveScanRate = 2
def logit(msg):
    lfile = open(id, "a")
    msgall = time.strftime("%Y-%m-%d %H\:%M\:%S, ") + msg
    print(msgall)
    lfile.write(msgall)
    lfile.close()
def snapit(msg):
    bounds = getBounds()
    pic = Screen(0).capture(bounds)
    print("snapshot taken, + msg")
    msg = msg.rstrip("\n")
    sfile = path + "OSX10.11.5 " + time.strftime("%Y-%m-%d %H.%M.%S ") + msg + ".png"
    shutil.move(pic,sfile)
def findit(pattern,desc):
    found = False
    for i in range(3):
        if wait(pattern,2):
            msg = "Found %s\n" % desc
            logit(msg)
            found = True
            break
    if (not found):
        msg = "%s not found\n" % desc
        logit(msg)
        snapit(msg)
        return False
    return True
def typekeys(app,cmd,parm1):
    defined = False
    if (app == "Firefox"):
        if (cmd == "Clear Recent History"):
            defined = True
            keys = "Key.BACKSPACE, KeyModifier.SHIFT|KeyModifier.CMD"
            type(Key.BACKSPACE, KeyModifier.SHIFT|KeyModifier.CMD)
            msg = "Typed %s\n" % keys
            logit(msg)
            time.sleep(1)
            clearnow = Pattern("clearnow.png").similar(0.80)
            desc = "Clear Now"
            rc = clickit(clearnow, desc)
            if (rc == False):
                return False
            time.sleep(2)
        elif (cmd == "New Tab & URL"):
            defined = True
            keys = "\"t\", KeyModifier.CMD"
            type("t", KeyModifier.CMD)
            msg = "Typed %s\n" % keys
            logit(msg)
            time.sleep(1)
            keys = "\"%s\" + Key.ENTER" % parm1
            type(parm1 + Key.ENTER)
            msg = "Typed %s\n" % keys
            logit(msg)
            time.sleep(1)
        elif (cmd == "Close Tab"):
            defined = True
            keys = "\"w\", KeyModifier.CMD"
            type("w", KeyModifier.CMD)
            msg = "Typed %s\n" % keys
            logit(msg)
            time.sleep(1)
        elif (cmd == "Select URL field"):
            keys = "\"l\", KeyModifier.CMD"
            type("l", KeyModifier.CMD)
            msg = "Typed %s\n" % keys
            logit(msg)
    else:
        pass
    if (not defined):
        msg = "No %s found\n" % cmd
        logit(msg)
        snapit(msg)
        return False
    return True
def timechanged(event):
    print("Something changed in ", event.region)
    num = 0
    for ch in event.changes:
        num += 1
        ch.highlight() # highlight all changes
    sleep(1)
    print("Highlighted events=" + str(num))
    num = 0
    for ch in event.changes:
        num += 1
        ch.highlight() # turn off the highlights
    print("Unhighlighted events=" + str(num))
    Settings.isChanged = True
    event.region.stopObserver()
####################################### Main ####################################
global id, path
# Create log file for msgs and path for snapshots
dir = "/users/joe/Documents/SikuliX/logs/"
lfile = "OSX10.11.5_" + time.strftime("%Y-%m-%d %Hh%Mm%Ss") + ".log"
id = dir + lfile
path = dir
lfile = open(id, "w")
lfile.close()
##############################################################################
setThrowException(False)
app = "Firefox"
myApp=switchApp(app)
cmd = "New Tab & URL"
parm1 = "nist.time.gov"
rc = typekeys(app,cmd,parm1)
if (not rc):
    exit(1)
header = "1469738059083.png"
rc = findit(header,"Right now")
if (not rc):
    exit(2)
headerloc = find(header)
headerloc.highlight(2)
hx = headerloc.getX()
hy = headerloc.getY()
timeloc = Region(hx + 44, hy + 48, 350, 62)
timeloc.highlight(2)
passed = 0
failed = 0
for i in range(10):
    sample = timeloc
    sample.onChange(100, timechanged)
    Settings.isChanged = False
    print("========= Starting Observation#" + str(i) + " ========")
    sample.observe(1) # observing for 1 seconds (script pauses here - Java Stack Overflow
    if Settings.isChanged: # check wether the handler was called (because there where changes)
        passed += 1
    else:
        failed += 1
print("Passed=" + str(passed) + ",Failed=" + str(failed))
cmd = "Close Tab"
parm1 = None
rc = typekeys(app,cmd,parm1)
if (not rc):
    exit(3)
exit(4)

################################ Log output #########################

Revision history for this message
Joe White (joe-white) wrote :
RaiMan (raimund-hocke)
Changed in sikuli:
status: New → Opinion
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.