From 0df79b939a642027325c2e050f07eefcf569d87d Mon Sep 17 00:00:00 2001 From: Martin Robinson Date: Thu, 2 May 2024 05:58:15 +0200 Subject: [PATCH] compositor: Do not handle embedder events during or after shutdown (#32207) This is a speculative fix for #32202, which I cannot reproduce consistently. This prevents handling any embedder events while shutting down or after shutdown is complete. It doesn't make sense to do this as the compositor can be in a very inconsistent state during this time and lead to panics. Fixes ##32202. --- components/compositing/compositor.rs | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index 19cecbcf55d..2520f9235ab 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -1416,6 +1416,10 @@ impl IOCompositor { } pub fn on_mouse_window_event_class(&mut self, mouse_window_event: MouseWindowEvent) { + if self.shutdown_state != ShutdownState::NotShuttingDown { + return; + } + if self.convert_mouse_to_touch { match mouse_window_event { MouseWindowEvent::Click(_, _) => {}, @@ -1513,6 +1517,10 @@ impl IOCompositor { } pub fn on_mouse_window_move_event_class(&mut self, cursor: DevicePoint) { + if self.shutdown_state != ShutdownState::NotShuttingDown { + return; + } + if self.convert_mouse_to_touch { self.on_touch_move(TouchId(0), cursor); return; @@ -1571,6 +1579,10 @@ impl IOCompositor { identifier: TouchId, location: DevicePoint, ) { + if self.shutdown_state != ShutdownState::NotShuttingDown { + return; + } + match event_type { TouchEventType::Down => self.on_touch_down(identifier, location), TouchEventType::Move => self.on_touch_move(identifier, location), @@ -1638,6 +1650,10 @@ impl IOCompositor { } pub fn on_wheel_event(&mut self, delta: WheelDelta, p: DevicePoint) { + if self.shutdown_state != ShutdownState::NotShuttingDown { + return; + } + self.send_wheel_event(delta, p); } @@ -1647,6 +1663,10 @@ impl IOCompositor { cursor: DeviceIntPoint, phase: TouchEventType, ) { + if self.shutdown_state != ShutdownState::NotShuttingDown { + return; + } + match phase { TouchEventType::Move => self.on_scroll_window_event(scroll_location, cursor), TouchEventType::Up | TouchEventType::Cancel => { @@ -1860,11 +1880,19 @@ impl IOCompositor { } pub fn on_zoom_reset_window_event(&mut self) { + if self.shutdown_state != ShutdownState::NotShuttingDown { + return; + } + self.page_zoom = Scale::new(1.0); self.update_after_zoom_or_hidpi_change(); } pub fn on_zoom_window_event(&mut self, magnification: f32) { + if self.shutdown_state != ShutdownState::NotShuttingDown { + return; + } + self.page_zoom = Scale::new( (self.page_zoom.get() * magnification) .max(MIN_ZOOM) @@ -1887,6 +1915,10 @@ impl IOCompositor { /// Simulate a pinch zoom pub fn on_pinch_zoom_window_event(&mut self, magnification: f32) { + if self.shutdown_state != ShutdownState::NotShuttingDown { + return; + } + // TODO: Scroll to keep the center in view? self.pending_scroll_zoom_events .push(ScrollZoomEvent::PinchZoom(magnification));