Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pipeline failed to screencap,画面颜色错误 #300

Open
FSPaul2498 opened this issue Aug 1, 2024 · 10 comments
Open

pipeline failed to screencap,画面颜色错误 #300

FSPaul2498 opened this issue Aug 1, 2024 · 10 comments
Labels
bug Something isn't working

Comments

@FSPaul2498
Copy link

使用Python集成MAA,在一个实例下长时间执行不同pipeline task后,会出现崩溃情况,且使用controller.screencap获得的实时截图色彩错误。
崩溃控制台输出如下

====================
开始执行任务 Start-快速回到搜索页
[2024-07-01 13:03:26.168][ERR][Px1462][Tx35400][ScreencapHelper.cpp][L74][std::optional<cv::Mat> MaaNS::CtrlUnitNs::ScreencapHelper::process_data(std::string &, std::function<std::optional<cv::Mat> (const std::string &)>)] convert lf and retry decode failed! 
[2024-07-01 13:03:26.168][ERR][Px1462][Tx35400][ControlUnitMgr.cpp][L290][bool MaaNS::CtrlUnitNs::ControlUnitMgr::_screencap(cv::Mat &)] failed to screencap 
[2024-07-01 13:03:26.187][ERR][Px1462][Tx35400][UnitBase.cpp][L65][std::optional<std::string> MaaNS::CtrlUnitNs::UnitBase::startup_and_read_pipe(const ProcessArgv &, std::chrono::seconds)] child return error [argv.exec=/Users/username/Library/Android/sdk/platform-tools/adb] [argv.args=["-s","127.0.0.1:5555","exec-out","screencap | gzip -1"]] 
[2024-07-01 13:03:26.187][ERR][Px1462][Tx35400][ControlUnitMgr.cpp][L290][bool MaaNS::CtrlUnitNs::ControlUnitMgr::_screencap(cv::Mat &)] failed to screencap 
[2024-07-01 13:03:26.202][ERR][Px1462][Tx35400][UnitBase.cpp][L65][std::optional<std::string> MaaNS::CtrlUnitNs::UnitBase::startup_and_read_pipe(const ProcessArgv &, std::chrono::seconds)] child return error [argv.exec=/Users/username/Library/Android/sdk/platform-tools/adb] [argv.args=["-s","127.0.0.1:5555","exec-out","screencap | gzip -1"]] 
[2024-07-01 13:03:26.203][ERR][Px1462][Tx35400][ControlUnitMgr.cpp][L290][bool MaaNS::CtrlUnitNs::ControlUnitMgr::_screencap(cv::Mat &)] failed to screencap 
[2024-07-01 13:03:26.220][ERR][Px1462][Tx35400][UnitBase.cpp][L65][std::optional<std::string> MaaNS::CtrlUnitNs::UnitBase::startup_and_read_pipe(const ProcessArgv &, std::chrono::seconds)] child return error [argv.exec=/Users/username/Library/Android/sdk/platform-tools/adb] [argv.args=["-s","127.0.0.1:5555","exec-out","screencap | gzip -1"]] 
[2024-07-01 13:03:26.221][ERR][Px1462][Tx35400][ControlUnitMgr.cpp][L290][bool MaaNS::CtrlUnitNs::ControlUnitMgr::_screencap(cv::Mat &)] failed to screencap 
[2024-07-01 13:03:26.234][ERR][Px1462][Tx35400][UnitBase.cpp][L65][std::optional<std::string> MaaNS::CtrlUnitNs::UnitBase::startup_and_read_pipe(const ProcessArgv &, std::chrono::seconds)] child return error [argv.exec=/Users/username/Library/Android/sdk/platform-tools/adb] [argv.args=["-s","127.0.0.1:5555","exec-out","screencap | gzip -1"]] 
[2024-07-01 13:03:26.234][ERR][Px1462][Tx35400][ControlUnitMgr.cpp][L290][bool MaaNS::CtrlUnitNs::ControlUnitMgr::_screencap(cv::Mat &)] failed to screencap 
[2024-07-01 13:03:26.249][ERR][Px1462][Tx35400][UnitBase.cpp][L65][std::optional<std::string> MaaNS::CtrlUnitNs::UnitBase::startup_and_read_pipe(const ProcessArgv &, std::chrono::seconds)] child return error [argv.exec=/Users/username/Library/Android/sdk/platform-tools/adb] [argv.args=["-s","127.0.0.1:5555","exec-out","screencap | gzip -1"]] 
[2024-07-01 13:03:26.249][ERR][Px1462][Tx35400][ControlUnitMgr.cpp][L290][bool MaaNS::CtrlUnitNs::ControlUnitMgr::_screencap(cv::Mat &)] failed to screencap 
[2024-07-01 13:03:26.265][ERR][Px1462][Tx35400][UnitBase.cpp][L65][std::optional<std::string> MaaNS::CtrlUnitNs::UnitBase::startup_and_read_pipe(const ProcessArgv &, std::chrono::seconds)] child return error [argv.exec=/Users/username/Library/Android/sdk/platform-tools/adb] [argv.args=["-s","127.0.0.1:5555","exec-out","screencap | gzip -1"]] 
[2024-07-01 13:03:26.265][ERR][Px1462][Tx35400][ControlUnitMgr.cpp][L290][bool MaaNS::CtrlUnitNs::ControlUnitMgr::_screencap(cv::Mat &)] failed to screencap 
[2024-07-01 13:03:26.281][ERR][Px1462][Tx35400][UnitBase.cpp][L65][std::optional<std::string> MaaNS::CtrlUnitNs::UnitBase::startup_and_read_pipe(const ProcessArgv &, std::chrono::seconds)] child return error [argv.exec=/Users/username/Library/Android/sdk/platform-tools/adb] [argv.args=["-s","127.0.0.1:5555","exec-out","screencap | gzip -1"]] 
[2024-07-01 13:03:26.281][ERR][Px1462][Tx35400][ControlUnitMgr.cpp][L290][bool MaaNS::CtrlUnitNs::ControlUnitMgr::_screencap(cv::Mat &)] failed to screencap 
[2024-07-01 13:03:26.298][ERR][Px1462][Tx35400][UnitBase.cpp][L65][std::optional<std::string> MaaNS::CtrlUnitNs::UnitBase::startup_and_read_pipe(const ProcessArgv &, std::chrono::seconds)] child return error [argv.exec=/Users/username/Library/Android/sdk/platform-tools/adb] [argv.args=["-s","127.0.0.1:5555","exec-out","screencap | gzip -1"]] 
[2024-07-01 13:03:26.298][ERR][Px1462][Tx35400][ControlUnitMgr.cpp][L290][bool MaaNS::CtrlUnitNs::ControlUnitMgr::_screencap(cv::Mat &)] failed to screencap 
[2024-07-01 13:03:26.315][ERR][Px1462][Tx35400][UnitBase.cpp][L65][std::optional<std::string> MaaNS::CtrlUnitNs::UnitBase::startup_and_read_pipe(const ProcessArgv &, std::chrono::seconds)] child return error [argv.exec=/Users/username/Library/Android/sdk/platform-tools/adb] [argv.args=["-s","127.0.0.1:5555","exec-out","screencap | gzip -1"]] 
[2024-07-01 13:03:26.315][ERR][Px1462][Tx35400][ControlUnitMgr.cpp][L290][bool MaaNS::CtrlUnitNs::ControlUnitMgr::_screencap(cv::Mat &)] failed to screencap 
[2024-07-01 13:03:26.349][ERR][Px1462][Tx35400][UnitBase.cpp][L65][std::optional<std::string> MaaNS::CtrlUnitNs::UnitBase::startup_and_read_pipe(const ProcessArgv &, std::chrono::seconds)] child return error [argv.exec=/Users/username/Library/Android/sdk/platform-tools/adb] [argv.args=["-s","127.0.0.1:5555","shell","settings get secure android_id"]] 
[2024-07-01 13:03:26.365][ERR][Px1462][Tx35400][UnitBase.cpp][L65][std::optional<std::string> MaaNS::CtrlUnitNs::UnitBase::startup_and_read_pipe(const ProcessArgv &, std::chrono::seconds)] child return error [argv.exec=/Users/username/Library/Android/sdk/platform-tools/adb] [argv.args=["-s","127.0.0.1:5555","exec-out","screencap | gzip -1"]] 
[2024-07-01 13:03:26.365][ERR][Px1462][Tx35400][ControlUnitMgr.cpp][L290][bool MaaNS::CtrlUnitNs::ControlUnitMgr::_screencap(cv::Mat &)] failed to screencap 
[2024-07-01 13:03:26.381][ERR][Px1462][Tx35400][UnitBase.cpp][L65][std::optional<std::string> MaaNS::CtrlUnitNs::UnitBase::startup_and_read_pipe(const ProcessArgv &, std::chrono::seconds)] child return error [argv.exec=/Users/username/Library/Android/sdk/platform-tools/adb] [argv.args=["-s","127.0.0.1:5555","exec-out","screencap | gzip -1"]] 
[2024-07-01 13:03:26.381][ERR][Px1462][Tx35400][ControlUnitMgr.cpp][L290][bool MaaNS::CtrlUnitNs::ControlUnitMgr::_screencap(cv::Mat &)] failed to screencap 
[2024-07-01 13:03:26.396][ERR][Px1462][Tx35400][UnitBase.cpp][L65][std::optional<std::string> MaaNS::CtrlUnitNs::UnitBase::startup_and_read_pipe(const ProcessArgv &, std::chrono::seconds)] child return error [argv.exec=/Users/username/Library/Android/sdk/platform-tools/adb] [argv.args=["-s","127.0.0.1:5555","exec-out","screencap | gzip -1"]] 
[2024-07-01 13:03:26.396][ERR][Px1462][Tx35400][ControlUnitMgr.cpp][L290][bool MaaNS::CtrlUnitNs::ControlUnitMgr::_screencap(cv::Mat &)] failed to screencap 
[2024-07-01 13:03:30.269][ERR][Px1462][Tx35400][ChildPipeIOStream.cpp][L111][virtual bool MaaNS::ChildPipeIOStream::write(std::string_view)] pout is not good [exec_=/Users/username/Library/Android/sdk/platform-tools/adb] [args_=["-s","127.0.0.1:5555","shell","export CLASSPATH=\"/data/local/tmp/2024.07.01-12.04.05.236437\"; app_process /data/local/tmp com.shxyke.MaaTouch.App"]] [child_.id()=1497] 
[2024-07-01 13:03:30.269][ERR][Px1462][Tx35400][MtouchHelper.cpp][L99][virtual bool MaaNS::CtrlUnitNs::MtouchHelper::click(int, int)] failed to write 
[2024-07-01 13:03:30.269][ERR][Px1462][Tx35400][GeneralControllerAgent.cpp][L112][virtual bool MaaNS::ControllerNS::GeneralControllerAgent::_click(ClickParam)] controller click failed [param.x=734] [param.y=120] 
[2024-07-01 13:03:30.779][ERR][Px1462][Tx42058][PipelineTask.cpp][L65][bool MaaNS::TaskNS::PipelineTask::run_pipeline()] Task InternalError: Click-清空内容按钮 
开始执行任务 Input-搜索词-626 loewe经典迷你手袋
[2024-07-01 13:03:31.141][ERR][Px1462][Tx35400][ChildPipeIOStream.cpp][L111][virtual bool MaaNS::ChildPipeIOStream::write(std::string_view)] pout is not good [exec_=/Users/username/Library/Android/sdk/platform-tools/adb] [args_=["-s","127.0.0.1:5555","shell","export CLASSPATH=\"/data/local/tmp/2024.07.01-12.04.05.236437\"; app_process /data/local/tmp com.shxyke.MaaTouch.App"]] [child_.id()=1497] 
[2024-07-01 13:03:31.141][ERR][Px1462][Tx35400][MaatouchInput.cpp][L97][virtual bool MaaNS::CtrlUnitNs::MaatouchInput::input_text(const std::string &)] failed to write 
[2024-07-01 13:03:31.142][ERR][Px1462][Tx35400][GeneralControllerAgent.cpp][L205][virtual bool MaaNS::ControllerNS::GeneralControllerAgent::_input_text(InputTextParam)] controller input_text failed [param.text=loewe经典迷你手袋] 
[2024-07-01 13:03:32.337][ERR][Px1462][Tx42058][PipelineTask.cpp][L65][bool MaaNS::TaskNS::PipelineTask::run_pipeline()] Task InternalError: Input-搜索词-626 
====================

