Page MenuHomePhabricator

evas cache image: compare with cached image file
ClosedPublic

Authored by kimcinoo on Aug 19 2018, 11:51 PM.

Details

Summary

As cache2 knows cached image could be not matched even though
hash key is not different.

Please refer to the following comment of evas_cache2_image_open.

/* image we found doesn't match what's on disk (stat info wise)
 * so dirty the active cache entry so we never find it again. this
 * also implicitly guarantees that we only have 1 active copy
 * of an image at a given key. we wither find it and keep re-reffing
 * it or we dirty it and get it out */

The hash key is created base on the image file address.
If the image file address to find does not equal cached image file address
then it means that the cached image is no longer valid.

This case could happen with the following step.

(1) Call evas_object_image_memfile_set with content data A
(2) Call evas_object_image_memfile_set with content data B
(3) Add timer with short time (ex: 0.01 sec)
(4) Delete A image, and add A image in timer callback
(5) Delete B image, and add B image in timer callback

Sometimes you could see image of A from the B image, because newly created
image at step 5 has same address of setp 1.

Diff Detail

Repository
rEFL core/efl
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
kimcinoo created this revision.Aug 19 2018, 11:51 PM
kimcinoo requested review of this revision.Aug 19 2018, 11:51 PM
kimcinoo edited the summary of this revision. (Show Details)Aug 20 2018, 12:14 AM
zmike added a comment.Aug 20 2018, 9:53 AM

Can a unit test be added for this using an implementation of the pseudocode you provided?

@zmike I have no idea how to compare two images on the unit test. Would you please let me know if you have?

raster added a subscriber: raster.Aug 20 2018, 5:33 PM

bug fix. i see how making test that triggers this would be hard as it's a race/internal structure condition where you just get unlucky sometimes. but i think mike means like memfile set an image to one memfile, then get the pixeldata, maybe chekcsum it simply, then memfile set the sameimage to another memfile data blob and get the image data and checksum that. if the sums differ. good. it worked. if they are the same... bad. it's not a great test and not of much value really... but that's kind of what he's asking.

@raster Thank you. If I got it correctly I need to use evas_object_image_data_get.

@raster Thank you. If I got it correctly I need to use evas_object_image_data_get.

If the wrong image is being displayed by an object then probably it's enough to just check the evas_object_image_data_get value in the following RENDER_PRE callback?

kimcinoo updated this revision to Diff 16493.Aug 22 2018, 10:51 PM

Add test case

kimcinoo updated this revision to Diff 16494.Aug 22 2018, 10:54 PM

Rename test case

Is this still a problem ? Is there a reason this has not landed ?

Cache2 has been removed. Unmaintained and not functional at the time.

The commit message is actually incorrect as the patch is against cache, not cache2. I think my question still stand, is this patch still relevant and does it require review ?

This is not standing for the cache2. I just quoted comment of the cache2.
This is standing for the cache.

cedric accepted this revision.Nov 29 2018, 4:01 PM

This seems actually correct to me.

This revision is now accepted and ready to land.Nov 29 2018, 4:01 PM
This revision was automatically updated to reflect the committed changes.