Skip to content

Commit

Permalink
Fix crash on Android
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Dec 4, 2023
1 parent 84a6d6f commit a474724
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions crates/eframe/src/native/wgpu_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,13 +388,25 @@ impl WinitApp for WgpuWinitApp {
self.init_run_state(egui_ctx, event_loop, storage, window, builder)?
};

EventResult::RepaintNow(
running.shared.borrow().viewports[&ViewportId::ROOT]
.window
.as_ref()
.unwrap()
.id(),
)
let SharedState {
egui_ctx,
viewports,
painter,
viewport_from_window,
..
} = &mut *running.shared.borrow_mut();

let viewport = viewports.get_mut(&ViewportId::ROOT).unwrap();

if viewport.window.is_none() {
viewport.init_window(egui_ctx, viewport_from_window, painter, event_loop);
}

if let Some(window) = &viewport.window {
EventResult::RepaintNow(window.id())
} else {
EventResult::Wait
}
}

winit::event::Event::Suspended => {
Expand Down

0 comments on commit a474724

Please sign in to comment.