Skip to content

Commit

Permalink
Workaround for wgpu crash when surface is dropped last (emilk#4876)
Browse files Browse the repository at this point in the history
* Fixes emilk#4874
* Details see gfx-rs/wgpu#6052
  • Loading branch information
Wumpf authored and 486c committed Oct 9, 2024
1 parent 1fc15c4 commit 4d45671
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 4d45671

Please sign in to comment.