Skip to content

Commit 200051d

Browse files
authored
Fix Android crash on resume with Glow backend (#3867)
Addition for <#3847> In previous one i only fixed crash occurring with Wgpu backend. This fixes crash with Glow backend as well. I only tested this change with android so most things i changed are behind ```#[cfg(target_os = "android")]```. Both fixes are dirty thought. As <#3172> says that "The root viewport is the original viewport, and cannot be closed without closing the application.". So they break rules i guess? But i can't think about better solution for now. Closes <#3861>.
1 parent 5e7fa46 commit 200051d

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

crates/eframe/src/native/glow_integration.rs

+3-13
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,6 @@ use super::{
3939
*,
4040
};
4141

42-
// Note: that the current Glutin API design tightly couples the GL context with
43-
// the Window which means it's not practically possible to just destroy the
44-
// window and re-create a new window while continuing to use the same GL context.
45-
//
46-
// For now this means it's not possible to support Android as well as we can with
47-
// wgpu because we're basically forced to destroy and recreate _everything_ when
48-
// the application suspends and resumes.
49-
//
50-
// There is work in progress to improve the Glutin API so it has a separate Surface
51-
// API that would allow us to just destroy a Window/Surface when suspending, see:
52-
// https://github.com/rust-windowing/glutin/pull/1435
53-
5442
// ----------------------------------------------------------------------------
5543
// Types:
5644

@@ -525,7 +513,9 @@ impl GlowWinitRunning {
525513
let mut glutin = self.glutin.borrow_mut();
526514
let egui_ctx = glutin.egui_ctx.clone();
527515
let viewport = glutin.viewports.get_mut(&viewport_id).unwrap();
528-
let window = viewport.window.as_ref().unwrap();
516+
let Some(window) = viewport.window.as_ref() else {
517+
return EventResult::Wait;
518+
};
529519
egui_winit::update_viewport_info(&mut viewport.info, &egui_ctx, window);
530520

531521
let egui_winit = viewport.egui_winit.as_mut().unwrap();

0 commit comments

Comments
 (0)