From c4f02514f080ec6d8e6a06d9a091da51802e7327 Mon Sep 17 00:00:00 2001 From: MistEO Date: Fri, 17 Apr 2026 17:32:47 +0800 Subject: [PATCH] fix: skip screencap when all next nodes use DirectHit recognition DirectHit does not require image data, so avoid calling screencap() when every enabled node in the next list uses DirectHit. This allows non-visual pipeline tasks (e.g. Custom actions) to proceed even when the controller is disconnected or unavailable. Made-with: Cursor --- source/MaaFramework/Task/PipelineTask.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source/MaaFramework/Task/PipelineTask.cpp b/source/MaaFramework/Task/PipelineTask.cpp index a3143cf222..13c4cdb079 100644 --- a/source/MaaFramework/Task/PipelineTask.cpp +++ b/source/MaaFramework/Task/PipelineTask.cpp @@ -161,11 +161,16 @@ NodeDetail PipelineTask::run_next(const std::vector& next, return true; }; + const bool need_screencap = !std::ranges::all_of(next, [&](const MAA_RES_NS::NodeAttr& node) { + auto data_opt = context_->get_pipeline_data(node); + return !data_opt || !data_opt->enabled || data_opt->reco_type == MAA_RES_NS::Recognition::Type::DirectHit; + }); + while (!context_->need_to_stop()) { auto current_clock = std::chrono::steady_clock::now(); - cv::Mat image = screencap(); + cv::Mat image = need_screencap ? screencap() : cv::Mat {}; - if (image.empty()) { + if (need_screencap && image.empty()) { LogWarn << "screencap failed, skip recognition" << VAR(pretask.name); if (!check_timeout_and_sleep(current_clock)) { break;