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
11 changed files with 228 additions and 14 deletions
|
|
@ -11,10 +11,10 @@ Settle the riskiest design question (REVIEW.md: several painters on one GL conte
|
|||
- `src/window.rs`, the painter/offscreen parts of `src/hub.rs` and `src/tabs.rs`
|
||||
|
||||
## Steps
|
||||
- [ ] Write `tests/smoke/painters.txt`: 5 tabs with distinct local test pages (colours/text), switch through them taking a shot each, resize window, PiP one tab, close tabs, shot
|
||||
- [ ] Run it under software GL; check every screenshot shows the right tab with no garbage, black frames or stale content
|
||||
- [ ] Check GL state isolation: egui chrome still draws right after page blits (scissor, blend, bound framebuffer); fix by saving/restoring state around `render_to_parent_callback` if needed
|
||||
- [ ] Measure memory and frame time with 5 and 15 tabs (log `perf.rs` numbers); check idle tabs release painters per the perf settings
|
||||
- [x] Write `tests/smoke/painters.txt`: 5 tabs with distinct local test pages (colours/text), switch through them taking a shot each, resize window, PiP one tab, close tabs, shot
|
||||
- [x] Run it under software GL; check every screenshot shows the right tab with no garbage, black frames or stale content
|
||||
- [x] Check GL state isolation: egui chrome still draws right after page blits (scissor, blend, bound framebuffer); fix by saving/restoring state around `render_to_parent_callback` if needed
|
||||
- [x] Measure memory and frame time with 5 and 15 tabs (log `perf.rs` numbers); check idle tabs release painters per the perf settings
|
||||
- [ ] Decision: keep per-tab painters, or implement the one-painter-per-window fallback (PiP then reuses a dedicated painter); implement it if needed
|
||||
- [ ] Run `painters.txt` and `launch.txt` green; record the decision in `docs/DECISIONS.md` and remove the item from `docs/REVIEW.md`
|
||||
- [ ] PROGRESS entry, INDEX line, commit `S005: …` and push
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
BIN
tests/smoke/pages/clip.webm
Normal file
BIN
tests/smoke/pages/clip.webm
Normal file
Binary file not shown.
27
tests/smoke/pages/color.html
Normal file
27
tests/smoke/pages/color.html
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<!-- Painter test page: color.html?n=<tab number>&c=<css colour>[&anim=1]. A full-page colour, a big label and a
|
||||
white box in each corner, so screenshots show which tab is drawn and whether it is cropped or stretched. -->
|
||||
<head><meta charset="utf-8"><title>Tab</title>
|
||||
<style>
|
||||
html, body { margin: 0; height: 100%; overflow: hidden; font: bold 96px sans-serif; color: #fff; }
|
||||
.label { position: absolute; top: 50%; left: 0; right: 0; text-align: center; transform: translateY(-50%); }
|
||||
.corner { position: absolute; width: 40px; height: 40px; background: #fff; }
|
||||
.bar { position: absolute; left: 0; bottom: 60px; width: 120px; height: 20px; background: #000; animation: move 2s linear infinite alternate; }
|
||||
@keyframes move { to { left: calc(100% - 120px); } }
|
||||
</style></head>
|
||||
<body>
|
||||
<div class="label" id="label"></div>
|
||||
<div class="corner" style="top: 0; left: 0"></div>
|
||||
<div class="corner" style="top: 0; right: 0"></div>
|
||||
<div class="corner" style="bottom: 0; left: 0"></div>
|
||||
<div class="corner" style="bottom: 0; right: 0"></div>
|
||||
<script>
|
||||
const q = new URLSearchParams(location.search);
|
||||
document.body.style.background = q.get('c') || '#555';
|
||||
document.getElementById('label').textContent = 'TAB ' + (q.get('n') || '?');
|
||||
document.title = 'Tab ' + (q.get('n') || '?');
|
||||
if (q.get('anim')) document.body.appendChild(Object.assign(document.createElement('div'), { className: 'bar' }));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
13
tests/smoke/pages/video.html
Normal file
13
tests/smoke/pages/video.html
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<!-- Painter test page with a looping, muted video (clip.webm, ffmpeg testsrc2 VP8) for picture in picture. -->
|
||||
<head><meta charset="utf-8"><title>Tab 5 video</title>
|
||||
<style>
|
||||
body { margin: 0; background: #613583; color: #fff; font: bold 64px sans-serif; text-align: center; }
|
||||
video { display: block; margin: 20px auto; width: 640px; height: 360px; background: #000; }
|
||||
</style></head>
|
||||
<body>
|
||||
<div>TAB 5 VIDEO</div>
|
||||
<video id="v" src="clip.webm" muted loop autoplay></video>
|
||||
</body>
|
||||
</html>
|
||||
57
tests/smoke/painters-perf.txt
Normal file
57
tests/smoke/painters-perf.txt
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
# Painter cost (S005): memory and frame time with 5 and 15 tabs, then idle tabs releasing their painters.
|
||||
# The status files carry "memory" (PSS bytes), "painters" (tabs holding a web view = painter) and "frames"
|
||||
# (median/max draw time of the last frames). Run with SMOKE_TIMEOUT=400 tools/smoke.sh.
|
||||
wait 3
|
||||
set /perf/freeze_min 0
|
||||
set /perf/discard_min 0
|
||||
open @PAGES@/color.html?n=1&c=%23c01c28
|
||||
waitload 30
|
||||
wait 2
|
||||
status m1-one-tab
|
||||
newtab @PAGES@/color.html?n=2&c=%2326a269
|
||||
waitload 30
|
||||
newtab @PAGES@/color.html?n=3&c=%231c71d8
|
||||
waitload 30
|
||||
newtab @PAGES@/color.html?n=4&c=%23e5a50a
|
||||
waitload 30
|
||||
newtab @PAGES@/color.html?n=5&c=%23613583&anim=1
|
||||
waitload 30
|
||||
# The animated tab redraws every frame: wait so the frame list holds only those frames.
|
||||
wait 5
|
||||
status m5-five-tabs
|
||||
newtab @PAGES@/color.html?n=6&c=%23c01c28
|
||||
waitload 30
|
||||
newtab @PAGES@/color.html?n=7&c=%2326a269
|
||||
waitload 30
|
||||
newtab @PAGES@/color.html?n=8&c=%231c71d8
|
||||
waitload 30
|
||||
newtab @PAGES@/color.html?n=9&c=%23e5a50a
|
||||
waitload 30
|
||||
newtab @PAGES@/color.html?n=10&c=%23613583
|
||||
waitload 30
|
||||
newtab @PAGES@/color.html?n=11&c=%23c01c28
|
||||
waitload 30
|
||||
newtab @PAGES@/color.html?n=12&c=%2326a269
|
||||
waitload 30
|
||||
newtab @PAGES@/color.html?n=13&c=%231c71d8
|
||||
waitload 30
|
||||
newtab @PAGES@/color.html?n=14&c=%23e5a50a
|
||||
waitload 30
|
||||
newtab @PAGES@/color.html?n=15&c=%23613583&anim=1
|
||||
waitload 30
|
||||
wait 5
|
||||
status m15-fifteen-tabs
|
||||
shot m15-fifteen-tabs
|
||||
# Idle tabs unload after discard_min minutes (checked by the slow tick): 14 painters should go away.
|
||||
set /perf/discard_min 1
|
||||
wait 90
|
||||
status m15-after-discard
|
||||
shot m15-after-discard
|
||||
# An unloaded tab loads again when shown.
|
||||
cmd select 1
|
||||
waitload 30
|
||||
wait 1
|
||||
shot m15-reloaded-tab2
|
||||
status m15-reloaded
|
||||
status done
|
||||
quit
|
||||
79
tests/smoke/painters.txt
Normal file
79
tests/smoke/painters.txt
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
# Per-tab painters (S005): 5 tabs, each its own painter on the window's GL context. Every shot must show the
|
||||
# right tab (colour + "TAB n", four white corner boxes), no black, garbage or stale frames, and the chrome intact.
|
||||
# Run with tools/smoke.sh.
|
||||
wait 3
|
||||
open @PAGES@/color.html?n=1&c=%23c01c28
|
||||
waitload 30
|
||||
newtab @PAGES@/color.html?n=2&c=%2326a269
|
||||
waitload 30
|
||||
newtab @PAGES@/color.html?n=3&c=%231c71d8&anim=1
|
||||
waitload 30
|
||||
newtab @PAGES@/color.html?n=4&c=%23e5a50a
|
||||
waitload 30
|
||||
newtab @PAGES@/video.html
|
||||
waitload 30
|
||||
wait 2
|
||||
status opened
|
||||
# Switch through every tab, then back to one that was hidden for a while.
|
||||
cmd select 0
|
||||
wait 1
|
||||
shot s1-tab1
|
||||
cmd select 1
|
||||
wait 1
|
||||
shot s2-tab2
|
||||
cmd select 2
|
||||
wait 1
|
||||
shot s3-tab3
|
||||
cmd select 3
|
||||
wait 1
|
||||
shot s4-tab4
|
||||
cmd select 4
|
||||
wait 1
|
||||
shot s5-tab5
|
||||
cmd select 1
|
||||
wait 1
|
||||
shot s6-tab2-again
|
||||
# Resize: the page must fill the new page area (corner boxes visible), then the old size again.
|
||||
resize 900 600
|
||||
wait 2
|
||||
shot r1-small-tab2
|
||||
cmd select 2
|
||||
wait 1
|
||||
shot r2-small-tab3
|
||||
resize 1280 800
|
||||
wait 2
|
||||
shot r3-big-tab3
|
||||
# Picture in picture: tab 5's video moves to its own window, the tab shows a placeholder.
|
||||
cmd select 4
|
||||
wait 1
|
||||
cmd pip
|
||||
wait 3
|
||||
shot p1-main-tab5
|
||||
shot p2-pip pip
|
||||
cmd select 0
|
||||
wait 2
|
||||
shot p3-main-tab1
|
||||
shot p4-pip-while-tab1 pip
|
||||
status pip
|
||||
cmd select 4
|
||||
wait 1
|
||||
cmd exitpip
|
||||
wait 2
|
||||
shot p5-tab5-back
|
||||
# Close tabs: the tab that takes over must draw its own page.
|
||||
cmd select 2
|
||||
wait 1
|
||||
cmd close_tab
|
||||
wait 1
|
||||
shot c1-closed-tab3
|
||||
cmd close_tab
|
||||
wait 1
|
||||
shot c2-closed-tab4
|
||||
cmd select 0
|
||||
wait 1
|
||||
cmd close_tab
|
||||
wait 1
|
||||
shot c3-closed-tab1
|
||||
status closed
|
||||
status done
|
||||
quit
|
||||
Loading…
Reference in a new issue