fix(gpu,ui-egui): await render workers and GPU warm-up on app drop

This commit is contained in:
Dylan M. Taylor committed 2026-11-23 10:30:47 -05:00
1 parent 98b3cf82bf
commit 3cb0924aff
2 files changed
+22 -1

No files matched your search

+6 -1
View File
@@ -349,7 +349,12 @@ pub fn warm_up() {
if STARTED.swap(true, Ordering::SeqCst) {
return;
}
let spawned = std::thread::Builder::new().name("lc-gpu-init".into()).spawn(|| {
let Some(work) = exit::enter() else {
STARTED.store(false, Ordering::SeqCst);
return;
};
let spawned = std::thread::Builder::new().name("lc-gpu-init".into()).spawn(move || {
let _work = work;
loop {
let _ = device();
if GPU.get().is_some() || shutting_down() || env_disabled() {
+16
View File
@@ -641,7 +641,23 @@ impl LightcraftApp {
let idle = lightcraft_engine::gpu::wait_idle(timeout);
stopped && idle
}
}
/// Dropping the app (including in one-test `nextest` processes that never call [`Self::shutdown`])
/// must not leave render workers or the GPU warm-up thread inside the driver when the process exits
/// (issue #620). Does not call [`lightcraft_engine::gpu::begin_shutdown`] so multiple tests in one
/// `cargo test` process can still use the GPU afterwards.
impl Drop for LightcraftApp {
fn drop(&mut self) {
#[cfg(not(target_arch = "wasm32"))]
{
self.renderer.shutdown(std::time::Duration::from_secs(30));
let _ = lightcraft_engine::gpu::wait_idle(std::time::Duration::from_secs(30));
}
}
}
impl LightcraftApp {
/// Background and queue work. Called before layout on every host pass and, while the window is
/// hidden, from `Context::run_logic`. It may read the refreshed viewport fields only: never
/// `i.time`, events, keys or dropped files.