openatx / uiautomator2

Android Uiautomator2 Python Wrapper
MIT License
6.25k stars 1.36k forks source link

ATX里面的uiautomator2服务过了几分钟就会自动断开 #516

Closed Hedilict closed 1 week ago

Hedilict commented 4 years ago

[I 200114 20:48:20 init:132] uiautomator2 version: 2.4.6 [D 200114 20:48:20 init:729] restart-uiautomator since "atx-agent restarted" [D 200114 20:48:20 init:777] Device: Android, 127.0.0.1:7555 [D 200114 20:48:21 init:783] stop app: com.github.uiautomator [D 200114 20:48:21 init:787] kill process(ps): uiautomator Traceback (most recent call last): File "D:/Project/XXQG/main.py", line 531, in driver = Driver().d File "D:/Project/XXQG/main.py", line 19, in init self.d = u2.connect(addr) File "D:\Python37\lib\site-packages\uiautomator2__init.py", line 124, in connect return connect_usb(addr) File "D:\Python37\lib\site-packages\uiautomator2__init.py", line 168, in connect_usb d._init_atx_agent() File "D:\Python37\lib\site-packages\uiautomator2\init.py", line 345, in _init_atx_agent self.reset_uiautomator("atx-agent restarted") File "D:\Python37\lib\site-packages\uiautomator2\init__.py", line 733, in reset_uiautomator ok = self._force_reset_uiautomator_v2() # uiautomator 2.0 File "D:\Python37\lib\site-packages\uiautomator2\init.py", line 788, in _force_reset_uiautomator_v2 self._kill_process_by_name("uiautomator") File "D:\Python37\lib\site-packages\uiautomator2\init.py", line 647, in _kill_process_by_name for p in self._iter_process(): File "D:\Python37\lib\site-packages\uiautomator2\init__.py", line 1163, in _iter_process if fields[0] == "USER": IndexError: list index out of range

这个错误应该是uiautomator服务自动关闭后报的错误,手动将ATX里面的uiauyomator2服务开启后就运行正常了,问题是这个服务几分钟后自己就关闭了,不知道什么原因。

codeskyblue commented 4 years ago

这错误有点神奇哈。ps ; ps -A 这个命令输出什么?

350050183 commented 4 years ago

ATX 不稳定,经常重启uiautomator2,在执行任务中间也会重启。

[I 200307 23:14:05 init:132] uiautomator2 version: 2.5.7 [D 200307 23:14:06 init:766] restart-uiautomator since "UiAutomation not connected" [D 200307 23:14:06 init:822] Device: HUAWEI, THF6R19A21001267 [D 200307 23:14:06 init:828] stop app: com.github.uiautomator [D 200307 23:14:06 init:832] kill process(ps): uiautomator [D 200307 23:14:07 init:846] uiautomator-v2 is starting ... left: 40.0s [D 200307 23:14:08 init:846] uiautomator-v2 is starting ... left: 39.0s [D 200307 23:14:09 init:846] uiautomator-v2 is starting ... left: 37.9s [D 200307 23:14:10 init:846] uiautomator-v2 is starting ... left: 36.9s [D 200307 23:14:11 init:846] uiautomator-v2 is starting ... left: 35.9s [D 200307 23:14:12 init:846] uiautomator-v2 is starting ... left: 34.9s [D 200307 23:14:13 init:846] uiautomator-v2 is starting ... left: 33.8s [D 200307 23:14:14 init:846] uiautomator-v2 is starting ... left: 32.8s [I 200307 23:14:14 init:786] uiautomator back to normal

codeskyblue commented 4 years ago

现在是每隔3分钟,如果没有任何UI操作的话,会关掉uiautomator服务。释放accessibility服务的占用。 不过貌似很多人对这个不太理解。要不改成3小时好了。

350050183 commented 4 years ago

现在是每隔3分钟,如果没有任何UI操作的话,会关掉uiautomator服务。释放accessibility服务的占用。 不过貌似很多人对这个不太理解。要不改成3小时好了。

如果3分钟断开一次,断开后再启动时,好像会恢复运行uiautomator,但不会恢复正常的执行,还要再运行一遍,调试时,每次都要运行2次,好麻烦。改成3小时比较好。

