mirror of
https://github.com/storytold/effectcraft.git
synced 2026-10-14 19:27:05 -04:00
Import: Purge frees decoded GIFs; a browser tab keeps less of one GIF (#567 follow-up)
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QiAJeFttZp83Fh7YuzAR5f
This commit is contained in:
2 files changed
+8
-2
No files matched your search
@@ -15,8 +15,12 @@ use crate::{MediaError, Result};
|
||||
/// The `Footage::codec` of an animated GIF.
|
||||
pub(crate) const CODEC: &str = "GIF";
|
||||
|
||||
/// Decoded frames of one GIF are kept as 8-bit RGBA, up to this many bytes.
|
||||
/// Decoded frames of one GIF are kept as 8-bit RGBA, up to this many bytes (less in a browser tab,
|
||||
/// whose wasm32 heap is 4 GiB at most and shared with everything else).
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
const MAX_BYTES: usize = 1 << 30;
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
const MAX_BYTES: usize = 256 << 20;
|
||||
|
||||
/// Frames read from a GIF's headers when probing.
|
||||
const MAX_FRAMES: usize = 100_000;
|
||||
|
||||
@@ -304,13 +304,15 @@ impl MediaPool {
|
||||
let mut c = lock(&self.inner.cache);
|
||||
c.lru = Lru::default();
|
||||
c.last.clear();
|
||||
drop(c);
|
||||
// Decoded GIFs sit outside the frame budget; Purge frees them too.
|
||||
lock(&self.inner.gifs).clear();
|
||||
}
|
||||
|
||||
/// Drop every cached frame and decoder.
|
||||
pub fn clear(&self) {
|
||||
self.clear_frames();
|
||||
lock(&self.inner.sources).clear();
|
||||
lock(&self.inner.gifs).clear();
|
||||
}
|
||||
|
||||
/// Forget a file (after it changed on disk, or to retry a file that failed to open).
|
||||
|
||||
Reference in new issue
Block a user