From adfd6a12f85b86ca35b17a31847fb86290360b7c Mon Sep 17 00:00:00 2001 From: Rhaskia Date: Sat, 17 Jan 2026 13:37:28 +1300 Subject: [PATCH] add android_sync_lock to wry event handler to avoid refcell errors (#5190) * add android_sync_lock to wry event handler to avoid refcell errors * rustfmt * move sync lock to apply_event --- packages/desktop/src/event_handlers.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/desktop/src/event_handlers.rs b/packages/desktop/src/event_handlers.rs index 428995e10..ae9895635 100644 --- a/packages/desktop/src/event_handlers.rs +++ b/packages/desktop/src/event_handlers.rs @@ -53,12 +53,17 @@ impl WindowEventHandlers { target: &EventLoopWindowTarget, ) { for (_, handler) in self.handlers.borrow_mut().iter_mut() { + // Avoid interacting with the runtime while something else is using it + #[cfg(target_os = "android")] + let _lock = crate::android_sync_lock::android_runtime_lock(); + // if this event does not apply to the window this listener cares about, continue if let Event::WindowEvent { window_id, .. } = event { if *window_id != handler.window_id { continue; } } + (handler.handler)(event, target) } }