KeymouseGo icon indicating copy to clipboard operation
KeymouseGo copied to clipboard

无缘无故暂停

Open yinghaodang opened this issue 3 years ago • 3 comments

我也不清楚什么情况...我使用的浏览器是chrome,我想用这个软件对浏览器中某个按钮实现连点,但是每次脚本运行10来次就会自动闪退。(我设置了运行500次)

yinghaodang avatar Aug 07 '22 02:08 yinghaodang

暂时无法重现这个问题,我在自己电脑上使用5.0非upx压缩版本进行测试:

  • 环境:Windows10 21h2
  • 操作:
    1. 用chrome打开连点测试网站
    2. 录制点击一次按钮的事件
    3. 重复运行500次
  • 结果: 无闪退现象,将录制事件的速度提升为1毫秒内完成一次点击后依旧没有闪退。

如果闪退现象持续发生,可以提供一些更加详细的信息便于重现问题以及调试解决,如程序版本、程序日志、程序参数信息、系统环境、浏览器版本、测试网站(如果只在特定网站上出错的话)和重现错误的脚本。

OKOtohime avatar Aug 08 '22 08:08 OKOtohime

  • 环境: windows10 21h2, 运行内存16g
  • 操作:
    1. 用chrome打开连点测试网站
    2. 录制点击一次按钮的事件
    3. 重复运行500次

自己从网站下的5.0非upx压缩版本

  • 结果:
    • 运行10次, 成功3次, 闪退6次, 程序无响应1次

直接运行master分支程序

  • 结果:
    • 运行10次, 成功0次, 闪退6次, 程序无响应4次
    • 闪退原因命令行显示为段错误

ZutJoe avatar Aug 15 '22 09:08 ZutJoe

可以复现了,应该是之前我测试的次数不够多,后来测试时release版本大概是10次左右闪退一次,源码调试时13次左右闪退一次。

程序在执行过程中闪退,具体情况为:

  • logger没有catch到任何异常
  • 使用性能监视器监控内存使用情况,程序闪退前内存占用没有剧烈变化(排除内存泄漏的可能)

事件查看器信息: 图片

OKOtohime avatar Aug 16 '22 07:08 OKOtohime

我有个想法:目前的程序一共使用了两个线程,主线程处理UI逻辑,子线程执行脚本。但是目前的实现中子线程涉及对UI控件的修改(文字提示以及日志框),并且使用的线程是python线程(threading.Thread),对于Qt程序来说是线程不安全的。因此在实现连点时,子线程对控件频繁修改,最终出现问题。

解决方法 使用QThread实现RunScriptClass,将所有在子线程中修改控件内容的部分使用槽-信号重构。

参考: DEBUG pyqt + ntdll.dll + 随机异常退出 PyQt5中使用线程QThread和Thread进行耗时操作的问题

OKOtohime avatar Sep 30 '22 03:09 OKOtohime

解决方法 使用QThread实现RunScriptClass,将所有在子线程中修改控件内容的部分使用槽-信号重构。

我在提交的更改中 a72558fcd81ffd18eae86bfdccbf3716c4f04c74 重构了相应代码,使用pyinstaller打包后按照以下配置运行了14次测试脚本,均无闪退或无响应情况。

配置:

[Config]
StartHotKeyIndex=3
StopHotKeyIndex=6
RecordHotKeyIndex=7
LoopTimes=5000
Precision=200
ExecuteSpeed=100
Language=zh-cn
Extension=Extension
Theme=dark_pink.xml
Script=0930_1011.txt

测试脚本:

[
 [0,"EM","mouse left down",["0.32708333333333334%","0.6481481481481481%"]],
 [5,"EM","mouse left up",["0.32708333333333334%","0.6481481481481481%"]]
]

OKOtohime avatar Oct 04 '22 05:10 OKOtohime

我回去测试一下,再把文件管理相关的i18n给改了,是不是可以发个小版本了👀

ZutJoe avatar Oct 04 '22 05:10 ZutJoe

我回去测试一下,再把文件管理相关的i18n给改了,是不是可以发个小版本了👀

可以

OKOtohime avatar Oct 04 '22 06:10 OKOtohime

先说结论:效果不太理想

