diff --git a/wgpu-core/src/hub.rs b/wgpu-core/src/hub.rs index 30d528c879..d61e042e90 100644 --- a/wgpu-core/src/hub.rs +++ b/wgpu-core/src/hub.rs @@ -25,7 +25,7 @@ use wgt::Backend; #[cfg(debug_assertions)] use std::cell::Cell; -use std::{fmt::Debug, marker::PhantomData, ops}; +use std::{fmt::Debug, marker::PhantomData, ops, thread}; /// A simple structure to manage identities of objects. #[derive(Debug)] @@ -553,10 +553,12 @@ impl Global { impl Drop for Global { fn drop(&mut self) { - log::info!("Dropping Global"); - // destroy surfaces - for (_, (surface, _)) in self.surfaces.data.write().map.drain() { - self.instance.destroy_surface(surface); + if !thread::panicking() { + log::info!("Dropping Global"); + // destroy surfaces + for (_, (surface, _)) in self.surfaces.data.write().map.drain() { + self.instance.destroy_surface(surface); + } } } }