alibaba / alibaba/tidevice

调用set_text方法时候,wda经常莫名quited

Open
#73 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
2.6k
Forks
469
PR merge metrics
No merged PRs in 30d

Description

# 现象

用tidevice起wda,在【直播底层页 - 多次发评论时候】wda服务经常会莫名quited,场景如下
![image](https://user-images.githubusercontent.com/53210634/115136305-9060f300-a051-11eb-994b-35173d0b972e.png)

尝试按照如下放开`socket closed`之前的错误信息,得到的堆栈如下:
![image](https://user-images.githubusercontent.com/53210634/115136192-d6698700-a050-11eb-996a-8ce8ee69490f.png)
```bash
[D 210418 13:53:06 _instruments:592] DTXMessage: expects_reply:1 flags:2 ('_XCT_logDebugMessage:', ["13:53:06.438 WebDriverAgentRunner-Runner[22962:4152260] Found matches {(\n TextView, {{28.0, 479.0}, {358.0, 42.0}}, identifier: 'TBUIAutoTest_Property_inputCommentView', Keyboard Focused\n)} with root Application, pid: 22977, label: '央视频'\n"])
[D 210418 13:53:06 _instruments:592] DTXMessage: expects_reply:1 flags:2 ('_XCT_logDebugMessage:', ['13:53:06.438 WebDriverAgentRunner-Runner[22962:4152260] finished activity 2021-04-18 05:53:05 +0000: Find the "TBUIAutoTest_Property_inputCommentView" TextView (0.444249s)\n'])
[D 210418 13:53:06 _instruments:592] DTXMessage: expects_reply:1 flags:2 ('_XCT_testCase:method:didFinishActivity:', ['none', 'none', XCActivityRecord(activityType=com.apple.dt.xctest.activity-type.internal, attachments=[], finish=2021-04-18 05:53:06.438379, start=2021-04-18 05:53:05.994130, title=Find the "TBUIAutoTest_Property_inputCommentView" TextView, uuid=300bb54b-6f71-4759-982a-25d918f23ab3)])
[D 210418 13:53:06 _instruments:611] server request not handled: ('_XCT_testCase:method:didFinishActivity:', ['none', 'none', XCActivityRecord(activityType=com.apple.dt.xctest.activity-type.internal, attachments=[], finish=2021-04-18 05:53:06.438379, start=2021-04-18 05:53:05.994130, title=Find the "TBUIAutoTest_Property_inputCommentView" TextView, uuid=300bb54b-6f71-4759-982a-25d918f23ab3)])
[D 210418 13:53:06 _instruments:592] DTXMessage: expects_reply:1 flags:2 ('_XCT_logDebugMessage:', ['13:53:06.440 WebDriverAgentRunner-Runner[22962:4152260] started activity 2021-04-18 05:53:06 +0000: Find the "TBUIAutoTest_Property_inputCommentView" TextView\n'])
[D 210418 13:53:06 _instruments:592] DTXMessage: expects_reply:1 flags:2 ('_XCT_testCase:method:willStartActivity:', ['none', 'none', XCActivityRecord(activityType=com.apple.dt.xctest.activity-type.internal, attachments=[], finish=None, start=2021-04-18 05:53:06.439494, title=Find the "TBUIAutoTest_Property_inputCommentView" TextView, uuid=cb87d56f-9731-4046-b519-0b8000a11d00)])
[D 210418 13:53:06 _instruments:611] server request not handled: ('_XCT_testCase:method:willStartActivity:', ['none', 'none', XCActivityRecord(activityType=com.apple.dt.xctest.activity-type.internal, attachments=[], finish=None, start=2021-04-18 05:53:06.439494, title=Find the "TBUIAutoTest_Property_inputCommentView" TextView, uuid=cb87d56f-9731-4046-b519-0b8000a11d00)])
[D 210418 13:53:06 _instruments:592] DTXMessage: expects_reply:1 flags:2 ('_XCT_logDebugMessage:', ['13:53:06.440 WebDriverAgentRunner-Runner[22962:4152260] Executing query:\n↪︎ Descendants matching type Any\n ↪︎ Elements matching predicate \'wdName == "TBUIAutoTest_Property_inputCommentView" AND (1 == 1 OR identifier == 0 OR frame == 0 OR value == 0 OR title == 0 OR label == 0 OR elementType == 0 OR enabled == 0 OR placeholderValue == 0 OR selected == 0)\'\n ↪︎ Identity Binding\n'])
[D 210418 13:53:06 _instruments:592] DTXMessage: expects_reply:1 flags:2 ('_XCT_logDebugMessage:', ['13:53:06.440 WebDriverAgentRunner-Runner[22962:4152260] Should evaluate query remotely? XCTDisableRemoteQueryEvaluation(d-write): YES, hasAutomationSession: NO, supportsRemoteEvaluation: YES\n'])
[D 210418 13:53:06 _instruments:592] DTXMessage: expects_reply:1 flags:2 ('_XCT_logDebugMessage:', ['13:53:06.440 WebDriverAgentRunner-Runner[22962:4152260] Getting matching snapshots for locally evaluated query\n'])
[D 210418 13:53:06 _instruments:592] DTXMessage: expects_reply:1 flags:2 ('_XCT_logDebugMessage:', ['13:53:06.440 WebDriverAgentRunner-Runner[22962:4152260] Evaluating query:\n ↪︎ Descendants matching type Any\n ↪︎ Elements matching predicate \'wdName == "TBUIAutoTest_Property_inputCommentView" AND (1 == 1 OR identifier == 0 OR frame == 0 OR value == 0 OR title == 0 OR label == 0 OR elementType == 0 OR enabled == 0 OR placeholderValue == 0 OR selected == 0)\'\n ↪︎ Identity Binding\n'])
[D 210418 13:53:06 _instruments:592] DTXMessage: expects_reply:1 flags:2 ('_XCT_logDebugMessage:', ['13:53:06.440 WebDriverAgentRunner-Runner[22962:4152260] Getting root element snapshot\n'])
[D 210418 13:53:06 _instruments:592] DTXMessage: expects_reply:1 flags:2 ('_XCT_logDebugMessage:', ['13:53:06.440 WebDriverAgentRunner-Runner[22962:4152260] Getting snapshot for App element pid: 22977 for query ↪︎ Descendants matching type Any\n ↪︎ Elements matching predicate \'wdName == "TBUIAutoTest_Property_inputCommentView" AND (1 == 1 OR identifier == 0 OR frame == 0 OR value == 0 OR title == 0 OR label == 0 OR elementType == 0 OR enabled == 0 OR placeholderValue == 0 OR selected == 0)\'\n ↪︎ Identity Binding\n'])
[D 210418 13:53:06 _instruments:592] DTXMessage: expects_reply:1 flags:2 ('_XCT_testCase:method:willStartActivity:', ['none', 'none', XCActivityRecord(activityType=com.apple.dt.xctest.activity-type.internal, attachments=[], finish=None, start=2021-04-18 05:53:06.440209, title=Requesting snapshot of accessibility hierarchy for app with pid 22977, uuid=a444ddfe-1350-4f1e-b888-720683a3d867)])
[D 210418 13:53:06 _instruments:611] server request not handled: ('_XCT_testCase:method:willStartActivity:', ['none', 'none', XCActivityRecord(activityType=com.apple.dt.xctest.activity-type.internal, attachments=[], finish=None, start=2021-04-18 05:53:06.440209, title=Requesting snapshot of accessibility hierarchy for app with pid 22977, uuid=a444ddfe-1350-4f1e-b888-720683a3d867)])
[D 210418 13:53:06 _instruments:592] DTXMessage: expects_reply:1 flags:2 ('_XCT_logDebugMessage:', ['13:53:06.440 WebDriverAgentRunner-Runner[22962:4152260] started activity 2021-04-18 05:53:06 +0000: Requesting snapshot of accessibility hierarchy for app with pid 22977\n'])
[D 210418 13:53:06 _instruments:592] DTXMessage: expects_reply:1 flags:2 ('_XCT_logDebugMessage:', ['13:53:06.440 WebDriverAgentRunner-Runner[22962:4152260] Query requires iOS snapshot attributes XC_kAXXCAttributeElementBaseType, XC_kAXXCAttributeFrame, XC_kAXXCAttributeElementType, XC_kAXXCAttributeIdentifier, XC_kAXXCAttributeValue, XC_kAXXCAttributeLabel, XC_kAXXCAttributeTraits, XC_kAXXCAttributePlaceholderValue.\n'])
[D 210418 13:53:06 _instruments:592] DTXMessage: expects_reply:1 flags:2 ('_XCT_logDebugMessage:', ['13:53:06.440 WebDriverAgentRunner-Runner[22962:4152260] XCUIElementQuery getting snapshot\n'])
[D 210418 13:53:06 _instruments:592] DTXMessage: expects_reply:1 flags:2 ('_XCT_logDebugMessage:', ['13:53:06.440 WebDriverAgentRunner-Runner[22962:4152260] Snapshot request has custom attributes XC_kAXXCAttributeElementBaseType, XC_kAXXCAttributeFrame, XC_kAXXCAttributeElementType, XC_kAXXCAttributeIdentifier, XC_kAXXCAttributeValue, XC_kAXXCAttributeLabel, XC_kAXXCAttributeTraits, XC_kAXXCAttributePlaceholderValue\n'])
[D 210418 13:53:06 _instruments:592] DTXMessage: expects_reply:1 flags:2 ('_XCT_logDebugMessage:', ['13:53:06.440 WebDriverAgentRunner-Runner[22962:4152260] Current snapshot generation is 3109\n'])
[D 210418 13:53:06 _instruments:592] DTXMessage: expects_reply:1 flags:2 ('_XCT_logDebugMessage:', ['13:53:06.441 WebDriverAgentRunner-Runner[22962:4152260] Query rootElementSnapshot is non-null with generation count 3109\n'])
[D 210418 13:53:06 _instruments:592] DTXMessage: expects_reply:1 flags:2 ('_XCT_logDebugMessage:', ['13:53:06.441 WebDriverAgentRunner-Runner[22962:4152260] Capturing a new snapshot\n'])
[D 210418 13:53:06 _instruments:592] DTXMessage: expects_reply:1 flags:2 ('_XCT_logDebugMessage:', ['13:53:06.441 WebDriverAgentRunner-Runner[22962:4152260] Fetching snapshot for App element pid: 22977 from testmanagerd with attributes XC_kAXXCAttributeElementBaseType, XC_kAXXCAttributeFrame, XC_kAXXCAttributeElementType, XC_kAXXCAttributeIdentifier, XC_kAXXCAttributeLabel, XC_kAXXCAttributeTraits, XC_kAXXCAttributeTruncatedValue, XC_kAXXCAttributeParent, XC_kAXXCAttributePlaceholderValue and parameters {\n maxArrayCount = 2147483647;\n maxChildren = 2147483647;\n maxDepth = 50;\n traverseFromParentsToChildren = 1;\n}.\n'])
[D 210418 13:53:06 _instruments:592] DTXMessage: expects_reply:1 flags:2 ('_XCT_logDebugMessage:', ["13:53:06.441 WebDriverAgentRunner-Runner[22962:4152260] Creating future for 'fetching snapshot from testmanagerd.' with timeout 65.00\n"])
[D 210418 13:53:06 _instruments:592] DTXMessage: expects_reply:1 flags:2 ('_XCT_logDebugMessage:', ['13:53:06.441 WebDriverAgentRunner-Runner[22962:4152260] entering wait loop for 65.00s with expectations: `fetching snapshot from testmanagerd.`\n'])
[D 210418 13:53:06 _instruments:592] DTXMessage: expects_reply:1 flags:2 ('_XCT_logDebugMessage:', ['13:53:06.874 WebDriverAgentRunner-Runner[22962:4155376] Got snapshot response from testmanagerd.\n'])
[D 210418 13:53:06 _instruments:592] DTXMessage: expects_reply:0 flags:2 ('outputReceived:fromProcess:atTime:', [' t = 521.06s Find: Descendants matching type Any\n', 22962, 26508288801741])
[D 210418 13:53:06 _device:944] logProcess: t = 521.06s Find: Descendants matching type Any
[D 210418 13:53:06 _instruments:592] DTXMessage: expects_reply:1 flags:2 ('_XCT_testCase:method:didFinishActivity:', ['none', 'none', XCActivityRecord(activityType=com.apple.dt.xctest.activity-type.internal, attachments=[], finish=2021-04-18 05:53:06.874365, start=2021-04-18 05:53:06.440209, title=Requesting snapshot of accessibility hierarchy for app with pid 22977, uuid=a444ddfe-1350-4f1e-b888-720683a3d867)])
[D 210418 13:53:06 _instruments:611] server request not handled: ('_XCT_testCase:method:didFinishActivity:', ['none', 'none', XCActivityRecord(activityType=com.apple.dt.xctest.activity-type.internal, attachments=[], finish=2021-04-18 05:53:06.874365, start=2021-04-18 05:53:06.440209, title=Requesting snapshot of accessibility hierarchy for app with pid 22977, uuid=a444ddfe-1350-4f1e-b888-720683a3d867)])
[D 210418 13:53:06 _instruments:592] DTXMessage: expects_reply:1 flags:2 ('_XCT_logDebugMessage:', ['13:53:06.874 WebDriverAgentRunner-Runner[22962:4152260] finished activity 2021-04-18 05:53:06 +0000: Requesting snapshot of accessibility hierarchy for app with pid 22977 (0.434156s)\n'])
[D 210418 13:53:06 _instruments:592] DTXMessage: expects_reply:1 flags:2 ('_XCT_testCase:method:willStartActivity:', ['none', 'none', XCActivityRecord(activityType=com.apple.dt.xctest.activity-type.internal, attachments=[], finish=None, start=2021-04-18 05:53:06.874707, title=Find: Descendants matching type Any, uuid=9a86c443-0b37-4446-ad44-04ef52b19ba1)])
[D 210418 13:53:06 _instruments:611] server request not handled: ('_XCT_testCase:method:willStartActivity:', ['none', 'none', XCActivityRecord(activityType=com.apple.dt.xctest.activity-type.internal, attachments=[], finish=None, start=2021-04-18 05:53:06.874707, title=Find: Descendants matching type Any, uuid=9a86c443-0b37-4446-ad44-04ef52b19ba1)])
[D 210418 13:53:06 _instruments:592] DTXMessage: expects_reply:1 flags:2 ('_XCT_logDebugMessage:', ['13:53:06.875 WebDriverAgentRunner-Runner[22962:4152260] XCTPerformOnMainRunLoop[MT]: already on MT; performing block without run loop dispatch - timeouts will not be enforced.\n'])
[D 210418 13:53:06 _instruments:592] DTXMessage: expects_reply:1 flags:2 ('_XCT_logDebugMessage:', ['13:53:06.875 WebDriverAgentRunner-Runner[22962:4152260] XCTElementQuery: set data source for rootElementSnapshot to (null)\n'])
[D 210418 13:53:06 _instruments:592] DTXMessage: expects_reply:1 flags:2 ('_XCT_logDebugMessage:', ['13:53:06.875 WebDriverAgentRunner-Runner[22962:4152260] Finding all matches with input Application, pid: 22977, label: \'央视频\' using transformers \n↪︎ Descendants matching type Any\n ↪︎ Eents matching predicate \'wdName == "TBUIAutoTest_Property_inputCommentView" AND (1 == 1 OR identifier == 0 OR frame == 0 OR value == 0 OR title == 0 OR label == 0 OR elementType == 0 OR enabled == 0 OR placeholderValue == 0 OR selected == 0)\'\n ↪︎ Identity Binding\n'])
[D 210418 13:53:06 _instruments:592] DTXMessage: expects_reply:1 flags:2 ('_XCT_logDebugMessage:', ['13:53:06.875 WebDriverAgentRunner-Runner[22962:4152260] started activity 2021-04-18 05:53:06 +0000: Find: Descendants matching type Any\n'])
[D 210418 13:53:06 _instruments:592] DTXMessage: expects_reply:0 flags:2 ('outputReceived:fromProcess:atTime:', [' t = 521.07s Find: Elements matching predicate \'wdName == "TBUIAutoTest_Property_inputCommentView" AND (1 == 1 OR identifier == 0 OR frame == 0 OR value == 0 OR title == 0 OR label == 0 OR elementType == 0 OR enabled == 0 OR placeholderValue == 0 OR selected == 0)\'\n', 22962, 26508288921858])
[D 210418 13:53:06 _device:944] logProcess: t = 521.07s Find: Elements matching predicate 'wdName == "TBUIAutoTest_Property_inputCommentView" AND (1 == 1 OR identifier == 0 OR frame == 0 OR value == 0 OR title == 0 OR label == 0 OR elementType == 0 OR enabled == 0 OR placeholderValue == 0 OR selected == 0)'
[D 210418 13:53:06 _instruments:592] DTXMessage: expects_reply:1 flags:2 ('_XCT_logDebugMessage:', ['13:53:06.876 WebDriverAgentRunner-Runner[22962:4152260] finished activity 2021-04-18 05:53:06 +0000: Find: Descendants matching type Any (0.00103307s)\n'])
[D 210418 13:53:06 _instruments:592] DTXMessage: expects_reply:1 flags:2 ('_XCT_testCase:method:didFinishActivity:', ['none', 'none', XCActivityRecord(activityType=com.apple.dt.xctest.activity-type.internal, attachments=[], finish=2021-04-18 05:53:06.875740, start=2021-04-18 05:53:06.874707, title=Find: Descendants matching type Any, uuid=9a86c443-0b37-4446-ad44-04ef52b19ba1)])
[D 210418 13:53:06 _instruments:611] server request not handled: ('_XCT_testCase:method:didFinishActivity:', ['none', 'none', XCActivityRecord(activityType=com.apple.dt.xctest.activity-type.internal, attachments=[], finish=2021-04-18 05:53:06.875740, start=2021-04-18 05:53:06.874707, title=Find: Descendants matching type Any, uuid=9a86c443-0b37-4446-ad44-04ef52b19ba1)])
[W 210418 13:53:06 _instruments:560] unexpected error: read expect length: 0x22E64, got: 0x10526
[W 210418 13:53:06 _instruments:567] unexpected error 2: 'NoneType' object has no attribute 'conversation_index'
[D 210418 13:53:06 _instruments:570] dtxm socket closed
[I 210418 13:53:06 _device:1119] xctrunner quited
```
# 补充

调试代码如下:
```py
import wda

if __name__ == '__main__':

c = wda.USBClient()
c.session('com.cctv.yangshipin.app.iphone')
ipt = input('wait for ready ...')
if ipt:
n = 1
while n < 50:
# 用className定位,几乎不quited
# c(className='XCUIElementTypeTextView').set_text('👏👏👏🌺🌺🍃%s' % n)
# 用name定位,经常quited
# p.s. TBUIAutoTest: http://yulingtianxia.com/blog/2016/03/28/Add-UITest-Label-for-UIAutomation/
c(name='TBUIAutoTest_Property_inputCommentView').set_text('👏👏👏🌺🌺🍃%s' % n)
n += 1
```
p.s. 评论框原始name属性为空,通过[TBUIAutoTest](http://yulingtianxia.com/blog/2016/03/28/Add-UITest-Label-for-UIAutomation)插桩添加的属性

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing repeated set_text calls during the live-comment scenario with tidevice and WebDriverAgent, then inspect the socket-closed log around the accessibility snapshot request shown in the issue. Done means the WDA service remains running during repeated comment entry and the failure can no longer be reproduced.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, python
Domain
mobile-dev, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.