Search code examples
androidwebviewcrashhardware-acceleration

Android process crash using WebViews inside a ViewPager with hardware acceleration on


I have an activity with a ViewPager that I use to flip through Fragments containing "random" webpages The web content is not controlled by me. I'm using a FragmentStatePagerAdapter and the latest support library. Each Fragment's layout contains a webview that loads a "random" page. The user can flip forward indefinitely.

When I turn hardware acceleration on, I get a seg fault crash (dump is below) after a handful of swipes. With hardware acceleration off for the activity, there is no crash, but of course the webview scroll and view pager transitions are very choppy. Plus I can't play embedded video on pages like youtube.

The crash does not happen on specific pages. Also the number of swipes needed to reproduce the crash varies - sometimes it's on the first swipe, sometimes it takes several, but it is very consistent. I've checked memory usage while running the app and it seems fine (ram and vram) - fine in the sense that I don't think I am using too much, and I don't get any low mem warnings.

I've hit the issue on all 3.0+ devices I've tried so far:

  • toshiba regza running 4.0.3
  • motorola xoon running 3.2.1
  • galaxy nexus phone running 4.0.4 (fwiw, happens less frequently on the phone)

Is this a known issue? Any workaround?

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

Solution

  • OK, I found a workaround and the "cause" of the crash. I put "cause" in quotes, because I don't think I'm doing anything wrong in my original code.

    I had the following code in my fragment:

    @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
    }
    

    For some reason, if I take out the inflation code, the crash no longer occurs. The workaround is to inflate the menu at the activity level, and then still apply the menu strategy at the fragment level. Not sure why this is happening. If it makes a difference I am currently not using ABSherlock.