Add flag for epoch mismatch

Signed-off-by: batu_hoang <longvatrong111@gmail.com>
This commit is contained in:
batu_hoang 2025-05-28 18:03:52 +08:00
parent ddad26f6c8
commit 54d37638b4
2 changed files with 9 additions and 2 deletions

View file

@ -814,10 +814,13 @@ impl IOCompositor {
let Some(webview_renderer) = self.webview_renderers.get_mut(webview_id) else { let Some(webview_renderer) = self.webview_renderers.get_mut(webview_id) else {
return warn!("Could not find WebView for incoming display list"); 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 pipeline_id = display_list_info.pipeline_id;
let details = webview_renderer.ensure_pipeline_details(pipeline_id.into()); let details = webview_renderer.ensure_pipeline_details(pipeline_id.into());
details.most_recent_display_list_epoch = Some(display_list_info.epoch); details.most_recent_display_list_epoch = Some(display_list_info.epoch);
details.hit_test_items = display_list_info.hit_test_info; details.hit_test_items = display_list_info.hit_test_info;
details.install_new_scroll_tree(display_list_info.scroll_tree); details.install_new_scroll_tree(display_list_info.scroll_tree);
@ -1662,6 +1665,7 @@ impl IOCompositor {
// Process all pending events // Process all pending events
self.webview_renderers.iter().for_each(|webview| { self.webview_renderers.iter().for_each(|webview| {
webview.dispatch_pending_input_events(); webview.dispatch_pending_input_events();
webview.epoch_not_synchronized.set(false);
}); });
} }

View file

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * 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::hash_map::Keys;
use std::collections::{HashMap, VecDeque}; use std::collections::{HashMap, VecDeque};
use std::rc::Rc; use std::rc::Rc;
@ -100,6 +100,8 @@ pub(crate) struct WebViewRenderer {
animating: bool, animating: bool,
/// Pending input events queue. Priavte and only this thread pushes events to it. /// Pending input events queue. Priavte and only this thread pushes events to it.
pending_input_events: RefCell<VecDeque<InputEvent>>, pending_input_events: RefCell<VecDeque<InputEvent>>,
/// Flag to indicate that the epoch has been not synchronized yet.
pub epoch_not_synchronized: Cell<bool>,
} }
impl Drop for WebViewRenderer { impl Drop for WebViewRenderer {
@ -135,6 +137,7 @@ impl WebViewRenderer {
hidpi_scale_factor: Scale::new(hidpi_scale_factor.0), hidpi_scale_factor: Scale::new(hidpi_scale_factor.0),
animating: false, animating: false,
pending_input_events: Default::default(), pending_input_events: Default::default(),
epoch_not_synchronized: Cell::default(),
} }
} }
@ -319,7 +322,7 @@ impl WebViewRenderer {
return; return;
}; };
if self.pending_input_events.borrow().len() > 0 { if self.epoch_not_synchronized.get() {
self.pending_input_events.borrow_mut().push_back(event); self.pending_input_events.borrow_mut().push_back(event);
return; return;
} }