在使用硬件加速的ViewPager中使用WebViews导致Android进程崩溃

时间:2012-07-03 16:06:12

标签: android webview crash hardware-acceleration

我有一个ViewPager活动,我用它来翻阅包含“随机”网页的碎片网页内容不受我控制。我正在使用FragmentStatePagerAdapter和最新的支持库。每个片段的布局都包含一个加载“随机”页面的webview。用户可以无限期地前进。

当我打开硬件加速时,在一些滑动后我得到一个seg故障崩溃(转储在下面)。关闭活动的硬件加速,没有崩溃,但当然webview滚动和视图分页器转换非常不稳定。另外,我无法在youtube等网页上播放嵌入式视频。

特定页面上不会发生崩溃。此外,重现碰撞所需的滑动次数也各不相同 - 有时它是在第一次滑动时,有时需要几次,但它非常一致。我在运行应用程序的时候检查了内存使用情况,看起来很好(ram和vram) - 从某种意义上来说很好,我认为我没有使用太多,而且我没有得到任何低内存警告。

到目前为止,我在所有3.0多台设备上遇到过这个问题:

  • toshiba regza跑步4.0.3
  • motorola xoon running 3.2.1
  • galaxy nexus phone运行4.0.4(fwiw,在手机上频繁发生)

这是一个已知问题吗?任何解决方法?

07-02 15:12:30.187: I/DEBUG(111): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

07-02 15:12:30.187: I/DEBUG(111): Build fingerprint: 'TOSHIBA/tostab05/tostab05:4.0.3/IML74K/05.3.0012:user/release-keys'

07-02 15:12:30.187: I/DEBUG(111): pid: 1538, tid: 1538  >>> xxx <<<

07-02 15:12:30.187: I/DEBUG(111): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0000043e
07-02 15:12:30.187: I/DEBUG(111):  r0 0000000b  r1 02514ba0  r2 befbf378  r3 0000043e

07-02 15:12:30.187: I/DEBUG(111):  r4 020a43e8  r5 02070958  r6 00000000  r7 00000006

07-02 15:12:30.187: I/DEBUG(111):  r8 00000000  r9 020a2364  10 01d2d108  fp befbf6e4

07-02 15:12:30.187: I/DEBUG(111):  ip 409da55c  sp befbf330  lr 409c3487  pc 409c349a  cpsr 80000030

07-02 15:12:30.187: I/DEBUG(111):  d0  4488000044800000  d1  0000000044800000

07-02 15:12:30.187: I/DEBUG(111):  d2  4480000044801000  d3  00000000000000af

07-02 15:12:30.187: I/DEBUG(111):  d4  3f800000170000e0  d5  4480000044800000

07-02 15:12:30.187: I/DEBUG(111):  d6  4488000000000000  d7  4260000000000000

07-02 15:12:30.187: I/DEBUG(111):  d8  0000000000000000  d9  0000000300000038

07-02 15:12:30.187: I/DEBUG(111):  d10 00000000000002f0  d11 0000000000000000

07-02 15:12:30.187: I/DEBUG(111):  d12 0000000000000000  d13 0000000000000000

07-02 15:12:30.187: I/DEBUG(111):  d14 0000000000000000  d15 0000000000000000

07-02 15:12:30.187: I/DEBUG(111):  d16 0000000000000000  d17 3ff0000000000000

07-02 15:12:30.187: I/DEBUG(111):  d18 3fe0000000000000  d19 3fe000000112a880

07-02 15:12:30.187: I/DEBUG(111):  d20 3ff0000000000000  d21 8000000000000000

07-02 15:12:30.187: I/DEBUG(111):  d22 c000000000000000  d23 0000000000000000

07-02 15:12:30.187: I/DEBUG(111):  d24 0000000000000000  d25 3ff0000000000000

07-02 15:12:30.187: I/DEBUG(111):  d26 4010000000000000  d27 3ff0000000000000

07-02 15:12:30.187: I/DEBUG(111):  d28 0000000000000000  d29 3ff0000000000000

07-02 15:12:30.187: I/DEBUG(111):  d30 0000000000000000  d31 3ff0000000000000

07-02 15:12:30.187: I/DEBUG(111):  scr 80000013

07-02 15:12:30.335: I/DEBUG(111):          #00  pc 0000c49a  /system/lib/libhwui.so

07-02 15:12:30.343: I/DEBUG(111):          #01  pc 00010d3c  /system/lib/libhwui.so

07-02 15:12:30.343: I/DEBUG(111):          #02  pc 0000c682  /system/lib/libhwui.so

07-02 15:12:30.343: I/DEBUG(111):          #03  pc 00010d3c  /system/lib/libhwui.so