后续执行的task均重复最后四行的报错。

我的集成逻辑设置了每次执行task后进行一次controller截图保存,查阅截图发现崩溃后每次controller截图的整体色彩错误,如下
错误的界面截图
cap_err
实际上此时的界面截图
cap_real
保持现场并使用MAA Debugger重连AVD发现截图色彩正常,基本可以排除AVD故障的可能性。

@MistEO
Copy link
Member

MistEO commented Aug 1, 2024

opencv 或者说传统图像处理惯用的颜色是 BGR 而非 RGB,screencap 接口返回的也是

@MistEO
Copy link
Member

MistEO commented Aug 1, 2024

崩溃问题给一下具体的复现路径和 maa.log

@FSPaul2498
Copy link
Author

崩溃问题给一下具体的复现路径和 maa.log

我设计了41906个case,我的python集成会加载所有这些case,创建一个maa实例,然后每个case顺序执行两个pipeline,两个pipeline的入口task依次为【Start-快速回到搜索页】和【Input-搜索词-*】,*为case id。最后一个正确执行的task为【Input-搜索词-625】,然后下一轮case的【Start-快速回到搜索页】开始发生崩溃。崩溃前controller.screencap获取保存的截图颜色正常,崩溃后开始颜色错误,个人猜测是controller崩溃,连带导致maa实例错误。
maa.log如下(log较长,我删减了最后一个正确执行的task之前的部分内容和后续重复失败task的部分内容)
maa_clean.log

