游戏测试问题之:Caused by: java.lang.Error: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000004

公司开发的小游戏在进行 Monkey 测试时在个别机型一直遇到相同的几个问题,特此记录一下

错误日志如下:

Caused by: java.lang.Error: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000004
Build fingerprint: 'xxxxx 测试信息'
Revision: '0'
pid: 21666, tid: 21847, name: UnityMain  >>> xxx 游戏包名 <<<
    r0 980ae958  r1 00000004  r2 00430000  r3 b11dc6dd
    r4 980ae958  r5 980ae958  r6 ffffffff  r7 980afe78
    r8 00000000  r9 a4b2ce00  sl 00000001  fp 980ae948
    ip 002e3688  sp 980ae938  lr 9738a941  pc 978460f8  cpsr 86371100

	at libunity.006ee0f8(Native Method)
	at libunity.0023293d(Native Method)
	at Unknown.fffffffd(Unknown Source:0)

我们使用的是 Unity 2019.2.9,这个错误出现的同时,也可能会连带着以下两个 crash。

crash1:

Caused by: java.lang.Error: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0000000000000008
Build fingerprint: 'xxxxx 测试信息'
Revision: '0'
pid: 13512, tid: 13788, name: UnityMain  >>> xxx 游戏包名 <<<
    x0   0000000000000008  x1   0000000000000040  x2   000000705c34e4be  x3   0000000000000003
    x4   0000000000000054  x5   0000007035b181e3  x6   00000000000001bc  x7   abababababababab
    x8   000000700de21110  x9   0000000000000000  x10  0000000000430000  x11  0000000000010001
    x12  0000000000000000  x13  0000000010000000  x14  0000000000000001  x15  0000007030298583
    x16  0000007035dc0e98  x17  000000705de80b88  x18  0000007035af326d  x19  000000700620df10
    x20  000000702ee547b0  x21  0000007035de3000  x22  0000000000000001  x23  000000700de234e8
    x24  000000700de21f40  x25  0000000012f0af80  x26  00000000701b89d8  x27  0000000070873148
    x28  0000000070274b70  x29  000000007030cb30  x30  00000070352714d4
    sp   000000700de210e0  pc   0000007035832e7c  pstate 0000000060000000

	at [vdso].(:0)
	at libunity.(:0)

crash2 是个超时问题:

Subject: Input dispatching timed out (Waiting because no window has focus but there is a focused application that may eventually add a window when it finishes starting up.)

目前可以进行一定分析的就只有第一个 00000004 的问题,分析方式是借助 NDK 的 arm-linux-andr
oideabi-addr2line 工具来在一定程度上定位 so 崩溃的问题。具体使用方法参考这篇文章

通过分析,发现 006ee0f8 对应的是 UnitySendMessage 方法,而 0023293d 对应的是 JNI_OnUnload 方法,除此以外没有其他有用的信息了。

此外经过在 google 的查询,目前推测这个问题很有可能是和 Unity 的 Application.Quit() 有关,毕竟我们没有测试条件,而测试方也没有给更多的信息,所以推测是在使用了这个方法将程序退出后,再次点击 app 图标时或某种其他操作可能就会导致 crash。
网上有一种解决方案是重写 Android 端的 OnPause() 方法:

    @Override
    protected void onPause() {
    
    
        if(!isFinish) mUnityPlayer.pause();
        super.onPause();
    }

但是我经过重写也还是会出现这个问题,而且测试机的型号比较随机,目前这个问题在 Unity 的官方论坛上也没有明确的解决方案。

临时解决方法:
最后我们决定将使用 Application.Quite() 部分的代码注销掉,之后终于通过了测试。

PS:
一开始之所以要加这个功能是因为发行方说要想上 Google Play 就必须在游戏内提供一个退出游戏的功能,所以我们添加了退出功能键,并且在系统功能键上面也实现了退出游戏的逻辑,但是没想到出现了这么难搞的问题。而且我在 Google Play 上面下了一些游戏中也没有相关的退出逻辑,所以感觉有点被坑到了。

猜你喜欢

转载自blog.csdn.net/EverNess010/article/details/107611115