Hedilict commented 4 years ago

现在是每隔3分钟,如果没有任何UI操作的话,会关掉uiautomator服务。释放accessibility服务的占用。 不过貌似很多人对这个不太理解。要不改成3小时好了。

3分钟的确太短了。就我个人而言,开发过程中会通过wdeitor进行调试,一般在思考通过哪些元素获取对应的内容过程时,经常会超过3分钟。这样的话,就需要重启uiautomotar服务,比较麻烦。

Hedilict commented 4 years ago

这错误有点神奇哈。ps ; ps -A 这个命令输出什么?

我之前测试过,ps会正常输出进程。但是貌似通过uiautomator2调用的ps命令无法获取进程。不过我代码中先手动借助adb初始化uiautomator2,这样就可以绕过这个错误了。感觉这不是bug吧,没见到其他人提这个issue。

zhbzhbzhbz commented 4 years ago

我也是,经常重启

BiteFoo commented 4 years ago

手机:nexus 6p 系统:Android7.0 uiautomator2版本:Version: 2.5.6 问题:运行操作3小时之后,会卡住或者无反应,重启u2或者手机也不行。

现象是:手机还在操作,但是时间久了,还是会卡住(也就是点击了没反应),例如swipe_ext('up',scale=0.25)或者d.click()时,没反应。如果人工滑动一次或者点击一次,似乎就恢复正常。有时候执行一次点击之后,程序会一直提示"restart-uiautomator since "UiAutomation not connected"",接着u2会restart 服务也不行。即使我重启设备或者重新healthcheck()也没有效果。

c0rpse commented 4 years ago

现在是每隔3分钟,如果没有任何UI操作的话,会关掉uiautomator服务。释放accessibility服务的占用。 不过貌似很多人对这个不太理解。要不改成3小时好了。

问一下,accessibility服务是在什么时候启动的?是哪个程序启动的? @codeskyblue

pengyanbing84 commented 4 years ago

现在是每隔3分钟,如果没有任何UI操作的话,会关掉uiautomator服务。释放可访问性服务的占用。 不过貌似很多人对这个不太理解。要不改成3小时好了。

我认为时间长一些, 3分钟太短了,遇到网络问题,比如上传视频网络不好,需要等待很久,我认为30分钟比较合理了

lizhixin2016 commented 3 years ago

请问自动断开的timeout改成3小时在uiautomator2 2.10.0版本上合入了么? 2.10.0还是会经常断@codeskyblue

codeskyblue commented 3 years ago

目前应该就是3小时,忘了哪个版本了,应该是半年前

Sent with GitHawk

Louis24 commented 3 years ago

2.3.1 0.9.5

Louis24 commented 3 years ago

ATX 不稳定,经常重启uiautomator2,在执行任务中间也会重启。

[I 200307 23:14:05 init:132] uiautomator2 version: 2.5.7 [D 200307 23:14:06 init:766] restart-uiautomator since "UiAutomation not connected" [D 200307 23:14:06 init:822] Device: HUAWEI, THF6R19A21001267 [D 200307 23:14:06 init:828] stop app: com.github.uiautomator [D 200307 23:14:06 init:832] kill process(ps): uiautomator [D 200307 23:14:07 init:846] uiautomator-v2 is starting ... left: 40.0s [D 200307 23:14:08 init:846] uiautomator-v2 is starting ... left: 39.0s [D 200307 23:14:09 init:846] uiautomator-v2 is starting ... left: 37.9s [D 200307 23:14:10 init:846] uiautomator-v2 is starting ... left: 36.9s [D 200307 23:14:11 init:846] uiautomator-v2 is starting ... left: 35.9s [D 200307 23:14:12 init:846] uiautomator-v2 is starting ... left: 34.9s [D 200307 23:14:13 init:846] uiautomator-v2 is starting ... left: 33.8s [D 200307 23:14:14 init:846] uiautomator-v2 is starting ... left: 32.8s [I 200307 23:14:14 init:786] uiautomator back to normal

怎么办 你们怎么解决的 我是这个版本 一加手机

