S005: painter smoke tests; fix chrome blanking after PiP closes
- tests/smoke/painters.txt (5 tabs, switch, resize, PiP, close) and painters-perf.txt (memory, frame time, threads with 1/5/15 tabs, idle discard); test pages color.html, video.html, clip.webm. - selftest: `resize <w> <h>`, `shot <name> pip`, status gets frames (median/max ms), painters, threads. - Fix: a closing window's egui was destroyed with another window's GL context current, deleting the main window's font texture (chrome text/icons blank after PiP). BrowserWindow::destroy() makes its own context current first. - Fix: PiP CSS resets the video's margin (video was shifted down in the PiP frame). Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
parent
e06776b3ea
commit
23c6908ca5
5 changed files with 228 additions and 14 deletions
|
|
@ -1093,7 +1093,7 @@ impl App {
|
|||
for kind in closes {
|
||||
if let Some(id) = self.windows.iter().find(|(_, x)| x.kind == kind).map(|(id, _)| *id) {
|
||||
if let Some(mut pip) = self.windows.remove(&id) {
|
||||
pip.egui.destroy();
|
||||
pip.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1408,7 +1408,7 @@ impl App {
|
|||
self.hub.forget(web.webview.id());
|
||||
}
|
||||
}
|
||||
win.egui.destroy();
|
||||
win.destroy();
|
||||
if self.last_window == Some(window) {
|
||||
self.last_window = None;
|
||||
}
|
||||
|
|
@ -1458,7 +1458,7 @@ impl App {
|
|||
self.hub.servo.borrow_mut().take();
|
||||
drop(self.servo.take());
|
||||
for (_, mut win) in self.windows.drain() {
|
||||
win.egui.destroy();
|
||||
win.destroy();
|
||||
}
|
||||
let _ = std::fs::remove_file(self.shared.paths.running_marker());
|
||||
if let Some(server) = self.instance.take() {
|
||||
|
|
@ -1580,6 +1580,7 @@ impl App {
|
|||
|
||||
fn draw(&mut self, window: WindowId) {
|
||||
let Some(win) = self.windows.get_mut(&window) else { return };
|
||||
let started = Instant::now();
|
||||
win.needs_redraw = false;
|
||||
win.sync_webviews();
|
||||
win.paint_page();
|
||||
|
|
@ -1594,6 +1595,10 @@ impl App {
|
|||
}
|
||||
let clear = win.ui.palette.map(|p| p.surface).unwrap_or(egui::Color32::from_gray(24));
|
||||
win.present(clear);
|
||||
if win.frame_times.len() >= 120 {
|
||||
win.frame_times.pop_front();
|
||||
}
|
||||
win.frame_times.push_back(started.elapsed().as_secs_f32() * 1000.0);
|
||||
// The page area moved or changed size: resize the web view and draw again.
|
||||
if win.page_rect != page_rect_before {
|
||||
win.needs_redraw = true;
|
||||
|
|
|
|||
|
|
@ -268,7 +268,7 @@ const PIP_JS: &str = r#"(() => { if (!window.__nacre || window.__nacre.pip) retu
|
|||
window.__nacrePipV = v; v.setAttribute('data-nacre-pip', '');
|
||||
if (!document.getElementById('__nacre_pip_css')) {
|
||||
const st = document.createElement('style'); st.id = '__nacre_pip_css';
|
||||
st.textContent = 'video[data-nacre-pip]{position:fixed!important;inset:0!important;width:100vw!important;height:100vh!important;' +
|
||||
st.textContent = 'video[data-nacre-pip]{position:fixed!important;inset:0!important;margin:0!important;width:100vw!important;height:100vh!important;' +
|
||||
'max-width:none!important;max-height:none!important;object-fit:contain!important;background:#000!important;z-index:2147483647!important;transform:none!important}' +
|
||||
'html.__nacre_pip,html.__nacre_pip body{overflow:hidden!important}';
|
||||
(document.head || document.documentElement).appendChild(st);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@
|
|||
//! waitload [seconds] wait until the current tab finished loading (default limit 30 s)
|
||||
//! open <url> load in the current tab newtab <url> open in a new tab
|
||||
//! page <nacre://...> show an internal page
|
||||
//! shot <name> save the window as <name>.png
|
||||
//! shot <name> [pip] save the window (or the picture-in-picture window) as <name>.png
|
||||
//! resize <w> <h> resize the window (logical pixels)
|
||||
//! status <name> save tabs, downloads, VPN, ad blocker and so on as <name>.json
|
||||
//! set <json pointer> <json> change a setting, e.g. `set /privacy/https_only true`
|
||||
//! flyout <name> main, downloads, shield, vpn, media, siteinfo, profiles, apps, qr, none
|
||||
|
|
@ -27,6 +28,7 @@ use crate::actions::{Command, Disposition, DownloadOp};
|
|||
use crate::app::App;
|
||||
use crate::tabs::Page;
|
||||
use crate::ui::Flyout;
|
||||
use crate::window::Kind;
|
||||
|
||||
pub struct SelfTest {
|
||||
lines: Vec<String>,
|
||||
|
|
@ -69,8 +71,8 @@ impl App {
|
|||
}
|
||||
if test.pending_shot {
|
||||
// Written by the window after its next frame.
|
||||
if self.windows.get(&window).is_some_and(|w| w.shot_request.is_some()) {
|
||||
self.redraw(window);
|
||||
if let Some(shooting) = self.windows.iter().find(|(_, w)| w.shot_request.is_some()).map(|(id, _)| *id) {
|
||||
self.redraw(shooting);
|
||||
return;
|
||||
}
|
||||
if let Some(test) = self.selftest.as_mut() {
|
||||
|
|
@ -130,13 +132,25 @@ impl App {
|
|||
}
|
||||
},
|
||||
"shot" => {
|
||||
if let Some(win) = self.windows.get_mut(&window) {
|
||||
win.shot_request = Some(dir.join(format!("{rest}.png")));
|
||||
let (name, which) = rest.split_once(char::is_whitespace).unwrap_or((rest, ""));
|
||||
let target = if which.trim() == "pip" { self.windows.iter().find(|(_, w)| matches!(w.kind, Kind::Pip { .. })).map(|(id, _)| *id) } else { Some(window) };
|
||||
let Some(target) = target else {
|
||||
self.selftest_log("shot: no such window");
|
||||
return;
|
||||
};
|
||||
if let Some(win) = self.windows.get_mut(&target) {
|
||||
win.shot_request = Some(dir.join(format!("{name}.png")));
|
||||
}
|
||||
if let Some(t) = self.selftest.as_mut() {
|
||||
t.pending_shot = true;
|
||||
}
|
||||
self.redraw(window);
|
||||
self.redraw(target);
|
||||
},
|
||||
"resize" => {
|
||||
let mut size = rest.split_whitespace().filter_map(|v| v.parse::<u32>().ok());
|
||||
if let (Some(w), Some(h), Some(win)) = (size.next(), size.next(), self.windows.get(&window)) {
|
||||
let _ = win.window.request_inner_size(winit::dpi::LogicalSize::new(w, h));
|
||||
}
|
||||
},
|
||||
"status" => {
|
||||
let text = serde_json::to_string_pretty(&self.selftest_status(window)).unwrap_or_default();
|
||||
|
|
@ -281,8 +295,16 @@ impl App {
|
|||
.unwrap_or_default();
|
||||
let downloads: Vec<serde_json::Value> = self.shared.downloads.borrow().items.iter().map(|d| serde_json::json!({"id": d.id, "name": d.file_name(), "state": format!("{:?}", d.state), "received": d.received, "total": d.total, "error": d.error, "manager": d.manager})).collect();
|
||||
let settings = self.shared.settings.borrow();
|
||||
// Draw times (ms) of the window's recent frames: median and slowest.
|
||||
let frames = self.windows.get(&window).map(|w| {
|
||||
let mut times: Vec<f32> = w.frame_times.iter().copied().collect();
|
||||
times.sort_by(f32::total_cmp);
|
||||
serde_json::json!({"count": times.len(), "median_ms": times.get(times.len() / 2), "max_ms": times.last()})
|
||||
});
|
||||
serde_json::json!({
|
||||
"windows": self.windows.len(),
|
||||
"frames": frames,
|
||||
"painters": self.windows.values().flat_map(|w| &w.tabs).filter(|t| t.web.is_some()).count(),
|
||||
"window_kinds": self.windows.values().map(|w| format!("{:?}", w.kind)).collect::<Vec<_>>(),
|
||||
"tabs": tabs,
|
||||
"downloads": downloads,
|
||||
|
|
@ -302,6 +324,7 @@ impl App {
|
|||
"media_now": self.shared.media_now.borrow().as_ref().map(|m| m.title.clone()),
|
||||
"import_sources": self.shared.import_sources.borrow().iter().map(|s| s.name()).collect::<Vec<_>>(),
|
||||
"memory": crate::perf::own_memory(),
|
||||
"threads": crate::perf::own_threads(),
|
||||
"user_agent": self.shared.user_agent.borrow().clone(),
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,6 +58,8 @@ pub struct BrowserWindow {
|
|||
pub focused: bool,
|
||||
/// Save the next frame to this file (self-test screenshots).
|
||||
pub shot_request: Option<std::path::PathBuf>,
|
||||
/// How long the last frames took to draw, in ms (self-test status).
|
||||
pub frame_times: std::collections::VecDeque<f32>,
|
||||
}
|
||||
|
||||
/// Choose the winit window attributes for a kind of window.
|
||||
|
|
@ -117,6 +119,7 @@ impl BrowserWindow {
|
|||
pip_size: [0, 0],
|
||||
focused: true,
|
||||
shot_request: None,
|
||||
frame_times: Default::default(),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -236,6 +239,13 @@ impl BrowserWindow {
|
|||
self.rendering.present();
|
||||
}
|
||||
|
||||
/// Free egui's GL objects. Its texture and buffer ids are only valid in this window's context, so make
|
||||
/// it current first: deleting them while another window's context is current deletes that window's.
|
||||
pub fn destroy(&mut self) {
|
||||
let _ = self.rendering.make_current();
|
||||
self.egui.destroy();
|
||||
}
|
||||
|
||||
pub fn resized(&mut self, size: PhysicalSize<u32>) {
|
||||
if size.width == 0 || size.height == 0 {
|
||||
return;
|
||||
|
|
|
|||
Loading…
Reference in a new issue