AcademySoftwareFoundation / AcademySoftwareFoundation/OpenImageIO
[BUG] ImageCache doesn't invalidate if no change in modification time
- Dominant language
- C++
- Stars
- 2.4k
- Forks
- 698
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 48
Description
**Describe the bug**
I loaded two images from the same path. The file was changed between the two operations but since the file's modification time stayed the same (in seconds) `ImageCache` didn't invalidate it:
If the change takes a longer time such that the modification time of the file, which has seconds resolution, differs for the second image load, `buf2` will load from the correct, updated file and that would be the expected behaviour always.
**To Reproduce**
Steps to reproduce the behavior:
```
std::string filePath = ...;
// Save an image to filePath
ImageBuf buf1(filePath);
// Save another image to filePath
ImageBuf buf2(filePath);
```
**Expected behavior**
I expect `buf2` to hold the update image which is the case if the modification time is updated (in seconds) for the second operation.
**Evidence**
This is intentional behavior of the `ImageCache` as we can see it here: https://github.com/OpenImageIO/oiio/blob/003a1f15aeb4a7ee7e31c0c21c27eafc9b981f57/src/libtexture/imagecache.cpp#L3395
I don't think ignoring the changes of a file should depend on the resolution of the file time, at least not if the resolution is seconds.
**Platform information:**
- OIIO branch/version: 2.3.7.2
- OS: macOS 12.6.2 (21G320)
- C++ compiler: Apple clang version 14.0.0 (clang-1400.0.29.202)
- Any non-default build flags when you build OIIO: none
Contributor guide
Research direction
Start in src/libtexture/imagecache.cpp around line 3395 and reproduce the two rapid saves and ImageBuf loads described in the issue. Trace how ImageCache decides whether a file changed, then verify with a regression test that buf2 reads the updated image even when modification time has only-second resolution.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100