diff options
author | 2021-08-05 14:44:32 +0700 | |
---|---|---|
committer | 2021-08-05 14:44:32 +0700 | |
commit | 45778ed598c0d202f8e86c47a444fd671fb3abce (patch) | |
tree | f0d7cd40b34bf4dca465fb6fd8fdeec5b0209e72 /winit | |
parent | 63bdbf817e0ecd8ce9162f2b8cc5eaefb5b42e68 (diff) | |
parent | 3e03a42bc69562639784a1b560978bf184576824 (diff) | |
download | iced-45778ed598c0d202f8e86c47a444fd671fb3abce.tar.gz iced-45778ed598c0d202f8e86c47a444fd671fb3abce.tar.bz2 iced-45778ed598c0d202f8e86c47a444fd671fb3abce.zip |
Merge pull request #667 from BillyDM/wgpu_outdatedframe
Don't panic when wgpu swapchain frame is outdated
Diffstat (limited to 'winit')
-rw-r--r-- | winit/src/application.rs | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/winit/src/application.rs b/winit/src/application.rs index 5d1aabf9..1d32a5f3 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -366,27 +366,43 @@ async fn run_instance<A, E, C>( viewport_version = current_viewport_version; } - let new_mouse_interaction = compositor.draw( + match compositor.draw( &mut renderer, &mut swap_chain, state.viewport(), state.background_color(), &primitive, &debug.overlay(), - ); + ) { + Ok(new_mouse_interaction) => { + debug.render_finished(); - debug.render_finished(); + if new_mouse_interaction != mouse_interaction { + window.set_cursor_icon( + conversion::mouse_interaction( + new_mouse_interaction, + ), + ); - if new_mouse_interaction != mouse_interaction { - window.set_cursor_icon(conversion::mouse_interaction( - new_mouse_interaction, - )); + mouse_interaction = new_mouse_interaction; + } - mouse_interaction = new_mouse_interaction; + // TODO: Handle animations! + // Maybe we can use `ControlFlow::WaitUntil` for this. + } + Err(error) => match error { + // This is an unrecoverable error. + window::SwapChainError::OutOfMemory => { + panic!("{}", error); + } + _ => { + debug.render_finished(); + + // Try rendering again next frame. + window.request_redraw(); + } + }, } - - // TODO: Handle animations! - // Maybe we can use `ControlFlow::WaitUntil` for this. } event::Event::WindowEvent { event: event::WindowEvent::MenuEntryActivated(entry_id), |