07-02 15:12:30.343: I/DEBUG(111):          #04  pc 0000c682  /system/lib/libhwui.so

07-02 15:12:30.343: I/DEBUG(111):          #05  pc 00010d3c  /system/lib/libhwui.so

07-02 15:12:30.343: I/DEBUG(111):          #06  pc 0000c682  /system/lib/libhwui.so

07-02 15:12:30.343: I/DEBUG(111):          #07  pc 00010d3c  /system/lib/libhwui.so

07-02 15:12:30.343: I/DEBUG(111):          #08  pc 0000c682  /system/lib/libhwui.so

07-02 15:12:30.343: I/DEBUG(111):          #09  pc 00010d3c  /system/lib/libhwui.so

07-02 15:12:30.343: I/DEBUG(111):          #10  pc 0000c682  /system/lib/libhwui.so

07-02 15:12:30.351: I/DEBUG(111):          #11  pc 00010d3c  /system/lib/libhwui.so

07-02 15:12:30.351: I/DEBUG(111):          #12  pc 00057874  /system/lib/libandroid_runtime.so
07-02 15:12:30.351: I/DEBUG(111):          #13  pc 0001ebf0  /system/lib/libdvm.so (dvmPlatformInvoke)
07-02 15:12:30.351: I/DEBUG(111):          #14  pc 00058eac  /system/lib/libdvm.so (_Z16dvmCallJNIMethodPKjP6JValuePK6MethodP6Thread)

07-02 15:12:30.351: I/DEBUG(111): code around pc:

