Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

Page: a <style> removed in the same mutation batch as its text no longer panics the render ("invalid SlotMap key used", on runs whose removals came in that order): Blitz's process_removed_subtree drops a removed node from the style, form and title nodes the batch flushes (vendor/blitz-dom, noted in vendor.toml), and raea's own re-parse of a changed <style> skips one that is gone (closes #24)

shinyobjectze94514d2430e
diff --git a/systems/page/src/ops.rs b/systems/page/src/ops.rs
index 3a47d599..291d1f02 100644
--- a/systems/page/src/ops.rs
+++ b/systems/page/src/ops.rs
@@ -268,6 +268,8 @@ pub fn apply(doc: &mut BaseDocument, nodes: &mut Nodes, ops: Vec<Op>) {
}
}
}
+ // (a <style> whose text changed and that was removed later in the same batch is gone: #24)
+ styles.retain(|s| doc.get_node(*s).is_some());
for s in styles {
doc.process_style_element(s);
}
diff --git a/vendor/blitz-dom/src/mutator.rs b/vendor/blitz-dom/src/mutator.rs
index 769d5da0..bfa64908 100644
--- a/vendor/blitz-dom/src/mutator.rs
+++ b/vendor/blitz-dom/src/mutator.rs
@@ -995,6 +995,14 @@ impl<'doc> DocumentMutator<'doc> {
fn process_removed_subtree(&mut self, node_id: NodeId) {
self.doc.iter_subtree_mut(node_id, |node_id, doc| {
+ // raea: a node leaving the document isn't processed when the batch flushes, as it may be dropped by then
+ // (a <style> recorded when its text child was removed, then removed itself: `flush` indexed the dropped
+ // node and panicked, "invalid SlotMap key used", raea #24)
+ self.style_nodes.remove(&node_id);
+ self.form_nodes.remove(&node_id);
+ if self.title_node == Some(node_id) {
+ self.title_node = None;
+ }
doc.nodes[node_id]
.flags
.set(NodeFlags::IS_IN_DOCUMENT, false);
@@ -1372,6 +1380,30 @@ mod test {
use crate::{Attribute, BaseDocument, DocumentConfig, ElementData, NodeData, qual_name};
+ /// raea #24: a <style> removed in the same batch as its text, the text first (which records the <style> to be parsed
+ /// again when the batch flushes): the flush used to index the dropped <style> and panic, "invalid SlotMap key used"
+ #[test]
+ fn a_style_removed_after_its_text_in_one_batch_is_not_parsed() {
+ let mut doc = BaseDocument::new(DocumentConfig::default());
+ let root = doc.root_node().id;
+ let (style, text) = {
+ let mut m = doc.mutate();
+ let div = m.create_element(qual_name!("div", html), vec![]);
+ let style = m.create_element(qual_name!("style", html), vec![]);
+ let text = m.create_text_node(".a { color: #fff; }");
+ m.append_children(style, &[text]);
+ m.append_children(div, &[style]);
+ m.append_children(root, &[div]);
+ (style, text)
+ };
+ {
+ let mut m = doc.mutate();
+ m.remove_and_drop_node(text);
+ m.remove_and_drop_node(style);
+ }
+ assert!(doc.get_node(style).is_none());
+ }
+
#[test]
fn media_type_defaults_to_screen() {
let mut document = BaseDocument::new(DocumentConfig::default());
diff --git a/vendor/vendor.toml b/vendor/vendor.toml
index 4104f64e..a411ccda 100644
--- a/vendor/vendor.toml
+++ b/vendor/vendor.toml
@@ -63,7 +63,7 @@ exit = "a Blitz release that draws these"
path = "vendor/blitz-dom"
upstream = "crates.io:0.3.0-beta.4"
kind = "patch"
-reason = "inline flex/grid baselines, auto table columns, table row rects, inline image load events, SVG text fonts, SVG non-scaling strokes, url() filters; Blitz main's #1244 and #1246"
+reason = "inline flex/grid baselines, auto table columns, table row rects, inline image load events, SVG text fonts, SVG non-scaling strokes, url() filters; Blitz main's #1244 and #1246; a node removed in a mutation batch dropped from the style, form and title nodes the batch flushes (raea #24)"
exit = "a Blitz release with #1244/#1246 and these"
[parley_engine]