Re: [Sikuli-driver] [Question #692550]: IDE crash when OCR does not find anything. Only 272 unsuccessful calls of text() possible
Question #692550 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/692550 Status: Answered => Open Michael Böhm is still having a problem: Hi! I tried the same on a VM with Windows 7 and Java 12. only one screen(small) and only 8 GB RAM. Same effect. only it stops after about 700 for crash. I hope this helps Michael -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #692550]: IDE crash when OCR does not find anything. Only 272 unsuccessful calls of text() possible
Question #692550 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/692550 Michael Böhm posted a new comment: Hi, I tried to run the same script from commandline -> same result, except it crashes at 298 instead of 272. Regards MIchael -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #692550]: IDE crash when OCR does not find anything. Only 272 unsuccessful calls of text() possible
Question #692550 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/692550 Michael Böhm posted a new comment: Hi! Thanks for your quick response --- *) if the image is whitespace: NO crash Since whitespace is an idiom in the string/character/regex world (meaning spaces, newlines, ...): you are talking about an area filled with white colour? -> yes, any plain white, grey, black, etc colour will not crash it --- *) but if there is a pattern, like a picture, actually any picture can you send me a typical image (sikulix---at---outlook---dot---com) -> here is the pic from the original bug ticket: https://launchpadlibrarian.net/494128457/BugImage.png # that one crashes for sure that pic, like many others show that behaviour. always at 272 loops. Fun fact: there are some images which should crash it, based on my original description, but in reality they don't. Further try makes me think it depends if the text() function expects any text at all (if yes, but there is no text-> crash). Another observation supports that: I always measure the time for every loop. A typical non-crash run takes about<0.2 sec (including write to file, etc..), it doubles to about 0.4sec on similar size when there is a crashing pattern. Also compared to around <0.3sec when there is actually a text found. Of course bigger areas take more time, but these results are on the same size regions. --- *) restarting the script does not reset this counter I learned, that restarting is only possible if the script did not hang. So you are talking about a restart after a successful run? -> yes, stop a running script at about loop 250, start again makes it through loop 22 kill java und start Sikulix again gets me to full 272 loops https://launchpadlibrarian.net/494128457/BugImage.png -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #692550]: IDE crash when OCR does not find anything. Only 272 unsuccessful calls of text() possible
Question #692550 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/692550 RaiMan proposed the following answer: --- Sorry for spamming this ticket, but just to ensure No excuses ;-) good job! Thank you --- *) if the image is whitespace: NO crash Since whitespace is an idiom in the string/character/regex world (meaning spaces, newlines, ...): you are talking about an area filled with white colour? --- *) but if there is a pattern, like a picture, actually any picture can you send me a typical image (sikulix---at---outlook---dot---com) --- *) restarting the script does not reset this counter I learned, that restarting is only possible if the script did not hang. So you are talking about a restart after a successful run? -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #692550]: IDE crash when OCR does not find anything. Only 272 unsuccessful calls of text() possible
Question #692550 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/692550 Michael Böhm posted a new comment: Sorry for spamming this ticket, but just to ensure: it is only possible to reproduce, if the region to be OCRed is a pattern without a text. Meaning: *) if the image is whitespace: NO crash *) if there is a text: NO crash *) if there is a light pattern: NO crash *) but if there is a pattern, like a picture, actually any picture : crash after 272 loops - every time *) if there is text found while looping: these dont count, it still crashes 272 times the text is not found *) restarting the script does not reset this counter *) killing JAVA and restarting makes the crash counter to start from 0. *) restarting the PC: no difference *) running a lot of applications in the meantime: no difference -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #692550]: IDE crash when OCR does not find anything. Only 272 unsuccessful calls of text() possible
Question #692550 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/692550 Michael Böhm posted a new comment: Hi! actually: using JSYS.gc() at the script makes no difference. following script stalls at loop #294 (which is about 10 later than without gc() ) import java.lang.System as JSYS # at beginning of main script def OCRTest1(): global jrt Reg=selectRegion() Reg.highlight(2) for i in range(1,3000): txt=Reg.text() if i % 100== 0: print_l(i,": GC!",ExtractAlphanumeric_all(txt),len(txt),"free:", int(jrt.freeMemory()/(1024 * 1024))) JSYS.gc() # at loop start or loop end if i % 2 == 0: print_l(i,":",ExtractAlphanumeric_all(txt),len(txt),"free:", int(jrt.freeMemory()/(1024 * 1024))) -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #692550]: IDE crash when OCR does not find anything. Only 272 unsuccessful calls of text() possible
Question #692550 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/692550 Michael Böhm posted a new comment: Here another logfile of the script with the loop: please see the crash right before the library is loaded. And the ABORTKEY event, which is still written to the logfile, although the script crashed. And again: enough memory free, GC was not done. [debug (25.08.20, 22:09:59)] RobotDesktop: captureScreen: [554,253, 123x68] [debug (25.08.20, 22:09:59)] Image: BufferedImage: (123, 68) [debug (25.08.20, 22:09:59)] Image: getImage inMemory: __BufferedImage__ [debug (25.08.20, 22:09:59)] Finder2: makeMat: INT_RGB (123x68) [debug (25.08.20, 22:09:59)] RunTime:loadlib: trying opencv_java342 [debug (25.08.20, 22:09:59)] RunTime:loadLib: opencv_java342.dll already loaded [debug (25.08.20, 22:09:59)] OCR: start: Tess4J 4.4.1 using Tesseract 4.1.0 [debug (25.08.20, 22:09:59)] RobotDesktop: captureScreen: [554,253, 123x68] [debug (25.08.20, 22:09:59)] Image: BufferedImage: (123, 68) [debug (25.08.20, 22:09:59)] Image: getImage inMemory: __BufferedImage__ [debug (25.08.20, 22:09:59)] Finder2: makeMat: INT_RGB (123x68) [debug (25.08.20, 22:10:08)] IDE: AbortKey was pressed: aborting all running scripts [debug (25.08.20, 22:10:09)] IDE: AbortKey was pressed: aborting all running scripts -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #692550]: IDE crash when OCR does not find anything. Only 272 unsuccessful calls of text() possible
Question #692550 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/692550 Michael Böhm posted a new comment: Dear RaiMan, It is still crashing in my environment. It does not seem to be memory related, as the remaining free memory (based on your script) was 495MB. besides: I am not sure you saw the debug log. Every loop looks the same in the debug log, except the last (the crashing) one. Following lines were missing: [debug (19.08.20, 11:19:18)] RunTime:loadlib: trying opencv_java342 [debug (19.08.20, 11:19:18)] RunTime:loadLib: opencv_java342.dll already loaded maybe there is a problem in loading this library? Regards MIchael -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #692550]: IDE crash when OCR does not find anything. Only 272 unsuccessful calls of text() possible
Question #692550 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/692550 Michael Böhm posted a new comment: Thanks a lot. I will monitor the behavior. Regards Michael -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #692550]: IDE crash when OCR does not find anything. Only 272 unsuccessful calls of text() possible
Question #692550 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/692550 Removed link to bug: #1892161 https://bugs.launchpad.net/bugs/1892161 "IDE crash when OCR does not find anything. Only 272 unsuccessful calls of text() possible" -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #692550]: IDE crash when OCR does not find anything. Only 272 unsuccessful calls of text() possible
Question #692550 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/692550 RaiMan proposed the following answer: Thanks again for your efforts. But doing my tests, I am rather sure, that this has nothing to do with OCR as such. Internally to trigger the OCR feature, a new screenshot is taken each time the Reg.text() is processed. This constantly increases memory consumption (BufferedImage). But in my tests (using the script from comment #6) one can see, that if free memory gets short, GC does its job and increases free memory again. So I cannot reproduce this problem on my system (Win 10, Java 11). So if this problem really persists in your environment, you either should restart the IDE from time to time or run the offending script from command line using -r -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #692550]: IDE crash when OCR does not find anything. Only 272 unsuccessful calls of text() possible
Question #692550 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/692550 Michael Böhm posted a new comment: as the original text was lost, here a copy again: Hi! I can reproduce with following script: Reg=Region(884,1291,104,64) Reg.highlight(2) for i in range(1,1000): print_l(i,":",Reg.text()) on my PC it crashed always(!!!) on counter: 272 Here the log: [debug (19.08.20, 11:19:17)] Finder2: makeMat: INT_RGB (104x64) [debug (19.08.20, 11:19:17)] RunTime:loadlib: trying opencv_java342 [debug (19.08.20, 11:19:17)] RunTime:loadLib: opencv_java342.dll already loaded [debug (19.08.20, 11:19:17)] OCR: start: Tess4J 4.4.1 using Tesseract 4.1.0 [debug (19.08.20, 11:19:17)] RobotDesktop: captureScreen: [884,1291, 104x64] [debug (19.08.20, 11:19:17)] Image: BufferedImage: (104, 64) [debug (19.08.20, 11:19:17)] Image: getImage inMemory: __BufferedImage__ [debug (19.08.20, 11:19:17)] Finder2: makeMat: INT_RGB (104x64) [debug (19.08.20, 11:19:18)] RunTime:loadlib: trying opencv_java342 [debug (19.08.20, 11:19:18)] RunTime:loadLib: opencv_java342.dll already loaded [debug (19.08.20, 11:19:18)] OCR: start: Tess4J 4.4.1 using Tesseract 4.1.0 [debug (19.08.20, 11:19:18)] RobotDesktop: captureScreen: [884,1291, 104x64] [debug (19.08.20, 11:19:18)] Image: BufferedImage: (104, 64) [debug (19.08.20, 11:19:18)] Image: getImage inMemory: __BufferedImage__ [debug (19.08.20, 11:19:18)] Finder2: makeMat: INT_RGB (104x64) [debug (19.08.20, 11:19:47)] IDE: AbortKey was pressed: aborting all running scripts [debug (19.08.20, 11:19:50)] IDE: AbortKey was pressed: aborting all running scripts Hi! Some more findings: Using the "reproduce script": *) It does NOT crash, when OCR finds a text. *) It crashes also at counter 272 for different Regions/images, however: -) it does not crash (also not later) when I select a Region with "easy" background (not many patterns) -) taking a much bigger region results in no difference -) finding a word in the meantime makes no difference, the script always crashes at 272 -) OCR.reset() in the meantime makes no difference, still crash at 272 -) replace Reg.text() to OCR.readText() - same, still crash at 272 -) OCR.readLine(), readWord, readChar are also crashing (different count (=128)), even tough they find characters in any pattern. -) Doing OCR alternatively on word and on non-word patterns let it crash earlier (at 172) -) Doing OCR on words only does not crash within 1000 runs -) OEM=0, PSM=8 also crash -) OEM=0, PSM=2 also crash I hope I found some useful information. I was not able to find a workaround (other than avoiding OCR on non text). Good luck Best Regards Michael -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #692550]: IDE crash when OCR does not find anything. Only 272 unsuccessful calls of text() possible
Question #692550 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/692550 RaiMan proposed the following answer: ... and this is my latest test showing memory usage: Reg=Region(1400+0,675,365,51) Reg.highlight(2) import java.lang.Runtime as RT jrt = RT.getRuntime() print "max:", jrt.maxMemory(), "tot:", jrt.totalMemory(), "free:", jrt.freeMemory() for i in range(1,2000): Reg.text() if i % 50 == 0: print i, "free:", int(jrt.freeMemory()/(1024 * 1024)) One can see, when GC does its job. -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #692550]: IDE crash when OCR does not find anything. Only 272 unsuccessful calls of text() possible
Question #692550 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/692550 RaiMan proposed the following answer: I made the test and can confirm: at the beginning running the snippet from inside the IDE I had the problem (at about 300+). Then after repeating the test (running the script with -r), I could not reproduce it again. Even not when running the script from inside the IDE again. Watching the memory consumption in parallel, I could see, that the usage constantly increases (which is normal), but also that the GC (Java garbage collection) works as it should: cutting down the usage from time to time. So I guess, that it is one of those ugly memory related problems, that are very hard to tackle. ... but I'll do my very best. meanwhile you might try this: https://github.com/RaiMan/SikuliX1/issues/323 -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #692550]: IDE crash when OCR does not find anything. Only 272 unsuccessful calls of text() possible
Question #692550 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/692550 Status: Open => Answered RaiMan proposed the following answer: ok, sorry for the mess. I will check. -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #692550]: IDE crash when OCR does not find anything. Only 272 unsuccessful calls of text() possible
Question #692550 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/692550 Linked to bug: #1892161 https://bugs.launchpad.net/bugs/1892161 "IDE crash when OCR does not find anything. Only 272 unsuccessful calls of text() possible" -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #692550]: IDE crash when OCR does not find anything. Only 272 unsuccessful calls of text() possible
Question #692550 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/692550 Status: Answered => Open Michael Böhm is still having a problem: Dear RaiMan, sorry for bothering you. I am still sure this is a bug, as I can reproduce any time. In regards to your questions: -- crash: I called it crash. Whatever it is: I cannot stop it with the hotkey (alt+shift+C). only killing JAVA from taskmanager works -- Here the missing function: def ExtractAlphanumeric_all(InputString): from string import ascii_letters, digits return "".join([ch for ch in InputString if ch in (ascii_letters + digits +" ()*"+"äöüÄÖÜß")]) -- I need to shrink the region, because my experience over years with Sikulix is, that in case text is not found, a region with smaller size (less empty space around the text) works much better. This is why I start trying to get the text with the biggest size first, and then slowly decreasing it. Nevertheless. In my original ticket I added a lot of debug information, which was describing exactly what leads to the bug. All comments disappeart obviously when you moved it to a "question". Short summary of what I wrote in my original ticket: it can be reproduced, a simple loop with getting text causes the same error, and it depends on the pattern of the picture how soon it crashes. Regards MIchael You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #692550]: IDE crash when OCR does not find anything. Only 272 unsuccessful calls of text() possible
Question #692550 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/692550 Status: Open => Answered RaiMan proposed the following answer: a better version of your snippet: def text_shrink(Reg): # continously decrease region until OCR gets a match texts="" Reg=Reg.grow(30,30,0,0) while texts == "" and Reg.getW()>61: Reg=Reg.grow(-30,-30,0,0) texts=ExtractAlphanumeric_all(Reg.text()).strip() #crash here on OCR return texts --- I cannot see any information about a "crash" (besides that the script does not come back) --- your function ExtractAlphanumeric_all() might have problems (endless loop?) --- generally it does not make sense to shrink a region, that does not have text, to eventually find text in the shrinked region. -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #692550]: IDE crash when OCR does not find anything. Only 272 unsuccessful calls of text() possible
Question #692550 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/692550 Removed link to bug: #1892161 https://bugs.launchpad.net/bugs/1892161 "IDE crash when OCR does not find anything. Only 272 unsuccessful calls of text() possible" -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp
Re: [Sikuli-driver] [Question #692550]: IDE crash when OCR does not find anything. Only 272 unsuccessful calls of text() possible
Question #692550 on Sikuli changed: https://answers.launchpad.net/sikuli/+question/692550 RaiMan posted a new comment: should first be a question -- You received this question notification because your team Sikuli Drivers is an answer contact for Sikuli. ___ Mailing list: https://launchpad.net/~sikuli-driver Post to : sikuli-driver@lists.launchpad.net Unsubscribe : https://launchpad.net/~sikuli-driver More help : https://help.launchpad.net/ListHelp