Hedilict commented 3 years ago

ATX 不稳定,经常重启uiautomator2,在执行任务中间也会重启。 [I 200307 23:14:05 init:132] uiautomator2 version: 2.5.7 [D 200307 23:14:06 init:766] restart-uiautomator since "UiAutomation not connected" [D 200307 23:14:06 init:822] Device: HUAWEI, THF6R19A21001267 [D 200307 23:14:06 init:828] stop app: com.github.uiautomator [D 200307 23:14:06 init:832] kill process(ps): uiautomator [D 200307 23:14:07 init:846] uiautomator-v2 is starting ... left: 40.0s [D 200307 23:14:08 init:846] uiautomator-v2 is starting ... left: 39.0s [D 200307 23:14:09 init:846] uiautomator-v2 is starting ... left: 37.9s [D 200307 23:14:10 init:846] uiautomator-v2 is starting ... left: 36.9s [D 200307 23:14:11 init:846] uiautomator-v2 is starting ... left: 35.9s [D 200307 23:14:12 init:846] uiautomator-v2 is starting ... left: 34.9s [D 200307 23:14:13 init:846] uiautomator-v2 is starting ... left: 33.8s [D 200307 23:14:14 init:846] uiautomator-v2 is starting ... left: 32.8s [I 200307 23:14:14 init:786] uiautomator back to normal

怎么办 你们怎么解决的 我是这个版本 一加手 遇到过,不过一般最后都会自己正常了。

Louis24 commented 3 years ago

不是会很久 等到1分多钟才重启 怎么修改源代码 不让他自动停止哦

Hedilict commented 3 years ago

不是会很久 等到1分多钟才重启 怎么修改源代码 不让他自动停止哦

这个我也不清楚。不过我遇到过这种情况都是被调试的APP暂时无响应造成的。

Mr-Learner commented 1 year ago

uiautomator2 version: 2.16.19 atx-agent version 0.10.0 测试中不断的在发滑动指令,还是会出现uiautomator2 中断,提到的3min是在哪里可以修改的

Mr-Learner commented 1 year ago

ATX 不稳定,经常重启uiautomator2,在执行任务中间也会重启。 [I 200307 23:14:05 init:132] uiautomator2 version: 2.5.7 [D 200307 23:14:06 init:766] restart-uiautomator since "UiAutomation not connected" [D 200307 23:14:06 init:822] Device: HUAWEI, THF6R19A21001267 [D 200307 23:14:06 init:828] stop app: com.github.uiautomator [D 200307 23:14:06 init:832] kill process(ps): uiautomator [D 200307 23:14:07 init:846] uiautomator-v2 is starting ... left: 40.0s [D 200307 23:14:08 init:846] uiautomator-v2 is starting ... left: 39.0s [D 200307 23:14:09 init:846] uiautomator-v2 is starting ... left: 37.9s [D 200307 23:14:10 init:846] uiautomator-v2 is starting ... left: 36.9s [D 200307 23:14:11 init:846] uiautomator-v2 is starting ... left: 35.9s [D 200307 23:14:12 init:846] uiautomator-v2 is starting ... left: 34.9s [D 200307 23:14:13 init:846] uiautomator-v2 is starting ... left: 33.8s [D 200307 23:14:14 init:846] uiautomator-v2 is starting ... left: 32.8s [I 200307 23:14:14 init:786] uiautomator back to normal

怎么办 你们怎么解决的 我是这个版本 一加手机

你的解决了没,我两台一个型号的手机,有台频繁遇到这个问题,另一概率小些 [I 221010 20:07:19 init:156] uiautomator2 version: 2.16.19 [D 221010 20:07:19 init:167] Shell: ('/data/local/tmp/atx-agent', 'server', '--stop') [I 221010 20:07:19 init:346] Install atx-agent 0.10.0 [D 221010 20:07:19 init:59] Use cached assets: D:\Users\80348829.uiautomator2\cache\atx-agent_0.10.0_linux_armv7.tar.gz-cf3333ae7b\atx-agent_0.10.0_linux_armv7.tar.gz [D 221010 20:07:19 init:238] Push to /data/local/tmp/atx-agent:0755 [D 221010 20:07:20 init:167] Shell: ('/data/local/tmp/atx-agent', 'server', '--nouia', '-d', '--addr', '127.0.0.1:7912') [I 221010 20:07:20 init:350] Check atx-agent version [D 221010 20:07:20 init:359] Forward: local:tcp:62367 -> remote:tcp:7912 [D 221010 20:07:20 init:359] Forward: local:tcp:62367 -> remote:tcp:7912 [D 221010 20:07:20 init:362] atx-agent version 0.10.0

