Skip to content

The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.

perf(memory): the caches are sized to the machine, and let go of what is idle

Jareer2433babafe9a
diff --git a/src/Cargo.lock b/src/Cargo.lock
index afab5456..894e4e2a 100644
--- a/src/Cargo.lock
+++ b/src/Cargo.lock
@@ -1247,6 +1247,7 @@ dependencies = [
"concat-text",
"concat-vision",
"cpal",
+ "libc",
"log",
"memmap2",
"png 0.17.16",
@@ -1254,6 +1255,7 @@ dependencies = [
"serde_json",
"sha2",
"ureq 2.12.1",
+ "windows-sys 0.61.2",
]
[[package]]
diff --git a/src/crates/concat-host/Cargo.toml b/src/crates/concat-host/Cargo.toml
index a15b10ba..e33fdd47 100644
--- a/src/crates/concat-host/Cargo.toml
+++ b/src/crates/concat-host/Cargo.toml
@@ -45,5 +45,12 @@ serde_json.workspace = true
cpal = "0.16"
memmap2 = "0.9"
+# The machine's memory, for sizing the caches to it; see memory.rs.
+[target.'cfg(unix)'.dependencies]
+libc = "0.2"
+
+[target.'cfg(windows)'.dependencies]
+windows-sys = { version = "0.61", features = ["Win32_System_SystemInformation"] }
+
[lints]
workspace = true
diff --git a/src/crates/concat-host/src/lib.rs b/src/crates/concat-host/src/lib.rs
index 212268c6..f4429f76 100644
--- a/src/crates/concat-host/src/lib.rs
+++ b/src/crates/concat-host/src/lib.rs
@@ -27,6 +27,7 @@ pub mod export;
pub mod jobs;
pub mod logs;
pub mod media;
+pub mod memory;
pub mod models;
pub mod playback;
pub mod preview;
@@ -58,7 +59,9 @@ pub fn scheduler() -> &'static std::sync::Arc<concat_media::Prefetcher> {
std::sync::OnceLock::new();
SCHEDULER.get_or_init(|| {
std::sync::Arc::new(concat_media::Prefetcher::with_defaults(
- std::sync::Arc::new(concat_media::ReaderPool::with_defaults()),
+ // The frame cache is a share of the machine's memory, not one
+ // size for a small laptop and a workstation alike.
+ std::sync::Arc::new(concat_media::ReaderPool::sized_for(memory::total())),
))
})
}
diff --git a/src/crates/concat-host/src/memory.rs b/src/crates/concat-host/src/memory.rs
new file mode 100644
index 00000000..4c9df441
--- /dev/null
+++ b/src/crates/concat-host/src/memory.rs
@@ -0,0 +1,58 @@
+// SPDX-License-Identifier: AGPL-3.0-or-later
+// SPDX-FileCopyrightText: 2026 Jareer and Concat contributors
+
+//! How much memory the machine has, for sizing the caches to it.
+//!
+//! One question, asked once: the frame cache is a share of it (see
+//! `concat_media::ReaderPool::frame_budget`). `None` where the platform
+//! will not say, and the caches fall back to the sizes they always had.
+
+/// The machine's physical memory, in bytes.
+pub fn total() -> Option<u64> {
+ static TOTAL: std::sync::OnceLock<Option<u64>> = std::sync::OnceLock::new();
+ *TOTAL.get_or_init(read)
+}
+
+/// Linux, Android, macOS and the other Unixes: the count of physical pages
+/// times their size, which every one of them answers through `sysconf`.
+#[cfg(unix)]
+fn read() -> Option<u64> {
+ // SAFETY: `sysconf` reads a system constant and has no preconditions;
+ // a negative answer means "not known" and is handled below.
+ let (pages, size) = unsafe {
+ (
+ libc::sysconf(libc::_SC_PHYS_PAGES),
+ libc::sysconf(libc::_SC_PAGESIZE),
+ )
+ };
+ (pages > 0 && size > 0).then(|| pages as u64 * size as u64)
+}
+
+/// Windows: `GlobalMemoryStatusEx`, the total physical memory it reports.
+#[cfg(windows)]
+fn read() -> Option<u64> {
+ use windows_sys::Win32::System::SystemInformation::{GlobalMemoryStatusEx, MEMORYSTATUSEX};
+ // SAFETY: the struct is plain data, zeroed and then given its own
+ // length as the call requires; the call only writes into it.
+ unsafe {
+ let mut status: MEMORYSTATUSEX = std::mem::zeroed();
+ status.dwLength = std::mem::size_of::<MEMORYSTATUSEX>() as u32;
+ (GlobalMemoryStatusEx(&mut status) != 0 && status.ullTotalPhys > 0)
+ .then_some(status.ullTotalPhys)
+ }
+}
+
+#[cfg(not(any(unix, windows)))]
+fn read() -> Option<u64> {
+ None
+}
+
+#[cfg(test)]
+mod tests {
+ /// Every machine the tests run on has some memory, and says how much.
+ #[test]
+ fn the_machine_says_how_much_memory_it_has() {
+ let total = super::total().expect("this platform answers");
+ assert!(total >= 512 * 1024 * 1024, "{total} bytes");
+ }
+}
diff --git a/src/crates/concat-host/src/preview.rs b/src/crates/concat-host/src/preview.rs
index 50837be8..98a9578e 100644
--- a/src/crates/concat-host/src/preview.rs
+++ b/src/crates/concat-host/src/preview.rs
@@ -109,6 +109,18 @@ impl Monitor {
}
}
+ /// Lets the GPU's frame textures go down to a quarter of their budget,
+ /// for when playback stops: the pool fills as frames stream past, and a
+ /// still picture needs only the few it shows. Nothing without a GPU.
+ pub fn shrink(&self) {
+ #[cfg(feature = "gpu")]
+ if let Some(gpu) = self.gpu.as_ref() {
+ gpu.lock()
+ .unwrap_or_else(|poisoned| poisoned.into_inner())
+ .shrink_pool(0.25);
+ }
+ }
+
/// A compositor of its own on the window's device, for work off the
/// monitor's thread - the effect cards. None without a GPU here.
#[cfg(feature = "gpu")]
diff --git a/src/crates/concat-host/src/titles.rs b/src/crates/concat-host/src/titles.rs
index a719083b..cc859b82 100644
--- a/src/crates/concat-host/src/titles.rs
+++ b/src/crates/concat-host/src/titles.rs
@@ -89,8 +89,11 @@ type LivePaintings = (
std::collections::VecDeque<u64>,
);
-/// How many live paintings are kept; see `Titles::live`.
-const LIVE_KEPT: usize = 16;
+/// The live paintings kept, in bytes of pixels; see `Titles::live`. Each
+/// is a picture the frame's size - 8 MB at 1080p, 33 MB at 4K - so a count
+/// cost four times as much on a 4K timeline as on an HD one. 128 MB keeps
+/// sixteen HD paintings or four 4K ones, and always the newest.
+const LIVE_BYTES: usize = 128 * 1024 * 1024;
impl Titles {
/// A painter that caches under the app's data directory.
@@ -267,7 +270,10 @@ impl Titles {
{
order.push_back(key);
}
- while order.len() > LIVE_KEPT {
+ let held = |kept: &HashMap<u64, (Art, Arc<Frame>)>| -> usize {
+ kept.values().map(|(_, frame)| frame.pixels().len()).sum()
+ };
+ while order.len() > 1 && held(kept) > LIVE_BYTES {
if let Some(oldest) = order.pop_front() {
kept.remove(&oldest);
}
diff --git a/src/crates/concat-media/src/pool.rs b/src/crates/concat-media/src/pool.rs
index 4d3881d4..cd92d205 100644
--- a/src/crates/concat-media/src/pool.rs
+++ b/src/crates/concat-media/src/pool.rs
@@ -460,6 +460,9 @@ struct Readers {
warm: HashMap<ReaderKey, Arc<Mutex<Reader>>>,
/// Recency order for reader eviction, oldest first.
order: Vec<ReaderKey>,
+ /// When each warm reader was last asked for; see
+ /// [`ReaderPool::close_idle`].
+ touched: HashMap<ReaderKey, std::time::Instant>,
/// Readers kept warm before the least-recently-used is dropped.
max: usize,
}
@@ -551,6 +554,7 @@ impl ReaderPool {
readers: Mutex::new(Readers {
warm: HashMap::new(),
order: Vec::new(),
+ touched: HashMap::new(),
max: max_readers.max(1),
}),
facts: Mutex::new(HashMap::new()),
@@ -565,6 +569,58 @@ impl ReaderPool {
Self::new(512 * 1024 * 1024, 8)
}
+ /// The frame cache a machine with `total_memory` bytes of RAM gets: a
+ /// sixteenth of it, between 256 MB and 1 GB - 512 MB on an 8 GB
+ /// machine, a gigabyte from 16 GB up. A fixed 512 MB was a sixteenth of
+ /// a small laptop's memory and a thirtieth of an editing workstation's.
+ /// Unknown memory gets the 512 MB the pool always had.
+ pub fn frame_budget(total_memory: Option<u64>) -> usize {
+ const MB: u64 = 1024 * 1024;
+ let bytes = match total_memory {
+ Some(total) => (total / 16).clamp(256 * MB, 1024 * MB),
+ None => 512 * MB,
+ };
+ usize::try_from(bytes).unwrap_or(usize::MAX)
+ }
+
+ /// A pool sized for a machine with `total_memory` bytes of RAM; see
+ /// [`ReaderPool::frame_budget`]. Eight warm readers at most, and those
+ /// not asked for in a while are closed by [`ReaderPool::close_idle`].
+ pub fn sized_for(total_memory: Option<u64>) -> Self {
+ Self::new(Self::frame_budget(total_memory), 8)
+ }
+
+ /// Closes the warm readers nobody has asked for in `idle`, and that no
+ /// decode is using now: a decoder holds its own buffers - a 4K one, a
+ /// hardware one, a good deal - and eight kept open for files the
+ /// playhead left long ago is memory spent on nothing. A reader closed
+ /// here is opened again on the next frame wanted from it, at the cost
+ /// of one seek. Returns how many went.
+ pub fn close_idle(&self, idle: std::time::Duration) -> usize {
+ let Ok(mut readers) = self.readers.lock() else {
+ return 0;
+ };
+ let now = std::time::Instant::now();
+ let doomed: Vec<ReaderKey> = readers
+ .warm
+ .iter()
+ .filter(|(key, reader)| {
+ Arc::strong_count(reader) == 1
+ && readers
+ .touched
+ .get(*key)
+ .is_none_or(|at| now.duration_since(*at) >= idle)
+ })
+ .map(|(key, _)| key.clone())
+ .collect();
+ for key in &doomed {
+ readers.warm.remove(key);
+ readers.touched.remove(key);
+ readers.order.retain(|entry| entry != key);
+ }
+ doomed.len()
+ }
+
/// Makes `frame` the still at `path`, a name no file has, until
/// [`STILLS_HELD`] newer ones have come. Frames already cut from an
/// earlier still of that name are let go, so the name never shows
@@ -1067,6 +1123,9 @@ impl ReaderPool {
})?;
readers.order.retain(|entry| entry != &key);
readers.order.push(key.clone());
+ readers
+ .touched
+ .insert(key.clone(), std::time::Instant::now());
if let Some(reader) = readers.warm.get(&key) {
return Ok(Arc::clone(reader));
}
@@ -1104,7 +1163,11 @@ impl ReaderPool {
break;
}
readers.warm.remove(&coldest);
+ readers.touched.remove(&coldest);
}
+ readers
+ .touched
+ .insert(key.clone(), std::time::Instant::now());
readers.warm.insert(key, Arc::clone(&opened));
Ok(opened)
}
@@ -1115,6 +1178,7 @@ impl ReaderPool {
if let Ok(mut readers) = self.readers.lock() {
readers.warm.clear();
readers.order.clear();
+ readers.touched.clear();
}
if let Ok(mut facts) = self.facts.lock() {
facts.clear();
@@ -1345,6 +1409,43 @@ pub(crate) mod tests {
/// frame at its level, fitted by no one here: no treated frame is made
/// and every size asked for is the same cached frame. With a chain it
/// is fitted and treated as before, `any_size` notwithstanding.
+ /// The frame cache is a sixteenth of the machine's memory, held
+ /// between 256 MB and 1 GB, and the old 512 MB when memory is unknown.
+ #[test]
+ fn the_frame_cache_is_sized_to_the_machine() {
+ const GB: u64 = 1024 * 1024 * 1024;
+ let mb = |bytes: usize| bytes / (1024 * 1024);
+ assert_eq!(mb(ReaderPool::frame_budget(Some(2 * GB))), 256);
+ assert_eq!(mb(ReaderPool::frame_budget(Some(8 * GB))), 512);
+ assert_eq!(mb(ReaderPool::frame_budget(Some(16 * GB))), 1024);
+ assert_eq!(mb(ReaderPool::frame_budget(Some(128 * GB))), 1024);
+ assert_eq!(mb(ReaderPool::frame_budget(None)), 512);
+ }
+
+ /// A reader nobody has asked for in a while is closed; one asked for
+ /// since is kept, and the next frame from a closed one opens it again.
+ #[test]
+ fn idle_readers_are_closed_and_reopened_on_demand() {
+ let path = counting_video("idle-readers", 32, 10);
+ let pool = ReaderPool::new(64 * 1024 * 1024, 4);
+ let at =
+ |frame: i64| FrameRequest::new(&path, FrameRate::THIRTY.time_of_frame(frame), 32, 32);
+ pool.frame(&at(1)).expect("decodes");
+ let warm = |pool: &ReaderPool| pool.readers.lock().expect("lock").warm.len();
+ assert_eq!(warm(&pool), 1);
+ assert_eq!(
+ pool.close_idle(std::time::Duration::from_secs(60)),
+ 0,
+ "fresh"
+ );
+ assert_eq!(warm(&pool), 1);
+ assert_eq!(pool.close_idle(std::time::Duration::ZERO), 1, "idle");
+ assert_eq!(warm(&pool), 0);
+ pool.frame(&at(7)).expect("decodes again");
+ assert_eq!(warm(&pool), 1);
+ let _ = std::fs::remove_file(&path);
+ }
+
#[test]
fn an_untreated_frame_at_any_size_is_the_source_itself() {
let path = counting_video("any-size", 64, 30);
diff --git a/src/crates/concat-render/src/gpu.rs b/src/crates/concat-render/src/gpu.rs
index a536314b..669748a0 100644
--- a/src/crates/concat-render/src/gpu.rs
+++ b/src/crates/concat-render/src/gpu.rs
@@ -561,9 +561,24 @@ struct PooledTexture {
/// still has rather than growing: the source-texture cache's budget. The
/// pool is also the cache - a frame uploaded stays in its texture until
/// the texture is wanted for something else - so a scrub back over ground
-/// the monitor has shown finds its frames on the device. 512 MB is 64
-/// frames at 1080p, or 256 at the monitor's usual 960 by 540.
-const POOL_BUDGET: u64 = 512 * 1024 * 1024;
+/// the monitor has shown finds its frames on the device.
+///
+/// Chosen by what the textures cost the machine. On a card of its own they
+/// live in the card's memory, which nothing else in the app wants: 512 MB,
+/// 64 frames at 1080p. On integrated graphics - Intel, AMD's APUs, Apple's
+/// chips - and on a virtual GPU they come out of system memory beside the
+/// frame cache, so half that; on the software adapter they are system
+/// memory outright, so a quarter.
+pub fn pool_budget_for(device: wgpu::DeviceType) -> u64 {
+ const MB: u64 = 1024 * 1024;
+ match device {
+ wgpu::DeviceType::DiscreteGpu => 512 * MB,
+ wgpu::DeviceType::Cpu => 128 * MB,
+ wgpu::DeviceType::IntegratedGpu
+ | wgpu::DeviceType::VirtualGpu
+ | wgpu::DeviceType::Other => 256 * MB,
+ }
+}
/// The LUTs and the reveal maps kept on the device, at most: a look is a
/// megabyte at 65 a side, and each one a person tries stayed on the device
@@ -683,8 +698,10 @@ pub struct WgpuCompositor {
/// composites a size has gone unclaimed: a timeline moves past a clip
/// size forever, and its textures should not outlive that by much.
pool: HashMap<(u32, u32), Vec<PooledTexture>>,
- /// What the pool's textures hold, in bytes; see [`POOL_BUDGET`].
+ /// What the pool's textures hold, in bytes; see [`pool_budget_for`].
pool_bytes: u64,
+ /// What `pool_bytes` may reach; see [`pool_budget_for`].
+ pool_budget: u64,
/// How many textures the pool holds; see [`POOL_TEXTURES`].
pool_textures: usize,
/// Composites drawn so far; see [`PooledTexture::drawn`].
@@ -813,6 +830,8 @@ impl WgpuCompositor {
/// Builds a compositor on a device the caller owns - the window's, so a
/// texture this draws is one the window can show.
pub fn with_device(device: wgpu::Device, queue: wgpu::Queue) -> Self {
+ // Read before the device moves into the compositor below.
+ let budget = pool_budget_for(device.adapter_info().device_type);
let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
label: Some("concat compositor"),
source: wgpu::ShaderSource::Wgsl(SHADER.into()),
@@ -1223,6 +1242,7 @@ impl WgpuCompositor {
vertex_capacity: 6 * 8,
pool: HashMap::new(),
pool_bytes: 0,
+ pool_budget: budget,
pool_textures: 0,
composites: 0,
uploads: 0,
@@ -2137,6 +2157,40 @@ impl WgpuCompositor {
}
}
+ /// Lets the pool go down to `share` of its budget, least recently drawn
+ /// first: what the monitor asks for when playback stops, so a pool that
+ /// filled while frames streamed past does not keep that memory while
+ /// the picture sits still. A scrub back over what was let go uploads
+ /// it again from the frame cache, which is quick.
+ pub fn shrink_pool(&mut self, share: f64) {
+ let keep = (self.pool_budget as f64 * share.clamp(0.0, 1.0)) as u64;
+ while self.pool_bytes > keep {
+ let oldest = self
+ .pool
+ .iter()
+ .flat_map(|(key, pool)| {
+ pool.iter()
+ .enumerate()
+ .map(move |(slot, texture)| (*key, slot, texture.drawn))
+ })
+ .min_by_key(|(_, _, drawn)| *drawn);
+ let Some((key, slot, _)) = oldest else {
+ break;
+ };
+ self.pool
+ .get_mut(&key)
+ .expect("found above")
+ .swap_remove(slot);
+ self.pool_bytes -= u64::from(key.0) * u64::from(key.1) * WORK_BYTES;
+ self.pool_textures -= 1;
+ }
+ }
+
+ /// The most the layer pool holds, in bytes; see [`pool_budget_for`].
+ pub fn pool_budget(&self) -> u64 {
+ self.pool_budget
+ }
+
/// Retires texture sizes the timeline has moved past. 300 unclaimed
/// composites (ten seconds of 30fps export) says a size is gone for
/// good, not just between two clips of it.
@@ -2177,7 +2231,7 @@ impl WgpuCompositor {
// Back under budget, least recently drawn first, never a texture
// this composite claimed: a pool grows past the budget only when
// one composite needs that much.
- while self.pool_bytes > POOL_BUDGET || self.pool_textures > POOL_TEXTURES {
+ while self.pool_bytes > self.pool_budget || self.pool_textures > POOL_TEXTURES {
let oldest = self
.pool
.iter()
@@ -2524,7 +2578,7 @@ impl WgpuCompositor {
let spare = (used..pool.len())
.find(|&slot| pool[slot].holds == 0)
.or_else(|| {
- (self.pool_bytes + bytes > POOL_BUDGET || self.pool_textures >= POOL_TEXTURES)
+ (self.pool_bytes + bytes > self.pool_budget || self.pool_textures >= POOL_TEXTURES)
.then(|| (used..pool.len()).min_by_key(|&slot| pool[slot].drawn))
.flatten()
});
diff --git a/src/crates/concat-render/src/gpu/tests.rs b/src/crates/concat-render/src/gpu/tests.rs
index 0baebf1e..ea959cc6 100644
--- a/src/crates/concat-render/src/gpu/tests.rs
+++ b/src/crates/concat-render/src/gpu/tests.rs
@@ -673,6 +673,17 @@ fn a_frame_drawn_before_is_not_uploaded_again() {
/// The pool keeps what it uploaded only up to its limits: a long run of
/// distinct frames - here more small ones than the texture cap - leaves it
/// holding no more than the cap and the byte budget allow.
+/// The pool costs system memory unless the card has its own, and its
+/// budget says so.
+#[test]
+fn the_pool_budget_follows_what_the_textures_cost() {
+ let discrete = pool_budget_for(wgpu::DeviceType::DiscreteGpu);
+ let integrated = pool_budget_for(wgpu::DeviceType::IntegratedGpu);
+ let software = pool_budget_for(wgpu::DeviceType::Cpu);
+ assert_eq!(discrete, 512 * 1024 * 1024);
+ assert!(discrete > integrated && integrated > software);
+}
+
#[test]
fn the_pool_stays_within_its_limits() {
let Some(mut gpu) = gpu() else { return };
@@ -693,7 +704,13 @@ fn the_pool_stays_within_its_limits() {
"{} textures",
gpu.pool_textures
);
- assert!(gpu.pool_bytes <= POOL_BUDGET);
+ assert!(gpu.pool_bytes <= gpu.pool_budget);
+ // Shrunk when playback stops: down to the share asked for, oldest
+ // first, and back to nothing on zero.
+ gpu.shrink_pool(0.25);
+ assert!(gpu.pool_bytes <= gpu.pool_budget / 4);
+ gpu.shrink_pool(0.0);
+ assert_eq!((gpu.pool_bytes, gpu.pool_textures), (0, 0));
let counted: usize = gpu.pool.values().map(Vec::len).sum();
assert_eq!(counted, gpu.pool_textures, "the count is the pool's");
}
diff --git a/src/crates/concat/src/host.rs b/src/crates/concat/src/host.rs
index 6e2f6701..f23b0978 100644
--- a/src/crates/concat/src/host.rs
+++ b/src/crates/concat/src/host.rs
@@ -271,7 +271,10 @@ fn spawn_at<T: Send + 'static>(
work: impl FnOnce() -> T + Send + 'static,
then: impl FnOnce(&mut Studio, &App, &Models, T) + Send + 'static,
) {
- concat_host::scheduler().submit(priority, move || deliver(None, work(), then));
+ // Art is of the project open when it was asked for: a strip still
+ // decoding when another project opens is dropped, not filed under it.
+ let epoch = project_epoch();
+ concat_host::scheduler().submit(priority, move || deliver(Some(epoch), work(), then));
}
/// Runs `body` on the event-loop thread from anywhere, with a full publish
diff --git a/src/crates/concat/src/lib.rs b/src/crates/concat/src/lib.rs
index 6c147046..7c9bee63 100644
--- a/src/crates/concat/src/lib.rs
+++ b/src/crates/concat/src/lib.rs
@@ -1789,7 +1789,26 @@ pub fn run() -> Result<(), slint::PlatformError> {
shell.studio.borrow().publish(&app, &shell.models);
}
+ // Decoders nobody has asked a frame of for ten seconds are closed,
+ // looked at every five: each holds buffers of its own, and the playhead
+ // leaves files behind. One reopens on its next frame. Held here, for
+ // the life of the loop.
+ let reader_sweep = slint::Timer::default();
+ reader_sweep.start(
+ slint::TimerMode::Repeated,
+ std::time::Duration::from_secs(5),
+ || {
+ let closed = concat_host::scheduler()
+ .pool()
+ .close_idle(std::time::Duration::from_secs(10));
+ if closed > 0 {
+ log::debug!("memory: closed {closed} idle decoder(s)");
+ }
+ },
+ );
+
let result = app.run();
+ drop(reader_sweep);
log::info!("close: event loop exited (ok={})", result.is_ok());
std::process::exit(0);
}
diff --git a/src/crates/concat/src/studio.rs b/src/crates/concat/src/studio.rs
index a7acd874..526c230d 100644
--- a/src/crates/concat/src/studio.rs
+++ b/src/crates/concat/src/studio.rs
@@ -2058,6 +2058,21 @@ impl Studio {
/// Asks before the track on lane `row` goes, empty or not: a track is
/// a whole lane of the cut, and the button that drops it sits beside
/// the ones that hide and mute it.
+ /// Lets go of every picture and waveform made for the project's media,
+ /// as a project closes or another opens: the bin's thumbnails, the
+ /// filmstrips, the waveform pyramids and their drawn envelopes. They
+ /// were never dropped, so each project opened in a session added its
+ /// art to the last one's until the app quit.
+ fn forget_art(&mut self) {
+ self.peaks.clear();
+ self.strips.clear();
+ self.windows.clear();
+ self.art_pending.clear();
+ self.window_pending.clear();
+ self.waves.borrow_mut().clear();
+ self.media.thumbs.clear();
+ }
+
pub fn ask_remove_track(&mut self, row: i32) {
let Some(track_id) = self.row_track(row).map(|track| track.id.clone()) else {
return;
@@ -2657,9 +2672,14 @@ impl Studio {
if self.playing {
log::debug!("playback: paused at {:.3}s", self.playhead);
}
+ let was_playing = self.playing;
self.playing = false;
self.transport.stop();
self.host.playback.pause();
+ // The textures playback streamed through are let go once it stops.
+ if was_playing {
+ self.host.monitor.shrink();
+ }
}
/// Moves the playhead, the transport with it, and asks for the frame.
@@ -6779,6 +6799,7 @@ impl Studio {
}
self.session = Some(session);
crate::host::next_project_epoch();
+ self.forget_art();
self.art_failed.clear();
self.art_stamp = None;
self.proxied.clear();
@@ -6926,6 +6947,7 @@ impl Studio {
// Whatever a worker still brings back for this project is dropped
// at delivery; the sheets that were waiting on one stop waiting.
crate::host::next_project_epoch();
+ self.forget_art();
self.art_failed.clear();
self.art_stamp = None;
self.proxied.clear();