[1.1.0] Images with same name but in different tab are wrong

Bug #1402048 reported by Voodoo on 2014-12-12
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Sikuli
High
RaiMan

Bug Description

Using SikuliX 2014 1.1.0 nightly build 2014-12-09 on Windows 8.1 x64 with Java 1.7.0_72.

If you have two test drectories, e.g.:
- test_1.sikuli
- test_2.sikuli
and both tests contains an image with the same name, e.g. "test.png" and 0.99 similarity,
opening both tests with the Sikuli IDE, the image of the first loaded test will dominate in the IDE,
this means the image of the first test will also be shown in the second test tab.

Assume the first test "test_1.sikuli" fails, because it can not match the image on the screen,
running the second loaded test "test_2.sikuli" from the IDE will also fail,
although the image should be found on the screen.

I also noticed another strange behavior which might be affected by the same bug:
capturing and replacing an existing image in the current test won't be found on screen
(assume the image won't be found before capturing).

Here an example code for capturing and replacing an image:

import os, shutil
f = capture(Region(0, 0, 500, 400))
shutil.copy(f, os.path.join(getBundlePath(), 'test.png'))
find(Pattern("test.png").exact())

I hope my description was clear enough.

RaiMan (raimund-hocke) wrote :

--- first case (same image name in different scripts)

I cannot reproduce this behaviour (at least on OS X 10.10) with the latest nightly (should not matter though):

# script 1
img = Pattern("test.png").exact()
find(img).highlight(1)

# script 2
img = Pattern("test.png").exact()
find(img).highlight(1)

- both opened in the IDE
- both test.png have different content
- image thumbs show correct content in each script

works as expected for me.

So please more details / concrete example.

--- second case (inline replace of existing image)
this is clear:
In version 1.1.0 we have an image cache, so when using an image again, it is loaded from memory and not again from file.
Since your approach is hidden to SikuliX (I do not check for external changes of the image file), after the replace of the file, the old memory content is still taken.

To avoid this effect, you either have to switch off image caching from the beginning
Settings.setImageCache(0) # is 64 MB otherwise

or say
Image.reset()
after your external replace (which will clear the cache, so caching starts all over again after that)

I am sorry, but I have not yet textually documented all aspects of version 1.1.0 at
http://sikulix-2014.readthedocs.org/en/latest/index.html

... but to get information about classes like Image and their methods you might have a look into the nightly javadocs:
http://nightly.sikuli.de/docs/index.html

For version 1.2, I will revise the Image handling again and will allow, to replace a cached image with captured content including save to an image file.

RaiMan (raimund-hocke) on 2014-12-13
Changed in sikuli:
status: New → Opinion
importance: Undecided → Medium
importance: Medium → High
assignee: nobody → RaiMan (raimund-hocke)
summary: - [1.1.0-nightly] Images with same name but in different tab are wrong
+ [1.1.0] Images with same name but in different tab are wrong
Changed in sikuli:
milestone: none → 1.1.0
Voodoo (voodoo-master-6666) wrote :

Ok, thank you for the trick with "Settings.setImageCache(0)",
with this capturing and finding is working again.

My first described scenario is still reproducable on Windows 8.1 x64.
Have you tried to open both tests and then restart the IDE?

RaiMan (raimund-hocke) wrote :

ok. thanks.

I made an extra bug for this.

bug 1402185

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers