A frame that comes out all black though its page shows something is a warning, said once over its run of frames (#96)

A frame black on two draws whose GPU passes its canary was kept as the scene's black with one stderr line, and every
later black frame was let through silently: #96's 4K handover lost frames 22-29 that way, the render reporting
success. Now, when such a frame's page shows something that isn't black, the render warns "black-frame" naming it
and where it's written ("frames 22-29: drew all black on two draws, though the page shows a rgb(34, 34, 34)
background (handover.tsx:31:3)"), in the run's findings: stderr, the manifest, the summary's count and raea check's.
A page that is black (a black background, nothing on it) says nothing, as before.

raea-page's visible_paint finds it: the first element shown on screen, not a video's holder, whose background or own
words' colour isn't black, with its source stamp; it shares the manifest's opacity and stamp walks, now functions of
their own. raea-core-facts' said_frame joins a frame's finding to the same one running on the frames just before it,
so a run prints one line and counts once. Both black checks of the page path call it (bevy_frame.rs's still and video
frames, render.rs's page over 3D). Left out, as on the issue: a fed MP4's frames, which never come back to the CPU.

RAEA_BLACK_FAULT=3 draws every frame black with the canary passing (a draw dropped whole, as #96's was), to test it.
Checked: a #222 page under that fault warns once over frames 0-5, the manifest holding one finding with frames [0, 6];
a black page under it says nothing. Test: said_frame merges a run and starts another after a gap (the two tests that
say and take findings hold one lock).

Skills (SK4): SKILL.md's "7. Deliver" names runtime/export/src and says nothing of black frames: checked, still true.
This commit is contained in:
shinyobjectz committed 2026-11-12 12:49:42 -08:00
1 parent 645b0853cc
commit 559d8274e0
7 files changed
+122 -41

No files matched your search

+29
View File
@@ -154,12 +154,28 @@ impl Finding {
}
static SAID: std::sync::Mutex<Vec<Finding>> = std::sync::Mutex::new(Vec::new());
/// Held by a test that says and takes, so two such tests don't take each other's findings
#[cfg(test)]
pub(crate) static SAYING: std::sync::Mutex<()> = std::sync::Mutex::new(());
/// Findings a command has said as it went (a render's clipping, from its own thread), kept for its count at the end.
pub fn said(fs: &[Finding]) {
SAID.lock().unwrap_or_else(|e| e.into_inner()).extend(fs.iter().cloned());
}
/// A finding about frame `f` alone, said: printed and kept, unless the same finding is running on the frames just before
/// it, which it then joins (a render's black frames with paint on them say one line a run, and count once: #96).
pub fn said_frame(found: Finding, f: i64) {
let mut all = SAID.lock().unwrap_or_else(|e| e.into_inner());
if let Some(run) = all.iter_mut().rev().find(|x| x.check == found.check && x.says == found.says && x.frames.is_some_and(|[_, b]| b == f)) {
run.frames = run.frames.map(|[a, _]| [a, f + 1]);
return;
}
let found = found.frames(f, f + 1);
eprintln!("raea: {}", found.line());
all.push(found);
}
/// Every finding said so far, taken: what the command ends by counting.
pub fn taken() -> Vec<Finding> {
std::mem::take(&mut *SAID.lock().unwrap_or_else(|e| e.into_inner()))
@@ -199,6 +215,19 @@ pub fn count(fs: &[Finding]) -> String {
mod tests {
use super::*;
#[test]
fn a_finding_on_frames_in_a_row_is_one_finding_over_them() {
let _held = SAYING.lock().unwrap_or_else(|e| e.into_inner());
let _ = taken();
let lost = || Finding::new("black-frame", Level::Warn, "drew all black", "raea render");
for f in [22, 23, 24, 30] {
said_frame(lost(), f);
}
said_frame(Finding::new("black-frame", Level::Warn, "other", "raea render"), 25);
let got: Vec<_> = taken().into_iter().map(|x| (x.says, x.frames)).collect();
assert_eq!(got, vec![("drew all black".to_string(), Some([22, 25])), ("drew all black".into(), Some([30, 31])), ("other".into(), Some([25, 26]))]);
}
#[test]
fn the_old_ranks_and_words_map_onto_three_levels() {
assert_eq!([0, 1, 2, 3].map(Level::of_rank), [Level::Error, Level::Error, Level::Warn, Level::Note]);
+1
View File
@@ -186,6 +186,7 @@ mod tests {
// outside a project, nothing is kept
assert!(keep("raea render", &std::env::temp_dir().join("loose.tsx"), None, &[], vec![], "x").is_none());
// a video copied from the export cache says what was found when it was drawn (finding::keep_to, replay)
let _held = crate::finding::SAYING.lock().unwrap_or_else(|e| e.into_inner());
crate::finding::said(std::slice::from_ref(&tilt));
assert!(crate::finding::keep_to(&root.join("cached.findings")));
let _ = crate::finding::taken();
+76 -37
View File
@@ -9,48 +9,13 @@ impl BlitzPage {
/// opacity, colour, size, weight and alignment as computed. In document order, as raea-runtime-js's page gave them.
pub fn manifest(&mut self) -> (Vec<serde_json::Value>, Vec<serde_json::Value>) {
use serde_json::json;
use style::computed_values::visibility::T as Visibility;
use style::values::specified::text::TextAlignKeyword;
let docs = self.app.world().non_send::<Docs>();
let Some(doc) = docs.0.get(&self.page) else { return (vec![], vec![]) };
let r = |v: f64| (v * 10.0).round() / 10.0;
let rect = |n: blitz_dom::NodeId| doc.get_client_bounding_rect(n).filter(|b| b.width > 0.0 && b.height > 0.0);
// its own opacity times its parents', 0 when it or one of them isn't shown
let alpha = |n: blitz_dom::NodeId| -> f64 {
let (mut a, mut at) = (1.0f64, Some(n));
while let Some(x) = at {
let Some(node) = doc.get_node(x) else { break };
if node.is_element() {
let Some(s) = node.primary_styles() else { return 0.0 };
if !node.has_boxes() || (x == n && matches!(s.clone_visibility(), Visibility::Hidden | Visibility::Collapse)) {
return 0.0;
}
a *= s.get_effects().opacity as f64;
}
at = node.parent;
}
a
};
// the source stamps (engine/bundle stamp.rs) of the nearest element up from `n` that has them: where the JSX
// is written ("promo.tsx:12:7"), and the uses of the edit's components it was drawn in, nearest first
let stamps = |n: blitz_dom::NodeId, entry: &mut serde_json::Value| {
let mut at = Some(n);
while let Some(x) = at {
let Some(node) = doc.get_node(x) else { break };
if let Some(loc) = node.attr(LocalName::from("data-raea-loc")) {
entry["loc"] = json!(loc);
if let Some(uses) = node.attr(LocalName::from("data-raea-use")).filter(|u| !u.is_empty()) {
entry["use"] = json!(uses.split('|').collect::<Vec<_>>());
}
// its place in a list (its .map()'s key), when it has one
if let Some(idx) = node.attr(LocalName::from("data-raea-idx")) {
entry["index"] = json!(idx);
}
return;
}
at = node.parent;
}
};
let alpha = |n: blitz_dom::NodeId| alpha(doc, n);
let stamps = |n: blitz_dom::NodeId, entry: &mut serde_json::Value| stamps(doc, n, entry);
let (mut videos, mut text) = (Vec::new(), Vec::new());
let mut owned: Vec<(blitz_dom::NodeId, Vec<String>)> = Vec::new();
// the whole document: a composition's sequences and screens are pages of their own under the root's
@@ -166,6 +131,80 @@ impl BlitzPage {
}
}
impl BlitzPage {
/// The first element shown on the page that paints something not black: a background colour, or its own words'
/// colour, said with where it's written ("a rgb(34, 34, 34) background (handover.tsx:31:3)"). A frame that came out
/// all black while this is on it is one the GPU lost (#96). A video's holder is skipped: it's see-through.
pub fn visible_paint(&mut self) -> Option<String> {
let docs = self.app.world().non_send::<Docs>();
let doc = docs.0.get(&self.page)?;
let (w, h) = (self.w as f64, self.h as f64);
let rgb = |c: style::color::AbsoluteColor| {
let c = c.to_color_space(style::color::ColorSpace::Srgb);
let [r, g, b] = [c.components.0, c.components.1, c.components.2].map(|v| (v.clamp(0.0, 1.0) * 255.0).round());
(r.max(g).max(b) > 8.0 && c.alpha > 0.05).then(|| format!("rgb({r}, {g}, {b})"))
};
let mut stack = vec![doc.root_node().id];
while let Some(n) = stack.pop() {
let Some(node) = doc.get_node(n) else { continue };
stack.extend(node.children.iter().rev().copied());
let on = doc.get_client_bounding_rect(n).is_some_and(|b| b.width > 0.0 && b.height > 0.0 && b.x < w && b.y < h && b.x + b.width > 0.0 && b.y + b.height > 0.0);
if !node.is_element() || node.attr(LocalName::from("data-raea-src")).is_some() || !on || alpha(doc, n) <= 0.01 {
continue;
}
let Some(s) = node.primary_styles() else { continue };
let words = node.children.iter().any(|c| doc.get_node(*c).is_some_and(|c| c.is_text_node() && !c.text_content().trim().is_empty()));
let paint = rgb(s.clone_background_color().resolve_to_absolute(&s.clone_color())).map(|c| format!("a {c} background")).or_else(|| words.then(|| rgb(s.clone_color())).flatten().map(|c| format!("{c} text")));
if let Some(p) = paint {
let mut at = serde_json::json!({});
stamps(doc, n, &mut at);
return Some(match at["loc"].as_str() { Some(l) => format!("{p} ({l})"), None => p });
}
}
None
}
}
/// An element's own opacity times its parents', 0 when it or one of them isn't shown.
fn alpha(doc: &blitz_dom::BaseDocument, n: blitz_dom::NodeId) -> f64 {
use style::computed_values::visibility::T as Visibility;
let (mut a, mut at) = (1.0f64, Some(n));
while let Some(x) = at {
let Some(node) = doc.get_node(x) else { break };
if node.is_element() {
let Some(s) = node.primary_styles() else { return 0.0 };
if !node.has_boxes() || (x == n && matches!(s.clone_visibility(), Visibility::Hidden | Visibility::Collapse)) {
return 0.0;
}
a *= s.get_effects().opacity as f64;
}
at = node.parent;
}
a
}
/// The source stamps (engine/bundle stamp.rs) of the nearest element up from `n` that has them, into `entry`: where the
/// JSX is written ("promo.tsx:12:7"), and the uses of the edit's components it was drawn in, nearest first.
fn stamps(doc: &blitz_dom::BaseDocument, n: blitz_dom::NodeId, entry: &mut serde_json::Value) {
use serde_json::json;
let mut at = Some(n);
while let Some(x) = at {
let Some(node) = doc.get_node(x) else { break };
if let Some(loc) = node.attr(LocalName::from("data-raea-loc")) {
entry["loc"] = json!(loc);
if let Some(uses) = node.attr(LocalName::from("data-raea-use")).filter(|u| !u.is_empty()) {
entry["use"] = json!(uses.split('|').collect::<Vec<_>>());
}
// its place in a list (its .map()'s key), when it has one
if let Some(idx) = node.attr(LocalName::from("data-raea-idx")) {
entry["index"] = json!(idx);
}
return;
}
at = node.parent;
}
}
/// A run's words from its text nodes, in order: joined by a space, as caption words set one a span are; or, when every
/// one is a single letter (a word revealed letter by letter, its spaces spans of their own), as the letters read
/// ("49 BC", not "4 9 B C"). None when the run is only white space.
+5 -3
View File
@@ -10,7 +10,7 @@ use std::time::Duration;
/// work for a while after a hang, and says why); then a 4-byte copy through `queue`, read back. Err says what the GPU
/// didn't do.
pub fn canary(device: &wgpu::Device, queue: &wgpu::Queue) -> Result<(), String> {
if fault() >= 2 {
if fault() == 2 {
return Err("RAEA_BLACK_FAULT=2 fails it".into());
}
#[cfg(target_vendor = "apple")]
@@ -60,16 +60,18 @@ pub fn black(px: &[u8]) -> bool {
}
/// RAEA_BLACK_FAULT, the black-frame redraw's check (sdk/raea/bench/black-frame): 1, each frame's first draw read
/// back black, as a GPU fault that leaves no error does; 2, every draw black and the canary failing too.
/// back black, as a GPU fault that leaves no error does; 2, every draw black and the canary failing too; 3, every draw
/// black and the canary passing, as a draw Vello drops whole does (#96).
pub fn fault() -> u8 {
match std::env::var("RAEA_BLACK_FAULT").as_deref() {
Ok("1") => 1,
Ok("2") => 2,
Ok("3") => 3,
_ => 0,
}
}
/// `px` as the fault RAEA_BLACK_FAULT asks for leaves it: black (its alpha kept) on a first draw at 1, on any at 2.
/// `px` as the fault RAEA_BLACK_FAULT asks for leaves it: black (its alpha kept) on a first draw at 1, on any at 2 or 3.
pub fn injected(mut px: Vec<u8>, redraw: bool) -> Vec<u8> {
if fault() > u8::from(redraw) {
for p in px.chunks_exact_mut(4) {
+4
View File
@@ -2,6 +2,9 @@
use super::*;
/// A frame black on two draws whose page shows `paint`: one the GPU lost, a warning over its run of frames (#96)
pub(crate) fn lost(f: i64, paint: Option<String>) { if let Some(p) = paint { raea_core_facts::finding::said_frame(raea_core_facts::Finding::new("black-frame", raea_core_facts::Level::Warn, format!("drew all black on two draws, though the page shows {p}"), "raea render").fix("the GPU dropped this frame's drawing: fewer or smaller filter layers at this size, or render it again"), f); } }
/// One frame on the bevy_ui page (src/page.rs, P26): the frame's sound, mix and marker read from React's tree as
/// snapshot_retained reads them, the page made to match the tree, drawn and read back. 3D isn't on this page yet.
pub(crate) fn snapshot_bevy(world: &mut World, page: &mut raea_runtime_page::BevyPage, cx: &mut Ctx) -> R<Frame> {
@@ -14,6 +17,7 @@ pub(crate) fn snapshot_bevy(world: &mut World, page: &mut raea_runtime_page::Bev
})?;
if twice {
raea_gpu_device::check::black_twice(f, page.canary())?;
lost(f, page.visible_paint());
}
let stored = store_page(&px, page.w, page.h, cx.work)?;
// each <Screen>'s picture: stored as a page is (a fully clear one too, so the screen shows it clear)
+1 -1
View File
@@ -290,7 +290,7 @@ pub(crate) fn render_bundle_with(js: &Path, dir: &Path, out: &Path, wanted: Opti
}
}
let (px, twice) = raea_gpu_device::check::black_checked(f, px, raea_sys_page::redraw_full, || bevy_over_3d(app.world_mut(), pg, &mut cx, fps))?;
if twice { raea_gpu_device::check::black_twice(f, pg.canary().and_then(|()| cx.scene3d.as_ref().map_or(Ok(()), |e| e.canary())))?; }
if twice { raea_gpu_device::check::black_twice(f, pg.canary().and_then(|()| cx.scene3d.as_ref().map_or(Ok(()), |e| e.canary())))?; lost(f, pg.visible_paint()); }
Ok(px)
})
.map_err(|e| if i == 0 { format!("{e}; no frame was written") } else { format!("{e}; the {i} frames before it are in {}", out.display()) })?;
+6
View File
@@ -160,6 +160,12 @@ impl BevyPage {
self.page.frame()
}
/// The first thing the page shows that isn't black, and where it's written (raea-page's visible_paint): a frame all
/// black while it's there was lost (#96).
pub fn visible_paint(&mut self) -> Option<String> {
self.page.visible_paint()
}
/// Whether the page's GPU still runs work (raea-page's gpucheck).
pub fn canary(&self) -> R<()> {
self.page.canary()