Skip to content

Commit c697b61

Browse files
authored
Clean up execution context for skipped node graph submissions (#3233)
1 parent bc66148 commit c697b61

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

editor/src/node_graph_executor.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub enum NodeGraphUpdate {
5151
pub struct NodeGraphExecutor {
5252
runtime_io: NodeRuntimeIO,
5353
current_execution_id: u64,
54-
futures: HashMap<u64, ExecutionContext>,
54+
futures: VecDeque<(u64, ExecutionContext)>,
5555
node_graph_hash: u64,
5656
previous_node_to_inspect: Option<NodeId>,
5757
}
@@ -157,7 +157,7 @@ impl NodeGraphExecutor {
157157
// Execute the node graph
158158
let execution_id = self.queue_execution(render_config);
159159

160-
self.futures.insert(execution_id, ExecutionContext { export_config: None, document_id });
160+
self.futures.push_back((execution_id, ExecutionContext { export_config: None, document_id }));
161161

162162
Ok(DeferMessage::SetGraphSubmissionIndex { execution_id }.into())
163163
}
@@ -213,7 +213,7 @@ impl NodeGraphExecutor {
213213
export_config: Some(export_config),
214214
document_id,
215215
};
216-
self.futures.insert(execution_id, execution_context);
216+
self.futures.push_back((execution_id, execution_context));
217217

218218
Ok(())
219219
}
@@ -273,7 +273,19 @@ impl NodeGraphExecutor {
273273
responses.extend(existing_responses.into_iter().map(Into::into));
274274
document.network_interface.update_vector_modify(vector_modify);
275275

276-
let execution_context = self.futures.remove(&execution_id).ok_or_else(|| "Invalid generation ID".to_string())?;
276+
while let Some(&(fid, _)) = self.futures.front() {
277+
if fid < execution_id {
278+
self.futures.pop_front();
279+
} else {
280+
break;
281+
}
282+
}
283+
284+
let Some((fid, execution_context)) = self.futures.pop_front() else {
285+
panic!("InvalidGenerationId")
286+
};
287+
assert_eq!(fid, execution_id, "Missmatch in execution id");
288+
277289
if let Some(export_config) = execution_context.export_config {
278290
// Special handling for exporting the artwork
279291
self.export(node_graph_output, export_config, responses)?;

0 commit comments

Comments
 (0)