Skip to content

Commit ead914e

Browse files
authored
Fix regression where Vello doesn't render new document opened after closing all documents (#3849)
* Fix regression where Vello doesn't render new document opened after closing all documents * Remove last_svg_canvas and do this logic in the frontend
1 parent 8a1dfb9 commit ead914e

2 files changed

Lines changed: 8 additions & 12 deletions

File tree

editor/src/node_graph_executor.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ use graph_craft::document::value::{RenderOutput, TaggedValue};
55
use graph_craft::document::{DocumentNode, DocumentNodeImplementation, NodeId, NodeInput};
66
use graph_craft::proto::GraphErrors;
77
use graph_craft::wasm_application_io::EditorPreferences;
8-
use graphene_std::application_io::{NodeGraphUpdateMessage, RenderConfig};
9-
use graphene_std::application_io::{SurfaceFrame, TimingInformation};
8+
use graphene_std::application_io::{NodeGraphUpdateMessage, RenderConfig, TimingInformation};
109
use graphene_std::raster::{CPU, Raster};
1110
use graphene_std::renderer::{RenderMetadata, format_transform_matrix};
1211
use graphene_std::text::FontCache;
@@ -56,7 +55,6 @@ pub struct NodeGraphExecutor {
5655
futures: VecDeque<(u64, ExecutionContext)>,
5756
node_graph_hash: u64,
5857
previous_node_to_inspect: Option<NodeId>,
59-
last_svg_canvas: Option<SurfaceFrame>,
6058
}
6159

6260
#[derive(Debug, Clone)]
@@ -79,7 +77,6 @@ impl NodeGraphExecutor {
7977
node_graph_hash: 0,
8078
current_execution_id: 0,
8179
previous_node_to_inspect: None,
82-
last_svg_canvas: None,
8380
};
8481
(node_runtime, node_executor)
8582
}
@@ -384,19 +381,14 @@ impl NodeGraphExecutor {
384381
// Send to frontend
385382
responses.add(FrontendMessage::UpdateImageData { image_data });
386383
responses.add(FrontendMessage::UpdateDocumentArtwork { svg });
387-
self.last_svg_canvas = None;
388384
}
389-
RenderOutputType::CanvasFrame(frame) => 'block: {
390-
if self.last_svg_canvas == Some(frame) {
391-
break 'block;
392-
}
385+
RenderOutputType::CanvasFrame(frame) => {
393386
let matrix = format_transform_matrix(frame.transform);
394387
let transform = if matrix.is_empty() { String::new() } else { format!(" transform=\"{matrix}\"") };
395388
let svg = format!(
396389
r#"<svg><foreignObject width="{}" height="{}"{transform}><div data-canvas-placeholder="{}" data-is-viewport="true"></div></foreignObject></svg>"#,
397390
frame.resolution.x, frame.resolution.y, frame.surface_id.0,
398391
);
399-
self.last_svg_canvas = Some(frame);
400392
responses.add(FrontendMessage::UpdateDocumentArtwork { svg });
401393
}
402394
RenderOutputType::Texture { .. } => {}

frontend/src/components/panels/Document.svelte

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,13 @@
185185
const logicalWidth = parseFloat(foreignObject.getAttribute("width") || "0");
186186
const logicalHeight = parseFloat(foreignObject.getAttribute("height") || "0");
187187
188-
// Clone canvas for repeated instances (layers that appear multiple times)
189-
// Viewport canvas is marked with data-is-viewport and should never be cloned
188+
// Viewport canvas is marked with data-is-viewport and should never be cloned.
189+
// If it's already mounted in the viewport, skip the DOM replacement since it's already showing the rendered content.
190+
// We check `canvas.isConnected` to ensure it's in the live DOM, not a detached tree from a destroyed component.
190191
const isViewport = placeholder.hasAttribute("data-is-viewport");
192+
if (isViewport && canvas.isConnected && canvas.parentElement?.closest("[data-viewport]")) return;
193+
194+
// Clone canvas for repeated instances (layers that appear multiple times)
191195
if (!isViewport && canvas.parentElement) {
192196
const newCanvas = window.document.createElement("canvas");
193197
const context = newCanvas.getContext("2d");

0 commit comments

Comments
 (0)