From 3fe10540d03ddf2bbfcf36d97a451f3ca80fbd66 Mon Sep 17 00:00:00 2001 From: uye <99072975+ABA2396@users.noreply.github.com> Date: Sun, 5 Jul 2026 23:42:26 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E5=B0=86=20FPS=20=E4=B8=8A=E6=8A=A5?= =?UTF-8?q?=E6=89=80=E9=9C=80=E7=9A=84=E6=95=B0=E6=8D=AE=E5=B0=81=E8=A3=85?= =?UTF-8?q?=E5=88=B0=E5=BC=82=E6=AD=A5=E4=BB=BB=E5=8A=A1=E7=9A=84=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E4=B8=AD=EF=BC=8C=E8=80=8C=E4=B8=8D=E6=98=AF=E4=BE=9D?= =?UTF-8?q?=E8=B5=96=20this?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MaaCore/Controller/AdbController.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/MaaCore/Controller/AdbController.cpp b/src/MaaCore/Controller/AdbController.cpp index 06362b157f..1ed8a9e453 100644 --- a/src/MaaCore/Controller/AdbController.cpp +++ b/src/MaaCore/Controller/AdbController.cpp @@ -1292,13 +1292,16 @@ void asst::AdbController::check_fps() m_last_fps_check_time = now; // 异步执行,避免 adb 延迟阻塞截图返回 - m_fps_future = std::async(std::launch::async, [this]() { + // 值捕获易变数据(m_uuid / m_adb.fps),防止 clear_info() 清空后异步线程读到悬空数据; + // call_command / callback 依赖的 mutex、platform_io、callback 等均为构造后不变, + // 生命周期由 ~AdbController 和 clear_info() 中的 m_fps_future.wait() 保证安全 + m_fps_future = std::async(std::launch::async, [this, cmd = m_adb.fps, uuid = m_uuid]() { if (need_exit()) { return; } // 放宽到 5 秒:异步执行后不再阻塞截图,可给 adb 足够时间 - auto ret = call_command(m_adb.fps, 5000, false); + auto ret = call_command(cmd, 5000, false); if (!ret || ret.value().empty()) { Log.warn("fps command failed or empty"); return; @@ -1335,7 +1338,7 @@ void asst::AdbController::check_fps() int fps_int = static_cast(std::round(fps)); json::value info = json::object { - { "uuid", m_uuid }, + { "uuid", uuid }, { "what", "EmulatorFPS" }, { "details", json::object {