alisleepy commented 1 year ago

过去两年多了,这个问题还存在,看了下issue,好多人都有这个问题,作者是不打算听从民意解决一下这个吗

VeerSun commented 1 year ago

ATX 不稳定,经常重启uiautomator2,在执行任务中间也会重启。 [I 200307 23:14:05 init:132] uiautomator2 version: 2.5.7 [D 200307 23:14:06 init:766] restart-uiautomator since "UiAutomation not connected" [D 200307 23:14:06 init:822] Device: HUAWEI, THF6R19A21001267 [D 200307 23:14:06 init:828] stop app: com.github.uiautomator [D 200307 23:14:06 init:832] kill process(ps): uiautomator [D 200307 23:14:07 init:846] uiautomator-v2 is starting ... left: 40.0s [D 200307 23:14:08 init:846] uiautomator-v2 is starting ... left: 39.0s [D 200307 23:14:09 init:846] uiautomator-v2 is starting ... left: 37.9s [D 200307 23:14:10 init:846] uiautomator-v2 is starting ... left: 36.9s [D 200307 23:14:11 init:846] uiautomator-v2 is starting ... left: 35.9s [D 200307 23:14:12 init:846] uiautomator-v2 is starting ... left: 34.9s [D 200307 23:14:13 init:846] uiautomator-v2 is starting ... left: 33.8s [D 200307 23:14:14 init:846] uiautomator-v2 is starting ... left: 32.8s [I 200307 23:14:14 init:786] uiautomator back to normal

怎么办 你们怎么解决的 我是这个版本 一加手机

你的解决了没,我两台一个型号的手机,有台频繁遇到这个问题,另一概率小些 [I 221010 20:07:19 init:156] uiautomator2 version: 2.16.19 [D 221010 20:07:19 init:167] Shell: ('/data/local/tmp/atx-agent', 'server', '--stop') [I 221010 20:07:19 init:346] Install atx-agent 0.10.0 [D 221010 20:07:19 init:59] Use cached assets: D:\Users\80348829.uiautomator2\cache\atx-agent_0.10.0_linux_armv7.tar.gz-cf3333ae7b\atx-agent_0.10.0_linux_armv7.tar.gz [D 221010 20:07:19 init:238] Push to /data/local/tmp/atx-agent:0755 [D 221010 20:07:20 init:167] Shell: ('/data/local/tmp/atx-agent', 'server', '--nouia', '-d', '--addr', '127.0.0.1:7912') [I 221010 20:07:20 init:350] Check atx-agent version [D 221010 20:07:20 init:359] Forward: local:tcp:62367 -> remote:tcp:7912 [D 221010 20:07:20 init:359] Forward: local:tcp:62367 -> remote:tcp:7912 [D 221010 20:07:20 init:362] atx-agent version 0.10.0

这应该是手机厂商的“智能后台”功能捣的鬼,才会有你这样的现象,两台概率不一样,而且ATX用得越多,概率越低。 可以尝试到手机设置里找到“耗电优化”、“后台高耗电”、“智能后台”等类似的功能,把这ATX和com.github.uiautomator.test这两个应用都设置为始终允许后台运行,应该就能解决。

Ffmydy commented 5 months ago

2024年了,还有这个问题

zhaoxiaona001 commented 5 months ago

报错信息看看

