diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index f63cb5ffae9..d174d54ae9c 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -814,10 +814,13 @@ impl IOCompositor { let Some(webview_renderer) = self.webview_renderers.get_mut(webview_id) else { return warn!("Could not find WebView for incoming display list"); }; + webview_renderer.epoch_not_synchronized.set(true); let pipeline_id = display_list_info.pipeline_id; let details = webview_renderer.ensure_pipeline_details(pipeline_id.into()); + details.most_recent_display_list_epoch = Some(display_list_info.epoch); + details.hit_test_items = display_list_info.hit_test_info; details.install_new_scroll_tree(display_list_info.scroll_tree); @@ -1662,6 +1665,7 @@ impl IOCompositor { // Process all pending events self.webview_renderers.iter().for_each(|webview| { webview.dispatch_pending_input_events(); + webview.epoch_not_synchronized.set(false); }); } diff --git a/components/compositing/webview_renderer.rs b/components/compositing/webview_renderer.rs index d730a148e92..19535c7e785 100644 --- a/components/compositing/webview_renderer.rs +++ b/components/compositing/webview_renderer.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use std::cell::RefCell; +use std::cell::{Cell, RefCell}; use std::collections::hash_map::Keys; use std::collections::{HashMap, VecDeque}; use std::rc::Rc; @@ -100,6 +100,8 @@ pub(crate) struct WebViewRenderer { animating: bool, /// Pending input events queue. Priavte and only this thread pushes events to it. pending_input_events: RefCell>, + /// Flag to indicate that the epoch has been not synchronized yet. + pub epoch_not_synchronized: Cell, } impl Drop for WebViewRenderer { @@ -135,6 +137,7 @@ impl WebViewRenderer { hidpi_scale_factor: Scale::new(hidpi_scale_factor.0), animating: false, pending_input_events: Default::default(), + epoch_not_synchronized: Cell::default(), } } @@ -319,7 +322,7 @@ impl WebViewRenderer { return; }; - if self.pending_input_events.borrow().len() > 0 { + if self.epoch_not_synchronized.get() { self.pending_input_events.borrow_mut().push_back(event); return; }