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 hacknus committed Oct 30, 2024
1 parent 2c4285c commit 2929aa6
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 2929aa6

Please sign in to comment.