Skip to content

Commit f04c093

Browse files
committed
Drop recordings (and blueprints) on separate threads.
This prevents the UI from hanging while dropping a large recording, which is useful when the user is trying to close multiple recordings at once. If threads are not available, automatically falls back to dropping on the current thread.
1 parent c62c77f commit f04c093

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

crates/viewer/re_viewer_context/src/store_hub.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,21 @@ impl StoreHub {
340340
.retain(|_, id| id != store_id);
341341
}
342342
}
343+
344+
// Drop the store itself on a separate thread,
345+
// so that recursing through it and freeing the memory doesn’t block the UI thread.
346+
#[allow(
347+
clippy::allow_attributes,
348+
clippy::disallowed_methods,
349+
reason = "If this thread spawn fails due to running on Wasm (or for any other reason),
350+
the error will be ignored and the store will be dropped on this thread."
351+
)]
352+
let (Ok(_) | Err(_)) = std::thread::Builder::new()
353+
.name("drop-removed-store".into())
354+
.spawn(|| {
355+
re_tracing::profile_scope!("drop store");
356+
drop(removed_store);
357+
});
343358
}
344359

345360
pub fn remove(&mut self, entry: &RecordingOrTable) {

0 commit comments

Comments
 (0)