Add a complexity limit on displaying layer thumbnails to improve performance (#2828)

* Skip complex layer thumbnails

* Set Raster<GPU> to have usize::MAX render complexity

* Code review

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
James Lindsay
2025-07-10 08:57:45 +01:00
committed by GitHub
parent ceffcfd8df
commit 13ad814639
4 changed files with 77 additions and 2 deletions

View File

@@ -328,6 +328,18 @@ impl NodeRuntime {
return;
}
// Skip thumbnails if the layer is too complex (for performance)
if graphic_element.render_complexity() > 1000 {
let old = thumbnail_renders.insert(parent_network_node_id, Vec::new());
if old.is_none_or(|v| !v.is_empty()) {
responses.push_back(FrontendMessage::UpdateNodeThumbnail {
id: parent_network_node_id,
value: "<svg viewBox=\"0 0 10 10\"><title>Dense thumbnail omitted for performance</title><line x1=\"0\" y1=\"10\" x2=\"10\" y2=\"0\" stroke=\"red\" /></svg>".to_string(),
});
}
return;
}
let bounds = graphic_element.bounding_box(DAffine2::IDENTITY, true);
// Render the thumbnail from a `GraphicElement` into an SVG string