Import: Purge frees decoded GIFs; a browser tab keeps less of one GIF (#567 follow-up)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QiAJeFttZp83Fh7YuzAR5f
This commit is contained in:
@@ -15,8 +15,12 @@ use crate::{MediaError, Result};
|
|||||||
/// The `Footage::codec` of an animated GIF.
|
/// The `Footage::codec` of an animated GIF.
|
||||||
pub(crate) const CODEC: &str = "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;
|
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.
|
/// Frames read from a GIF's headers when probing.
|
||||||
const MAX_FRAMES: usize = 100_000;
|
const MAX_FRAMES: usize = 100_000;
|
||||||
|
|||||||
@@ -304,13 +304,15 @@ impl MediaPool {
|
|||||||
let mut c = lock(&self.inner.cache);
|
let mut c = lock(&self.inner.cache);
|
||||||
c.lru = Lru::default();
|
c.lru = Lru::default();
|
||||||
c.last.clear();
|
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.
|
/// Drop every cached frame and decoder.
|
||||||
pub fn clear(&self) {
|
pub fn clear(&self) {
|
||||||
self.clear_frames();
|
self.clear_frames();
|
||||||
lock(&self.inner.sources).clear();
|
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).
|
/// Forget a file (after it changed on disk, or to retry a file that failed to open).
|
||||||
|
|||||||
Reference in New Issue
Block a user