Reduce pipeline use-after-free errors (#1447)

This commit is contained in:
Cameron (3539)
2024-10-07 11:35:18 -04:00
committed by GitHub
parent cd9dd07282
commit c4b273e737

View File

@@ -101,13 +101,17 @@ public class VisionRunner {
continue;
}
// There's no guarantee the processing type change will occur this tick, so pipelines should
// check themselves
try {
var pipelineResult = pipeline.run(frame, cameraQuirks);
pipelineResultConsumer.accept(pipelineResult);
} catch (Exception ex) {
logger.error("Exception on loop " + loopCount, ex);
// If the pipeline has changed while we are getting our frame we should scrap that frame it
// may result in incorrect frame settings like hsv values
if (pipeline == pipelineSupplier.get()) {
// There's no guarantee the processing type change will occur this tick, so pipelines should
// check themselves
try {
var pipelineResult = pipeline.run(frame, cameraQuirks);
pipelineResultConsumer.accept(pipelineResult);
} catch (Exception ex) {
logger.error("Exception on loop " + loopCount, ex);
}
}
loopCount++;