@MistEO
Copy link
Member

MistEO commented Aug 1, 2024

感觉理解有偏差,你说的崩溃是指 crash / core dump 吗?

@FSPaul2498
Copy link
Author

FSPaul2498 commented Aug 1, 2024

感觉理解有偏差,你说的崩溃是指 crash / core dump 吗?

啊非常抱歉 可能是我表述的问题,我指的是发生异常后,MAA实例无法再成功执行任何task,每次run_task都会卡在首个task打印以上报错然后结束task,但MAA实例仍然存活,并没有 crash / coredump,这也许叫做“异常运行状态”更准确一些

@neko-para
Copy link
Contributor

  1. 这里获取的实时截图是在所谓崩溃后才错误的吗? 即, 在崩溃前获取的颜色是正常的吗?
  2. 如果令每个case独立创建实例, 结束后销毁, 可以复现问题吗?

@FSPaul2498
Copy link
Author

  1. 这里获取的实时截图是在所谓崩溃后才错误的吗? 即, 在崩溃前获取的颜色是正常的吗?
  2. 如果令每个case独立创建实例, 结束后销毁, 可以复现问题吗?
  1. 是的,前面几百个case成功执行后的controller截图色彩都是正常的,在后续case出现异常之后,截图色彩也出现了异常。
  2. 因为case数量较多,每个case独立创建MAA实例的方式会极大增加测试时间成本,因此尚未测试。我在手动终止以上异常MAA实例后,重新执行我的Python集成创建实例,可以正确开始新一轮测试,猜测理论上此方法应该不会复现问题。

@neko-para
Copy link
Contributor

其实实例创建的成本不算高, 倒是controller创建确实不低; 可以先考虑每100-200个case之后移除并重新创建一次controller, 应该能暂时绕过现在的问题

@neko-para
Copy link
Contributor

看日志执行了600多个case之后, adb进程拉起来无法绑定管道了, 可以在刚启动和接近500-600case的是用活动监视器看一下是不是fd泄露了

@neko-para
Copy link
Contributor

029a81901387496a1e7a2d77e3cd070d

@MistEO MistEO added the bug Something isn't working label Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants