From 9e80fc9d1d67380268e8ed7e35231cdffe9fa5b1 Mon Sep 17 00:00:00 2001 From: sagudev <16504129+sagudev@users.noreply.github.com> Date: Thu, 22 Oct 2026 11:47:05 +0200 Subject: [PATCH] [core] Do device validity check at the start of `try_map_async` this is important as we need to return Abort error instead of Operation error which is raised on invalid buffer Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --- wgpu-core/src/resource.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/wgpu-core/src/resource.rs b/wgpu-core/src/resource.rs index 12870b517..3ab2334e4 100644 --- a/wgpu-core/src/resource.rs +++ b/wgpu-core/src/resource.rs @@ -831,6 +831,11 @@ impl Buffer { self.size.saturating_sub(offset) }; + let device = &self.device; + if let Err(e) = device.check_is_valid() { + return Err((callback, e.into())); + } + if let Err(e) = self.check_is_valid() { return Err((callback, e.into())); } @@ -882,11 +887,6 @@ impl Buffer { return Err((callback, e.into())); } - let device = &self.device; - if let Err(e) = device.check_is_valid() { - return Err((callback, e.into())); - } - let submit_index = { let snatch_guard = device.snatchable_lock.read(); if let Err(e) = self.check_destroyed(&snatch_guard) {