From b54e1c7dbeaec8cd2447fd9786c5428f4ce4c74c Mon Sep 17 00:00:00 2001 From: Garoven Date: Fri, 19 Jan 2024 14:04:22 +0100 Subject: [PATCH] fixed android on resume crash --- crates/eframe/src/native/wgpu_integration.rs | 28 ++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/crates/eframe/src/native/wgpu_integration.rs b/crates/eframe/src/native/wgpu_integration.rs index 79e94e527f1..56847b92124 100644 --- a/crates/eframe/src/native/wgpu_integration.rs +++ b/crates/eframe/src/native/wgpu_integration.rs @@ -139,6 +139,32 @@ impl WgpuWinitApp { } } + #[cfg(target_os = "android")] + fn recreate_window( + &self, + event_loop: &EventLoopWindowTarget, + running: &WgpuWinitRunning, + ) { + let SharedState { + egui_ctx, + viewports, + viewport_from_window, + painter, + .. + } = &mut *running.shared.borrow_mut(); + + initialize_or_update_viewport( + egui_ctx, + viewports, + ViewportIdPair::ROOT, + ViewportClass::Root, + self.native_options.viewport.clone(), + None, + None, + ) + .initialize_window(event_loop, egui_ctx, viewport_from_window, painter); + } + #[cfg(target_os = "android")] fn drop_window(&mut self) -> Result<(), egui_wgpu::WgpuError> { if let Some(running) = &mut self.running { @@ -386,6 +412,8 @@ impl WinitApp for WgpuWinitApp { log::debug!("Event::Resumed"); let running = if let Some(running) = &self.running { + #[cfg(target_os = "android")] + self.recreate_window(event_loop, running); running } else { let storage = epi_integration::create_storage(