From e468ef1f2ec2ea685ed18121a255462beeaa13e3 Mon Sep 17 00:00:00 2001 From: pianostringquartet Date: Fri, 12 Sep 2025 13:53:29 -0600 Subject: [PATCH] Wipe pulse outputs on graph reset --- .../Node/Port/Util/PortValue/PortValuesUtils.swift | 7 +++++-- .../NodeRowObserverSchemaObserverIdentifiable.swift | 12 ++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Stitch/Graph/Node/Port/Util/PortValue/PortValuesUtils.swift b/Stitch/Graph/Node/Port/Util/PortValue/PortValuesUtils.swift index 0081170cc..821548e8d 100644 --- a/Stitch/Graph/Node/Port/Util/PortValue/PortValuesUtils.swift +++ b/Stitch/Graph/Node/Port/Util/PortValue/PortValuesUtils.swift @@ -121,9 +121,12 @@ extension PortValuesList { var outputsLoop = PortValues() for output in self { - outputsLoop.append(output[loopIndex]) +// outputsLoop.append(output[loopIndex]) + if let valueAtIndex = output[safe: loopIndex] { + outputsLoop.append(valueAtIndex) + } } - + valuesList.append(outputsLoop) } diff --git a/Stitch/Graph/Node/Port/ViewModel/NodeRowObserver/NodeRowObserverSchemaObserverIdentifiable.swift b/Stitch/Graph/Node/Port/ViewModel/NodeRowObserver/NodeRowObserverSchemaObserverIdentifiable.swift index beb43b3c6..23d371306 100644 --- a/Stitch/Graph/Node/Port/ViewModel/NodeRowObserver/NodeRowObserverSchemaObserverIdentifiable.swift +++ b/Stitch/Graph/Node/Port/ViewModel/NodeRowObserver/NodeRowObserverSchemaObserverIdentifiable.swift @@ -86,10 +86,22 @@ extension InputNodeRowObserver: SchemaObserverIdentifiable { } extension OutputNodeRowObserver { + @MainActor func onPrototypeRestart(document: StitchDocumentViewModel) { // Set outputs to be empty // MARK: no longer seems necessary, removing for fixing flashing media on restart // self.allLoopedValues = [] + +// let containsMedia = self.allLoopedValues.first?.asyncMedia.isDefined ?? false +// if !containsMedia { +// self.allLoopedValues = [] +// } + + // TODO: better to only reset based on pulses, since some nodes may still look at old-style previous outputs? + let containsPulse = self.allLoopedValues.first?.getPulse.isDefined ?? false + if containsPulse { + self.allLoopedValues = [] + } } }