File tree 1 file changed +19
-0
lines changed
examples/runners/wgpu/src
1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -164,6 +164,25 @@ async fn run(
164
164
event_loop_window_target. set_control_flow ( ControlFlow :: Wait ) ;
165
165
match event {
166
166
Event :: Resumed => {
167
+ // Avoid holding onto to multiple surfaces at the same time
168
+ // (as it's undetected and can confusingly break e.g. Wayland).
169
+ //
170
+ // FIXME(eddyb) create the window and `wgpu::Surface` on either
171
+ // `Event::NewEvents(StartCause::Init)`, or `Event::Resumed`,
172
+ // which is becoming recommended on (almost) all platforms, see:
173
+ // - https://github.com/rust-windowing/winit/releases/tag/v0.30.0
174
+ // - https://github.com/gfx-rs/wgpu/blob/v23/examples/src/framework.rs#L139-L161
175
+ // (note wasm being handled differently due to its `<canvas>`)
176
+ if let Ok ( ( _, surface_config) ) = & surface_with_config {
177
+ // HACK(eddyb) can't move out of `surface_with_config` as
178
+ // it's a closure capture, and also the `Err(_)` variant
179
+ // has a payload so that needs to be filled with something.
180
+ let filler = Err ( SurfaceCreationPending {
181
+ preferred_format : surface_config. format ,
182
+ } ) ;
183
+ drop ( std:: mem:: replace ( & mut surface_with_config, filler) ) ;
184
+ }
185
+
167
186
let new_surface = instance. create_surface ( & window)
168
187
. expect ( "Failed to create surface from window (after resume)" ) ;
169
188
surface_with_config = Ok ( auto_configure_surface (
You can’t perform that action at this time.
0 commit comments