Skip to content

Commit ea8315e

Browse files
kpreidcwfitzgerald
authored andcommitted
Change uncaptured error handler pointer type from Box to Arc.
This will be necessary for the next change.
1 parent 2e8a600 commit ea8315e

File tree

6 files changed

+9
-8
lines changed

6 files changed

+9
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ By @Vecvec in [#7913](https://github.com/gfx-rs/wgpu/pull/7913).
7272
- Copies of depth/stencil formats must be 4B aligned.
7373
- The offset for `set_vertex_buffer` and `set_index_buffer` must be 4B aligned. By @andyleiserson in [#7929](https://github.com/gfx-rs/wgpu/pull/7929).
7474
- The offset and size of bindings are validated as fitting within the underlying buffer in more cases. By @andyleiserson in [#7911](https://github.com/gfx-rs/wgpu/pull/7911).
75-
- The function you pass to `Device::on_uncaptured_error()` must now implement `Sync` in addition to `Send`.
75+
- The function you pass to `Device::on_uncaptured_error()` must now implement `Sync` in addition to `Send`, and be wrapped in `Arc` instead of `Box`.
7676
By @kpreid in [#8011](https://github.com/gfx-rs/wgpu/pull/8011).
7777

7878
#### Naga

examples/standalone/custom_backend/src/custom.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ impl DeviceInterface for CustomDevice {
240240
unimplemented!()
241241
}
242242

243-
fn on_uncaptured_error(&self, _handler: Box<dyn wgpu::UncapturedErrorHandler>) {
243+
fn on_uncaptured_error(&self, _handler: Arc<dyn wgpu::UncapturedErrorHandler>) {
244244
unimplemented!()
245245
}
246246

wgpu/src/api/device.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,8 @@ impl Device {
407407
QuerySet { inner: query_set }
408408
}
409409

410-
/// Set a callback for errors that are not handled in error scopes.
411-
pub fn on_uncaptured_error(&self, handler: Box<dyn UncapturedErrorHandler>) {
410+
/// Set a callback which will be called for all errors that are not handled in error scopes.
411+
pub fn on_uncaptured_error(&self, handler: Arc<dyn UncapturedErrorHandler>) {
412412
self.inner.on_uncaptured_error(handler)
413413
}
414414

wgpu/src/backend/webgpu.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use alloc::{
1010
format,
1111
rc::Rc,
1212
string::{String, ToString as _},
13+
sync::Arc,
1314
vec,
1415
vec::Vec,
1516
};
@@ -2409,7 +2410,7 @@ impl dispatch::DeviceInterface for WebDevice {
24092410
closure.forget();
24102411
}
24112412

2412-
fn on_uncaptured_error(&self, handler: Box<dyn crate::UncapturedErrorHandler>) {
2413+
fn on_uncaptured_error(&self, handler: Arc<dyn crate::UncapturedErrorHandler>) {
24132414
let f = Closure::wrap(Box::new(move |event: webgpu_sys::GpuUncapturedErrorEvent| {
24142415
let error = crate::Error::from_js(event.error().value_of());
24152416
handler(error);

wgpu/src/backend/wgpu_core.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ struct ErrorScope {
617617

618618
struct ErrorSinkRaw {
619619
scopes: Vec<ErrorScope>,
620-
uncaptured_handler: Option<Box<dyn crate::UncapturedErrorHandler>>,
620+
uncaptured_handler: Option<Arc<dyn crate::UncapturedErrorHandler>>,
621621
}
622622

623623
impl ErrorSinkRaw {
@@ -1757,7 +1757,7 @@ impl dispatch::DeviceInterface for CoreDevice {
17571757
.device_set_device_lost_closure(self.id, device_lost_callback);
17581758
}
17591759

1760-
fn on_uncaptured_error(&self, handler: Box<dyn crate::UncapturedErrorHandler>) {
1760+
fn on_uncaptured_error(&self, handler: Arc<dyn crate::UncapturedErrorHandler>) {
17611761
let mut error_sink = self.error_sink.lock();
17621762
error_sink.uncaptured_handler = Some(handler);
17631763
}

wgpu/src/dispatch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ pub trait DeviceInterface: CommonTraits {
185185

186186
fn set_device_lost_callback(&self, device_lost_callback: BoxDeviceLostCallback);
187187

188-
fn on_uncaptured_error(&self, handler: Box<dyn crate::UncapturedErrorHandler>);
188+
fn on_uncaptured_error(&self, handler: Arc<dyn crate::UncapturedErrorHandler>);
189189
fn push_error_scope(&self, filter: crate::ErrorFilter);
190190
fn pop_error_scope(&self) -> Pin<Box<dyn PopErrorScopeFuture>>;
191191

0 commit comments

Comments
 (0)