diff --git a/wgpu-core/src/device/global.rs b/wgpu-core/src/device/global.rs index fa6ece21d4..d8f1c0f5d0 100644 --- a/wgpu-core/src/device/global.rs +++ b/wgpu-core/src/device/global.rs @@ -2296,12 +2296,12 @@ impl Global { log::info!("configuring surface with {:?}", config); let error = 'outer: loop { - let hub = A::hub(self); - let mut token = Token::root(); - // User callbacks must not be called while we are holding locks. let user_callbacks; { + let hub = A::hub(self); + let mut token = Token::root(); + let (mut surface_guard, mut token) = self.surfaces.write(&mut token); let (adapter_guard, mut token) = hub.adapters.read(&mut token); let (device_guard, mut token) = hub.devices.read(&mut token);