From 889cd0a3f3453610ef5dd9c8d0f0ed1f44501e22 Mon Sep 17 00:00:00 2001 From: David <56174894+Constrat@users.noreply.github.com> Date: Mon, 4 Dec 2023 19:46:00 +0100 Subject: [PATCH] perf: reduced screencap timeout (#7476) refs: https://github.com/MaaAssistantArknights/MaaAssistantArknights/pull/7473#issuecomment-1838440548 https://github.com/MaaAssistantArknights/MaaAssistantArknights/pull/7473#issuecomment-1838446255 --- src/MaaCore/Controller/AdbController.cpp | 6 +++--- src/MaaCore/Controller/AdbController.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/MaaCore/Controller/AdbController.cpp b/src/MaaCore/Controller/AdbController.cpp index f5a5afd6bb..8bc45666ce 100644 --- a/src/MaaCore/Controller/AdbController.cpp +++ b/src/MaaCore/Controller/AdbController.cpp @@ -378,7 +378,7 @@ bool asst::AdbController::screencap(cv::Mat& image_payload, bool allow_reconnect auto start_time = high_resolution_clock::now(); if (m_support_socket && m_server_started && - screencap(m_adb.screencap_raw_by_nc, decode_raw, allow_reconnect, true)) { + screencap(m_adb.screencap_raw_by_nc, decode_raw, allow_reconnect, true, 5000)) { auto duration = duration_cast(high_resolution_clock::now() - start_time); if (duration < min_cost) { m_adb.screencap_method = AdbProperty::ScreencapMethod::RawByNc; @@ -455,13 +455,13 @@ bool asst::AdbController::screencap(cv::Mat& image_payload, bool allow_reconnect } bool asst::AdbController::screencap(const std::string& cmd, const DecodeFunc& decode_func, bool allow_reconnect, - bool by_socket) + bool by_socket, int timeout) { if ((!m_support_socket || !m_server_started) && by_socket) [[unlikely]] { return false; } - auto ret = call_command(cmd, 20000, allow_reconnect, by_socket); + auto ret = call_command(cmd, timeout, allow_reconnect, by_socket); if (!ret || ret.value().empty()) [[unlikely]] { Log.warn("data is empty!"); diff --git a/src/MaaCore/Controller/AdbController.h b/src/MaaCore/Controller/AdbController.h index 617dba468d..a8bc579c50 100644 --- a/src/MaaCore/Controller/AdbController.h +++ b/src/MaaCore/Controller/AdbController.h @@ -63,7 +63,7 @@ namespace asst using DecodeFunc = std::function; bool screencap(const std::string& cmd, const DecodeFunc& decode_func, bool allow_reconnect = false, - bool by_socket = false); + bool by_socket = false, int max_timeout = 20000); void clear_lf_info(); virtual void clear_info() noexcept;