07-02 15:12:30.351: I/DEBUG(111): 409c3478 f7fe6781 9010ffa3 f0044628 9f0df81f  .g......(F......

07-02 15:12:30.351: I/DEBUG(111): 409c3488 ab13aa12 920b3701 9711930e 900f3801  .....7.......8..

07-02 15:12:30.351: I/DEBUG(111): 409c3498 f853e2fe 98107b04 990d463a f7fe67a3  ..S..{..:F...g..

07-02 15:12:30.351: I/DEBUG(111): 409c34a8 2f23fedf 82f4f200 f017e8df 0037002e  ..#/..........7.

07-02 15:12:30.351: I/DEBUG(111): 409c34b8 0043003a 00810061 0095008c 00ad00a2  :.C.a...........

07-02 15:12:30.351: I/DEBUG(111): code around lr:

07-02 15:12:30.351: I/DEBUG(111): 409c3464 460db095 920c4604 0800f04f 4646930d  ...F.F..O.....FF

07-02 15:12:30.351: I/DEBUG(111): 409c3474 1080f8d0 f7fe6781 9010ffa3 f0044628  .....g......(F..

07-02 15:12:30.351: I/DEBUG(111): 409c3484 9f0df81f ab13aa12 920b3701 9711930e  .........7......

07-02 15:12:30.351: I/DEBUG(111): 409c3494 900f3801 f853e2fe 98107b04 990d463a  .8....S..{..:F..

07-02 15:12:30.351: I/DEBUG(111): 409c34a4 f7fe67a3 2f23fedf 82f4f200 f017e8df  .g....#/........

07-02 15:12:30.351: I/DEBUG(111): stack:

07-02 15:12:30.351: I/DEBUG(111):     befbf2f0  00000000  

07-02 15:12:30.351: I/DEBUG(111):     befbf2f4  befbf30c  [stack]

07-02 15:12:30.351: I/DEBUG(111):     befbf2f8  0237c55c  [heap]

07-02 15:12:30.351: I/DEBUG(111):     befbf2fc  befbf364  [stack]

07-02 15:12:30.351: I/DEBUG(111):     befbf300  409da430  /system/lib/libhwui.so

07-02 15:12:30.351: I/DEBUG(111):     befbf304  01d8c2d8  [heap]

07-02 15:12:30.351: I/DEBUG(111):     befbf308  409daa10  /system/lib/libhwui.so

07-02 15:12:30.351: I/DEBUG(111):     befbf30c  409c7d05  /system/lib/libhwui.so

07-02 15:12:30.351: I/DEBUG(111):     befbf310  00000000  

07-02 15:12:30.351: I/DEBUG(111):     befbf314  020a2364  [heap]

07-02 15:12:30.351: I/DEBUG(111):     befbf318  01d2d108  [heap]

07-02 15:12:30.351: I/DEBUG(111):     befbf31c  409c23f1  /system/lib/libhwui.so

07-02 15:12:30.351: I/DEBUG(111):     befbf320  020a43e8  [heap]

07-02 15:12:30.351: I/DEBUG(111):     befbf324  02070958  [heap]

07-02 15:12:30.351: I/DEBUG(111):     befbf328  df0027ad  

07-02 15:12:30.359: I/DEBUG(111):     befbf32c  00000000  

07-02 15:12:30.359: I/DEBUG(111): #00 befbf330  00000000  

07-02 15:12:30.359: I/DEBUG(111):     befbf334  3f800000  

07-02 15:12:30.359: I/DEBUG(111):     befbf338  00000000  

07-02 15:12:30.359: I/DEBUG(111):     befbf33c  44800000  /dev/ashmem/dalvik-heap (deleted)

07-02 15:12:30.359: I/DEBUG(111):     befbf340  00000000  

07-02 15:12:30.359: I/DEBUG(111):     befbf344  00000000  

07-02 15:12:30.359: I/DEBUG(111):     befbf348  3f800000  

07-02 15:12:30.359: I/DEBUG(111):     befbf34c  02370001  [heap]

07-02 15:12:30.359: I/DEBUG(111):     befbf350  00000000  

07-02 15:12:30.359: I/DEBUG(111):     befbf354  00000000  

07-02 15:12:30.359: I/DEBUG(111):     befbf358  befbf378  [stack]

07-02 15:12:30.359: I/DEBUG(111):     befbf35c  befbf378  [stack]

07-02 15:12:30.359: I/DEBUG(111):     befbf360  befbf6a0  [stack]

07-02 15:12:30.359: I/DEBUG(111):     befbf364  00000005  

07-02 15:12:30.359: I/DEBUG(111):     befbf368  befbf37c  [stack]

07-02 15:12:30.359: I/DEBUG(111):     befbf36c  0000000b  

07-02 15:12:30.359: I/DEBUG(111):     befbf370  01d8c2d8  [heap]

07-02 15:12:30.359: I/DEBUG(111):     befbf374  00000006  

07-02 15:12:30.359: I/DEBUG(111):     befbf378  44800000  /dev/ashmem/dalvik-heap (deleted)

07-02 15:12:30.359: I/DEBUG(111):     befbf37c  00000000  

07-02 15:12:30.359: I/DEBUG(111):     befbf380  44880000  /dev/ashmem/dalvik-heap (deleted)

07-02 15:12:30.359: I/DEBUG(111):     befbf384  020a43e8  [heap]

07-02 15:12:30.359: I/DEBUG(111):     befbf388  02070958  [heap]

07-02 15:12:30.359: I/DEBUG(111):     befbf38c  00000000  

07-02 15:12:30.359: I/DEBUG(111):     befbf390  409c7d05  /system/lib/libhwui.so

07-02 15:12:30.359: I/DEBUG(111):     befbf394  00000000  

07-02 15:12:30.359: I/DEBUG(111):     befbf398  020a2364  [heap]

07-02 15:12:30.359: I/DEBUG(111):     befbf39c  01d2d108  [heap]

07-02 15:12:30.359: I/DEBUG(111):     befbf3a0  befbf6e4  [stack]

07-02 15:12:30.359: I/DEBUG(111):     befbf3a4  409c7d41  /system/lib/libhwui.so

07-02 15:12:30.359: I/DEBUG(111): #01 befbf3a8  42600000  /dev/ashmem/dalvik-heap (deleted)

07-02 15:12:30.359: I/DEBUG(111):     befbf3ac  020a43e8  [heap]

07-02 15:12:30.359: I/DEBUG(111):     befbf3b0  00000040  

07-02 15:12:30.359: I/DEBUG(111):     befbf3b4  020a41a0  [heap]

07-02 15:12:30.359: I/DEBUG(111):     befbf3b8  02070958  [heap]

07-02 15:12:30.359: I/DEBUG(111):     befbf3bc  409c3685  /system/lib/libhwui.so

1 个答案:

答案 0 :(得分:1)

好的,我找到了一个解决方法和崩溃的“原因”。我把“因果”放在引号中,因为我不认为我在原始代码中做错了什么。

我的片段中有以下代码:

@Override
public void onCreate(Bundle savedInstanceState)
{
    ...
    setHasOptionsMenu(true);
    ...
}

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
{
    inflater.inflate(R.menu.options_menu, menu);
}

@Override
public void onPrepareOptionsMenu(Menu menu)
{
    ... // apply a menu strategy that enables/disables some items based on app state
}

出于某种原因,如果我拿出通货膨胀代码,则不再发生崩溃。解决方法是在活动级别对菜单进行膨胀,然后仍然在片段级别应用菜单策略。不知道为什么会这样。如果它有所作为,我目前没有使用ABSherlock。