Poll only visible web surfaces

This commit is contained in:
2026-05-13 01:54:51 -04:00
parent 6ce5df83a8
commit 05ce4afba4
7 changed files with 62 additions and 5 deletions
+2 -2
View File
@@ -74,8 +74,8 @@ impl WebSurfaceStore {
}
}
pub(super) fn tick(&mut self) -> WebSurfaceTickResult {
let frames = self.runtime.tick();
pub(super) fn tick(&mut self, visible_tab_ids: &[TabId]) -> WebSurfaceTickResult {
let frames = self.runtime.tick(visible_tab_ids);
let mut result = WebSurfaceTickResult::default();
for frame in frames {
@@ -51,7 +51,13 @@ impl ElyShell {
}
pub(super) fn tick_external_web_surfaces(&mut self) -> bool {
let result = self.web_surfaces.tick();
let visible_tab_ids = match &self.state {
super::ShellState::Ready(core) => {
core.visible_content_tab_ids().unwrap_or_else(|_| Vec::new())
}
super::ShellState::StartupError(_) => Vec::new(),
};
let result = self.web_surfaces.tick(&visible_tab_ids);
let mut url_changed = false;
for url_change in result.url_changes {
url_changed |= self.apply_web_surface_url_change(url_change);
@@ -134,7 +134,7 @@ fn wait_for_ready_frame(
return Err(format!("timed out rendering {}", case.url));
}
store.tick();
store.tick(std::slice::from_ref(tab_id));
match store.state(tab_id) {
Some(WebSurfaceState::Ready(frame)) => {
validate_prd_frame(frame, case)?;
@@ -101,7 +101,7 @@ impl WebSurfaceRuntime {
Ok(WebSurfaceEnsureResult { requested_url, started_loading, frame, url_change })
}
pub(super) fn tick(&mut self) -> Vec<WebSurfaceRuntimeFrame> {
pub(super) fn tick(&mut self, visible_tab_ids: &[TabId]) -> Vec<WebSurfaceRuntimeFrame> {
let (state, sessions) = (&mut self.state, &mut self.sessions);
let RuntimeState::Ready { client, .. } = state else {
return Vec::new();
@@ -109,6 +109,9 @@ impl WebSurfaceRuntime {
let mut frames = Vec::new();
for (tab_id, session) in sessions {
if !visible_tab_ids.iter().any(|visible_tab_id| visible_tab_id == tab_id) {
continue;
}
match client.poll(tab_id.as_str().to_string()) {
Ok(Some(frame)) => match WebSurfaceFrame::from_live_frame(
session.requested_url.clone(),