Skip to content

Commit

Permalink
Workaround for wgpu crash when surface is dropped last (#4876)
Browse files Browse the repository at this point in the history
* Fixes #4874
* Details see gfx-rs/wgpu#6052
  • Loading branch information
Wumpf committed Jul 26, 2024
1 parent 34db001 commit 64d5f94
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions crates/egui-wgpu/src/winit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,17 @@ pub struct Painter {
surfaces: ViewportIdMap<SurfaceState>,
}

impl Drop for Painter {
fn drop(&mut self) {
// Drop surfaces before dropping the render state.
//
// This is a workaround for a bug in wgpu 22.0.0.
// Fixed in https://github.com/gfx-rs/wgpu/pull/6052
// Remove with wgpu 22.1.0 update!
self.surfaces.clear();
}
}

impl Painter {
/// Manages [`wgpu`] state, including surface state, required to render egui.
///
Expand Down

0 comments on commit 64d5f94

Please sign in to comment.