Clean up execution context for skipped node graph submissions (#3233)

This commit is contained in:
Dennis Kobert 2025-10-01 12:13:59 +02:00 committed by GitHub
parent bc66148d2b
commit c697b61a7e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 16 additions and 4 deletions

View File

@ -51,7 +51,7 @@ pub enum NodeGraphUpdate {
pub struct NodeGraphExecutor { pub struct NodeGraphExecutor {
runtime_io: NodeRuntimeIO, runtime_io: NodeRuntimeIO,
current_execution_id: u64, current_execution_id: u64,
futures: HashMap<u64, ExecutionContext>, futures: VecDeque<(u64, ExecutionContext)>,
node_graph_hash: u64, node_graph_hash: u64,
previous_node_to_inspect: Option<NodeId>, previous_node_to_inspect: Option<NodeId>,
} }
@ -157,7 +157,7 @@ impl NodeGraphExecutor {
// Execute the node graph // Execute the node graph
let execution_id = self.queue_execution(render_config); let execution_id = self.queue_execution(render_config);
self.futures.insert(execution_id, ExecutionContext { export_config: None, document_id }); self.futures.push_back((execution_id, ExecutionContext { export_config: None, document_id }));
Ok(DeferMessage::SetGraphSubmissionIndex { execution_id }.into()) Ok(DeferMessage::SetGraphSubmissionIndex { execution_id }.into())
} }
@ -213,7 +213,7 @@ impl NodeGraphExecutor {
export_config: Some(export_config), export_config: Some(export_config),
document_id, document_id,
}; };
self.futures.insert(execution_id, execution_context); self.futures.push_back((execution_id, execution_context));
Ok(()) Ok(())
} }
@ -273,7 +273,19 @@ impl NodeGraphExecutor {
responses.extend(existing_responses.into_iter().map(Into::into)); responses.extend(existing_responses.into_iter().map(Into::into));
document.network_interface.update_vector_modify(vector_modify); document.network_interface.update_vector_modify(vector_modify);
let execution_context = self.futures.remove(&execution_id).ok_or_else(|| "Invalid generation ID".to_string())?; while let Some(&(fid, _)) = self.futures.front() {
if fid < execution_id {
self.futures.pop_front();
} else {
break;
}
}
let Some((fid, execution_context)) = self.futures.pop_front() else {
panic!("InvalidGenerationId")
};
assert_eq!(fid, execution_id, "Missmatch in execution id");
if let Some(export_config) = execution_context.export_config { if let Some(export_config) = execution_context.export_config {
// Special handling for exporting the artwork // Special handling for exporting the artwork
self.export(node_graph_output, export_config, responses)?; self.export(node_graph_output, export_config, responses)?;