---原始邮件--- 发件人: @.> 发送时间: 2024年2月21日(周三) 上午10:00 收件人: @.>; 抄送: @.**@.>; 主题: Re: [openatx/uiautomator2] ATX里面的uiautomator2服务过了几分钟就会自动断开 (#516)

2024年了,还有这个问题

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

Louis24 commented 5 months ago

现在正常了 不过我用的不多 每次10分钟

Ffmydy commented 5 months ago

[D 240222 11:13:17 init:661] [pid:11476] [EMP75THUJ7HQHQAQ] kill process(ps): uiautomator [D 240222 11:13:18 init:682] [pid:11476] [EMP75THUJ7HQHQAQ] uiautomator-v2 is starting ... left: 40.0s [D 240222 11:13:19 init:682] [pid:11476] [EMP75THUJ7HQHQAQ] uiautomator-v2 is starting ... left: 39.0s [D 240222 11:13:19 init:696] [pid:11476] [EMP75THUJ7HQHQAQ] show float window [D 240222 11:13:20 init:682] [pid:11476] [EMP75THUJ7HQHQAQ] uiautomator-v2 is starting ... left: 37.8s [I 240222 11:13:20 init:643] [pid:11476] [EMP75THUJ7HQHQAQ] uiautomator back to normal [D 240222 11:14:12 init:661] [pid:11476] [EMP75THUJ7HQHQAQ] kill process(ps): uiautomator [D 240222 11:14:12 init:682] [pid:11476] [EMP75THUJ7HQHQAQ] uiautomator-v2 is starting ... left: 40.0s [D 240222 11:14:14 init:682] [pid:11476] [EMP75THUJ7HQHQAQ] uiautomator-v2 is starting ... left: 39.0s [D 240222 11:14:14 init:696] [pid:11476] [EMP75THUJ7HQHQAQ] show float window [D 240222 11:14:15 init:682] [pid:11476] [EMP75THUJ7HQHQAQ] uiautomator-v2 is starting ... left: 37.8s [I 240222 11:14:15 init:643] [pid:11476] [EMP75THUJ7HQHQAQ] uiautomator back to normal @zhaoxiaona001

zhaoxiaona001 commented 5 months ago

换个数据线试试,你怎么会有我的邮箱呢

---原始邮件--- 发件人: @.> 发送时间: 2024年2月22日(周四) 中午11:21 收件人: @.>; 抄送: @.**@.>; 主题: Re: [openatx/uiautomator2] ATX里面的uiautomator2服务过了几分钟就会自动断开 (#516)

[D 240222 11:13:17 init:661] [pid:11476] [EMP75THUJ7HQHQAQ] kill process(ps): uiautomator [D 240222 11:13:18 init:682] [pid:11476] [EMP75THUJ7HQHQAQ] uiautomator-v2 is starting ... left: 40.0s [D 240222 11:13:19 init:682] [pid:11476] [EMP75THUJ7HQHQAQ] uiautomator-v2 is starting ... left: 39.0s [D 240222 11:13:19 init:696] [pid:11476] [EMP75THUJ7HQHQAQ] show float window [D 240222 11:13:20 init:682] [pid:11476] [EMP75THUJ7HQHQAQ] uiautomator-v2 is starting ... left: 37.8s [I 240222 11:13:20 init:643] [pid:11476] [EMP75THUJ7HQHQAQ] uiautomator back to normal [D 240222 11:14:12 init:661] [pid:11476] [EMP75THUJ7HQHQAQ] kill process(ps): uiautomator [D 240222 11:14:12 init:682] [pid:11476] [EMP75THUJ7HQHQAQ] uiautomator-v2 is starting ... left: 40.0s [D 240222 11:14:14 init:682] [pid:11476] [EMP75THUJ7HQHQAQ] uiautomator-v2 is starting ... left: 39.0s [D 240222 11:14:14 init:696] [pid:11476] [EMP75THUJ7HQHQAQ] show float window [D 240222 11:14:15 init:682] [pid:11476] [EMP75THUJ7HQHQAQ] uiautomator-v2 is starting ... left: 37.8s [I 240222 11:14:15 init:643] [pid:11476] [EMP75THUJ7HQHQAQ] uiautomator back to normal @zhaoxiaona001

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

codeskyblue commented 3 months ago

@Louis24 你把ATX的悬浮窗权限打开,就能运行很久很久