ps:和文件名称无关,在没有更改名称时也是相同结果

配置:

[Config]
StartHotKeyIndex=3
StopHotKeyIndex=6
RecordHotKeyIndex=7
LoopTimes=20
Precision=212
ExecuteSpeed=96
Theme=dark_cyan.xml
Extension=Extension
Script=\x6d4b\x8bd5.txt

测试脚本:

[
 [0,"EM","mouse left down",["0.47291666666666665%","0.5583333333333333%"]],
 [5,"EM","mouse left up",["0.47291666666666665%","0.5583333333333333%"]],
]

测试结果:


## 第一次点击
2022-10-04 17:39:27.738 | INFO     | UIFunc:get_script_path:355 - Script path: D:\workspace\PR\KeymouseGo\scripts\测试.txt
2022-10-04 17:39:27.747 | INFO     | UIFunc:run:513 - 测试.txt running..
2022-10-04 17:39:27.747 | DEBUG    | UIFunc:run:516 - Parse script..
2022-10-04 17:39:27.747 | DEBUG    | UIFunc:parsescript:621 - Script content
2022-10-04 17:39:27.747 | DEBUG    | UIFunc:parsescript:622 - [[0,"EM","mouse left down",["0.47291666666666665%","0.5583333333333333%"]],[5,"EM","mouse left up",["0.47291666666666665%","0.5583333333333333%"]]]
2022-10-04 17:39:27.747 | INFO     | UIFunc:getextension:590 - Load plugin class <class 'Extension.Extension'> in module Extension
2022-10-04 17:39:27.747 | DEBUG    | UIFunc:run:534 - Run script..
2022-10-04 17:39:27.755 | DEBUG    | UIFunc:run:538 - ===========0==============

2022-10-04 17:39:27.755 | DEBUG    | UIFunc:run_script_once:712 - [0, EM, mouse left down, ['0.47291666666666665%', '0.5583333333333333%']]
TypeError: 'float' object cannot be interpreted as an integer
D:\workspace\PR\KeymouseGo\UIFunc.py:477: RuntimeWarning: libshiboken: Overflow: Value 0.0 exceeds limits of type  [signed] "__int64" (8bytes).
  cond.wait(mutex, QDeadlineTimer(msecs))
2022-10-04 17:39:27.780 | ERROR    | UIFunc:run:570 - Run error:
Traceback (most recent call last):
  File "D:\workspace\PR\KeymouseGo\UIFunc.py", line 547, in run
    nointerrupt = nointerrupt and RunScriptClass.run_script_once(events, extension, thd=self,
  File "D:\workspace\PR\KeymouseGo\UIFunc.py", line 713, in run_script_once
    event.execute(thd)
  File "D:\workspace\PR\KeymouseGo\Event\WindowsEvents.py", line 36, in execute
    self.sleep(thd)
  File "D:\workspace\PR\KeymouseGo\Event\Event.py", line 28, in sleep
    thd.sleep(self.delay)
  File "D:\workspace\PR\KeymouseGo\UIFunc.py", line 477, in sleep
    cond.wait(mutex, QDeadlineTimer(msecs))
OverflowError

## 在没有按照规划执行之后再次点击
2022-10-04 17:39:30.207 | INFO     | UIFunc:OnBtrunButton:445 - Script start
2022-10-04 17:39:30.207 | DEBUG    | UIFunc:OnBtrunButton:446 - Script start by btn
2022-10-04 17:39:30.207 | DEBUG    | UIFunc:__init__:460 - Thread created at thread<_MainThread(MainThread, started 26552)>

## 后面的结果就是像第二次一样了,但是都不会执行

ZutJoe avatar Oct 04 '22 09:10 ZutJoe

QDeadlineTimer构造函数不支持float类型参数,已提交修改 040db4e05334712664ee060438c76de55d859dcf

OKOtohime avatar Oct 04 '22 10:10 OKOtohime

QDeadlineTimer构造函数不支持float类型参数,已提交修改 040db4e

收到,我再试试

ZutJoe avatar Oct 04 '22 10:10 ZutJoe

测试了几次,目前没有测试出问题,牛的

ZutJoe avatar Oct 04 '22 10:10 ZutJoe