Footage cache (#3271): a remembered failure is of the file as it was

The plane store remembered failed requests (unreadable, too large) by what they asked for alone: a file replaced on disk without Reload Footage got a new index but kept being refused, so its channels stayed missing and its picture fell back to a whole-file decode every frame. A failure now keeps the index it was made with and only refuses requests of that index; a failure of the new file replaces the old ones. A test fails a broken file, then reads its fixed version under a new index; it fails on the old code.
This commit is contained in:
vangel76 committed 2026-11-08 16:24:43 +01:00
1 parent 3a63d8e8df
commit 53f59f8742
2 files changed
+35 -5

No files matched your search

+12 -5
View File
@@ -261,9 +261,10 @@ struct Entry {
path: String,
batch: Option<Arc<Batch>>,
flight: Option<Arc<Flight>>,
/// Requests that failed for good (unreadable, too large) and why: a request asking for at
/// Requests that failed for good (unreadable, too large), the index they were made with, and
/// why: a request of that index (the file as it was) asking for at
/// least as much fails the same way until the file is forgotten.
failed: Vec<(Want, Refused)>,
failed: Vec<(Arc<ExrIndex>, Want, Refused)>,
bytes: usize,
/// When it was last asked for or finished decoding ([`effectcraft_render::memory::tick`]).
used: u64,
@@ -504,7 +505,8 @@ impl PlaneStore {
crate::reads::note(b.file.clone());
return Step::Done(Ok(b));
}
if let Some((_, why)) = e.failed.iter().find(|(failed, _)| asks_at_least(want, failed)) {
// (a failure of the file as it was before: the file changed since, it is read again)
if let Some((_, _, why)) = e.failed.iter().find(|(of, failed, _)| Arc::ptr_eq(of, index) && asks_at_least(want, failed)) {
return Step::Done(Err(why.clone()));
}
if let Some(flight) = e.flight.clone() {
@@ -641,11 +643,16 @@ impl PlaneStore {
e.batch = Some(b.clone());
}
Err(why @ (Refused::Unreadable | Refused::TooLarge(_))) => {
let want = flight.state().want.clone();
let (index, want) = {
let fs = flight.state();
(fs.index.clone(), fs.want.clone())
};
// (failures of another version of the file no longer apply)
e.failed.retain(|(of, _, _)| Arc::ptr_eq(of, &index));
if e.failed.len() >= FAILED_KEPT {
e.failed.remove(0);
}
e.failed.push((want, why.clone()));
e.failed.push((index, want, why.clone()));
}
// (the file changed: what is held is of the old one)
Err(Refused::Changed) => {
+23
View File
@@ -1382,3 +1382,26 @@ fn the_picture_planes_are_not_kept_beside_the_picture() {
assert!(shared().kept(path).is_none());
forget(path);
}
/// #3271 review (#3301): a remembered failure belongs to the file as it was. A file that was
/// unreadable and is then replaced on disk (no Reload Footage: the new index comes from its new
/// stamp) is read again, not refused with the old file's failure.
#[test]
fn a_failure_is_forgotten_once_the_file_changes() {
let good: Arc<[u8]> = write(vec![part(None, &RGBA, (8, 8), Compression::ZIP1)], (8, 8)).into();
let mut broken = good.to_vec();
broken.truncate(broken.len() - 64);
let path = "/3271-failed-then-fixed.exr";
let store = PlaneStore::new(CACHE_BUDGET);
let all = Want { all: true, ids: (0..4).collect() };
let source = ExrSource::Bytes(broken.into());
let old = crate::exr_index::get(path, &source).unwrap();
assert!(store.get(path, &source, &old, &all, Use::Other).is_err());
assert!(store.get(path, &source, &old, &all, Use::Other).is_err(), "remembered for the same file");
// The file is replaced: another index (here read under another name, as the file's new stamp
// would give it).
let source = ExrSource::Bytes(good);
let new = crate::exr_index::get("/3271-failed-then-fixed-new.exr", &source).unwrap();
assert!(!Arc::ptr_eq(&old, &new));
assert!(store.get(path, &source, &new, &all, Use::Other).is_ok(), "the new file is read");
}