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

运行时偶现 panic #28

Open
chenhengjie123 opened this issue May 23, 2022 · 7 comments
Open

运行时偶现 panic #28

chenhengjie123 opened this issue May 23, 2022 · 7 comments

Comments

@chenhengjie123
Copy link

运行命令

./gidevice xctest com.facebook.WebDriverAgentRunner.xctrunner -u xxxx --env=USE_PORT=8100 --env=MJPEG_SERVER_PORT=9100

执行一段时间后,运行基于 appium 的 UI 自动化脚本时,出现如下报错然后自动退出:

 t =  3505.76s     Requesting snapshot of accessibility hierarchy for app with pid 566
    t =  3506.16s     Find: Descendants matching type Any
    t =  3506.17s     Find: Elements matching predicate '(wdType == "XCUIElementTypeTextField" AND wdValue == "请输入手机号") 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)'
panic: runtime error: slice bounds out of range [:209106] with capacity 132768

goroutine 8 [running]:
github.com/electricbubble/gidevice/pkg/libimobiledevice.(*dtxMessageClient).ReceiveDTXMessage(0xc00038b1a0, 0xc000096000, 0x0, 0x0)
	/home/runner/go/pkg/mod/github.com/electricbubble/[email protected]/pkg/libimobiledevice/client_dtxmessage.go:180 +0x1265
github.com/electricbubble/gidevice/pkg/libimobiledevice.(*dtxMessageClient).startReceive.func1(0xc00038b1a0)
	/home/runner/go/pkg/mod/github.com/electricbubble/[email protected]/pkg/libimobiledevice/client_dtxmessage.go:326 +0x5e
created by github.com/electricbubble/gidevice/pkg/libimobiledevice.(*dtxMessageClient).startReceive
	/home/runner/go/pkg/mod/github.com/electricbubble/[email protected]/pkg/libimobiledevice/client_dtxmessage.go:320 +0x3f

目前为偶现,暂时未找到稳定复现步骤。

@electricbubble
Copy link
Owner

偶现这个问题时,是否都恰好在 app 元素较多的页面?

@ZhouYixun
Copy link
Contributor

有没有试过调整ios获取控件层数约束一下

@chenhengjie123
Copy link
Author

chenhengjie123 commented May 24, 2022

偶现这个问题时,是否都恰好在 app 元素较多的页面?

查看了一下当时的日志,出现这个问题时,手机是在登录页面。完整控件树如下:

<?xml version="1.0" encoding="UTF-8"?>
<AppiumAUT>
  <XCUIElementTypeApplication type="XCUIElementTypeApplication" name="Funbox" label="Funbox" enabled="true" visible="true" accessible="false" x="0" y="0" width="414" height="736" index="0">
    <XCUIElementTypeWindow type="XCUIElementTypeWindow" enabled="true" visible="true" accessible="false" x="0" y="0" width="414" height="736" index="0">
      <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="false" accessible="false" x="0" y="0" width="414" height="736" index="0">
        <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="false" accessible="false" x="0" y="0" width="414" height="736" index="0"/>
      </XCUIElementTypeOther>
      <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="true" accessible="false" x="0" y="0" width="414" height="736" index="1">
        <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="true" accessible="false" x="0" y="0" width="414" height="736" index="0">
          <XCUIElementTypeNavigationBar type="XCUIElementTypeNavigationBar" name="AIPWPhoneLogin" enabled="true" visible="true" accessible="false" x="0" y="20" width="414" height="44" index="0">
            <XCUIElementTypeButton type="XCUIElementTypeButton" name="" label="" enabled="true" visible="true" accessible="true" x="10" y="20" width="32" height="44" index="0"/>
          </XCUIElementTypeNavigationBar>
          <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="true" accessible="false" x="0" y="0" width="414" height="736" index="1">
            <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="true" accessible="false" x="0" y="0" width="414" height="736" index="0">
              <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="true" accessible="false" x="0" y="0" width="414" height="736" index="0">
                <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="手机号注册/登录" name="手机号注册/登录" label="手机号注册/登录" enabled="true" visible="true" accessible="true" x="32" y="112" width="180" height="34" index="0"/>
                <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="true" accessible="false" x="32" y="169" width="350" height="57" index="1">
                  <XCUIElementTypeOther type="XCUIElementTypeOther" name="+86" label="+86" enabled="true" visible="true" accessible="false" x="32" y="173" width="78" height="49" index="0">
                    <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" visible="false" accessible="false" x="32" y="189" width="24" height="17" index="0"/>
                    <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="+86" name="+86" label="+86" enabled="true" visible="true" accessible="true" x="62" y="189" width="32" height="17" index="1"/>
                    <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" visible="false" accessible="false" x="101" y="193" width="9" height="9" index="2"/>
                  </XCUIElementTypeOther>
                  <XCUIElementTypeTextField type="XCUIElementTypeTextField" value="请输入手机号" label="" enabled="true" visible="true" accessible="true" x="125" y="173" width="209" height="49" index="1"/>
                  <XCUIElementTypeButton type="XCUIElementTypeButton" name="login clean" label="login clean" enabled="true" visible="true" accessible="true" x="350" y="181" width="32" height="33" index="2"/>
                  <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="true" accessible="false" x="32" y="225" width="350" height="1" index="3"/>
                </XCUIElementTypeOther>
                <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="true" accessible="false" x="32" y="285" width="350" height="51" index="2">
                  <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="true" accessible="false" x="157" y="302" width="100" height="18" index="0">
                    <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="true" accessible="false" x="157" y="302" width="100" height="18" index="0">
                      <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="发送短信验证码" name="发送短信验证码" label="发送短信验证码" enabled="true" visible="true" accessible="true" x="157" y="302" width="100" height="18" index="0"/>
                    </XCUIElementTypeOther>
                  </XCUIElementTypeOther>
                </XCUIElementTypeOther>
              </XCUIElementTypeOther>
            </XCUIElementTypeOther>
          </XCUIElementTypeOther>
        </XCUIElementTypeOther>
      </XCUIElementTypeOther>
    </XCUIElementTypeWindow>
    <XCUIElementTypeWindow type="XCUIElementTypeWindow" enabled="true" visible="false" accessible="false" x="0" y="0" width="414" height="736" index="1">
      <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="false" accessible="false" x="0" y="0" width="414" height="736" index="0">
        <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="false" accessible="false" x="0" y="0" width="414" height="736" index="0"/>
        <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="false" accessible="false" x="0" y="510" width="414" height="226" index="1">
          <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="false" accessible="false" x="0" y="510" width="414" height="226" index="0"/>
        </XCUIElementTypeOther>
      </XCUIElementTypeOther>
    </XCUIElementTypeWindow>
    <XCUIElementTypeWindow type="XCUIElementTypeWindow" enabled="true" visible="true" accessible="false" x="0" y="0" width="414" height="736" index="2">
      <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="true" accessible="false" x="0" y="0" width="414" height="736" index="0">
        <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="true" accessible="false" x="0" y="510" width="414" height="226" index="0">
          <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="false" accessible="false" x="0" y="510" width="414" height="226" index="0">
            <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="false" accessible="false" x="0" y="510" width="414" height="226" index="0">
              <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="false" accessible="false" x="0" y="510" width="414" height="226" index="0">
                <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="false" accessible="false" x="0" y="510" width="414" height="226" index="0"/>
                <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="false" accessible="false" x="0" y="510" width="414" height="226" index="1"/>
              </XCUIElementTypeOther>
            </XCUIElementTypeOther>
          </XCUIElementTypeOther>
          <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="true" accessible="false" x="0" y="510" width="414" height="226" index="1">
            <XCUIElementTypeKeyboard type="XCUIElementTypeKeyboard" enabled="true" visible="true" accessible="false" x="0" y="510" width="414" height="226" index="0">
              <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="true" accessible="false" x="0" y="510" width="414" height="226" index="0">
                <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" visible="true" accessible="false" x="0" y="510" width="414" height="226" index="0">
                  <XCUIElementTypeKey type="XCUIElementTypeKey" name="1" label="1" enabled="true" visible="true" accessible="true" x="0" y="510" width="137" height="57" index="0"/>
                  <XCUIElementTypeKey type="XCUIElementTypeKey" name="2" label="2" enabled="true" visible="true" accessible="true" x="136" y="510" width="142" height="57" index="1"/>
                  <XCUIElementTypeKey type="XCUIElementTypeKey" name="3" label="3" enabled="true" visible="true" accessible="true" x="277" y="510" width="137" height="57" index="2"/>
                  <XCUIElementTypeKey type="XCUIElementTypeKey" name="4" label="4" enabled="true" visible="true" accessible="true" x="0" y="567" width="137" height="56" index="3"/>
                  <XCUIElementTypeKey type="XCUIElementTypeKey" name="5" label="5" enabled="true" visible="true" accessible="true" x="136" y="567" width="142" height="56" index="4"/>
                  <XCUIElementTypeKey type="XCUIElementTypeKey" name="6" label="6" enabled="true" visible="true" accessible="true" x="277" y="567" width="137" height="56" index="5"/>
                  <XCUIElementTypeKey type="XCUIElementTypeKey" name="7" label="7" enabled="true" visible="true" accessible="true" x="0" y="623" width="137" height="56" index="6"/>
                  <XCUIElementTypeKey type="XCUIElementTypeKey" name="8" label="8" enabled="true" visible="true" accessible="true" x="136" y="623" width="142" height="56" index="7"/>
                  <XCUIElementTypeKey type="XCUIElementTypeKey" name="9" label="9" enabled="true" visible="true" accessible="true" x="277" y="623" width="137" height="56" index="8"/>
                  <XCUIElementTypeKey type="XCUIElementTypeKey" name="International" label="International" enabled="true" visible="true" accessible="true" x="0" y="679" width="70" height="57" index="9"/>
                  <XCUIElementTypeKey type="XCUIElementTypeKey" name="Shift" label="Shift" enabled="true" visible="true" accessible="true" x="67" y="679" width="70" height="57" index="10"/>
                  <XCUIElementTypeKey type="XCUIElementTypeKey" name="0" label="0" enabled="true" visible="true" accessible="true" x="136" y="679" width="142" height="57" index="11"/>
                  <XCUIElementTypeKey type="XCUIElementTypeKey" name="删除" label="删除" enabled="true" visible="true" accessible="true" x="277" y="679" width="137" height="57" index="12"/>
                </XCUIElementTypeOther>
              </XCUIElementTypeOther>
            </XCUIElementTypeKeyboard>
          </XCUIElementTypeOther>
        </XCUIElementTypeOther>
      </XCUIElementTypeOther>
    </XCUIElementTypeWindow>
  </XCUIElementTypeApplication>
</AppiumAUT>

不知道这个算不算多,但目前并不是必现的,大部分情况下在这个界面是可以正常输入手机号什么的。不过没太理解,这个 panic 是因为控件多引起的吗?

@electricbubble
Copy link
Owner

不是这原因,只是因为看提供的日志,恰好停留在匹配元素的输出后面,

结合报错信息,猜测可能是响应过大,同时赶上未知的原因导致接收的数据不完整,

所以只是猜测,问这个只是为了判断是否可能存在这种可能。


原因暂无思路定位,但这个 panic 可以避免掉,

晚些时候我做一些调整,这种情况数据不完整的情况可能还是会出现

@chenhengjie123
Copy link
Author

这个不好约束,毕竟项目控件深度这个目前没有严格规范限制。我现在用的是 wda 的默认值(印象中是50)。而且这个问题并不是必现,一样的脚本这个问题只是偶现,所以因为这个问题调整 wda 的控件深度,有点不大合适。

@electricbubble
Copy link
Owner

⚠️只是现状无法定位的猜测

electricbubble added a commit that referenced this issue May 29, 2022
@electricbubble
Copy link
Owner

已尝试避免 panic v0.5.2,有空再试一试

electricbubble/gidevice-cli v0.8.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants