Skip to content

Commit 068352c

Browse files
committed
Prevent render thread panic when the graph is not fully initialized yet
When the rendering has already commenced but the control thread has not set up the destination node, a panic occurs: ``` thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', src/render/graph.rs:479:14 ``` We now wait with rendering before the node count is at least 1
1 parent a750aa3 commit 068352c

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/render/graph.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ impl Graph {
104104
}
105105
}
106106

107+
/// Check if the graph is fully initialized and can start rendering
108+
pub fn is_active(&self) -> bool {
109+
// currently we only require the destination node to be present
110+
!self.nodes.is_empty()
111+
}
112+
107113
pub fn add_node(
108114
&mut self,
109115
index: AudioNodeId,

src/render/thread.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ impl RenderThread {
235235
self.handle_control_messages();
236236

237237
// if the thread is still booting, or shutting down, fill with silence
238-
if self.graph.is_none() {
238+
if !self.graph.as_ref().is_some_and(Graph::is_active) {
239239
output_buffer.fill(S::from_sample_(0.));
240240
return;
241241
}

0 commit comments

Comments
 (0)