From bed624f3b6f7ad5d25b5474c516561c537f10199 Mon Sep 17 00:00:00 2001 From: MediaPipe Team Date: Tue, 27 Jun 2023 01:59:59 -0700 Subject: [PATCH] Shows the recently added warning when WaitUntilIdle is called with source nodes only once. Otherwise, it is very spammy as it's shown every frame. Moreover, display the names of the sources, so the warning is more actionable. PiperOrigin-RevId: 543676454 --- mediapipe/framework/calculator_graph.cc | 17 +++++++++++++++-- mediapipe/framework/calculator_graph.h | 3 +++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/mediapipe/framework/calculator_graph.cc b/mediapipe/framework/calculator_graph.cc index 2a2088c6..33ca41fb 100644 --- a/mediapipe/framework/calculator_graph.cc +++ b/mediapipe/framework/calculator_graph.cc @@ -840,9 +840,12 @@ absl::Status CalculatorGraph::PrepareForRun( absl::Status CalculatorGraph::WaitUntilIdle() { if (has_sources_) { - LOG(WARNING) << "WaitUntilIdle called on a graph with source nodes, which " - "is not fully supported at the moment."; + LOG_FIRST_N(WARNING, 1) + << "WaitUntilIdle called on a graph with source nodes, which " + "is not fully supported at the moment. Source nodes: " + << ListSourceNodes(); } + MP_RETURN_IF_ERROR(scheduler_.WaitUntilIdle()); VLOG(2) << "Scheduler idle."; absl::Status status = absl::OkStatus(); @@ -1372,6 +1375,16 @@ const OutputStreamManager* CalculatorGraph::FindOutputStreamManager( .get()[validated_graph_->OutputStreamIndex(name)]; } +std::string CalculatorGraph::ListSourceNodes() const { + std::vector sources; + for (auto& node : nodes_) { + if (node->IsSource()) { + sources.push_back(node->DebugName()); + } + } + return absl::StrJoin(sources, ", "); +} + namespace { void PrintTimingToInfo(const std::string& label, int64_t timer_value) { const int64_t total_seconds = timer_value / 1000000ll; diff --git a/mediapipe/framework/calculator_graph.h b/mediapipe/framework/calculator_graph.h index 748d2fb3..00c922a3 100644 --- a/mediapipe/framework/calculator_graph.h +++ b/mediapipe/framework/calculator_graph.h @@ -597,6 +597,9 @@ class CalculatorGraph { // status before taking any action. void UpdateThrottledNodes(InputStreamManager* stream, bool* stream_was_full); + // Returns a comma-separated list of source nodes. + std::string ListSourceNodes() const; + #if !MEDIAPIPE_DISABLE_GPU // Owns the legacy GpuSharedData if we need to create one for backwards // compatibility.