kiwix-android icon indicating copy to clipboard operation
kiwix-android copied to clipboard

Chrome.apk crashes in Kiwix-Android and top custom apps

Open julianharty opened this issue 3 years ago • 3 comments
trafficstars

Describe the bug Various crashes are reported in Android Vitals for Chrome.apk in the Kiwix family of apps. They have a variety of offsets, it's not clear whether this means the various crashes are distinct and/or whether we could/would handle them differently depending on the specific offset, etc.

It occurs regardless of where the app was installed from (but mainly when installed from Google Play) and both when the app is in the foreground (mainly) and background (infrequently).

Note: We already have several similar crash clusters "hidden" which indicates a project member may have already decided not to try and address this issue.

Exception Occurrences in last 30 days in Google Play Occurrences in last 30 days total Total occurrences Impacted users URL to crash cluster
signal 5 (SIGTRAP), code 1 (TRAP_BRKPT) Chrome.apk (offset 0xfb4000) 49 51 410 42 Cluster 633cc12d
signal 5 (SIGTRAP), code 1 (TRAP_BRKPT) Chrome.apk (offset 0xf01000) 44 48 620 116 Cluster e1e45b1b
signal 5 (SIGTRAP), code 1 (TRAP_BRKPT) Chrome.apk (offset 0x1b8d000) 31 32 107 20 Cluster 59c73cfb
signal 5 (SIGTRAP), code 1 (TRAP_BRKPT) Chrome.apk (offset 0x87b000) 19 19 98 25 Cluster 8e40c4f3
signal 5 (SIGTRAP), code 4 (TRAP_HWBKPT) Chrome.apk (offset 0xf2d000) 9 9 87 33 Cluster a0d8323b
signal 5 (SIGTRAP), code 1 (TRAP_BRKPT) Chrome.apk (offset 0x1ea7000) 7 9 125 22 'Hidden' cluster 53ba51ff

The next two hidden clusters are for: signal 5 (SIGTRAP), code 4 (TRAP_HWBKPT) Chrome.apk (offset 0xfcb000) and signal 5 (SIGTRAP), code 1 (TRAP_BRKPT) Chrome.apk (offset 0x8c4000) They each happened 4 times in the last 30 days and it doesn't currently seem like any more details are required for these 2 hidden crash clusters.

Expected behavior Ideally, the apps would cope gracefully with whatever's happening under the covers on the end-user devices.

Steps to reproduce the behavior: Unknown, these are reported in Android Vitals.

Screenshots The following screenshot was captured using Android Vitals URL for production releases installed from Google Play

Screenshot 2022-07-09 at 16 35 38

Here's a screenshot of the most common cluster: Screenshot 2022-07-09 at 16 49 47

Environment

  • Production releases installed from Google Play (6 crash clusters in the top 40)
  • Production releases installed from anywhere (10 crash clusters in the top 40)
  • All releases installed from Google Play (10 crash clusters in the top 40)
  • All releases installed from anywhere (5 crash clusters in the top 40)

Logs The first crash cluster doesn't have much in the stack trace:

*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
pid: 0, tid: 0 >>> org.kiwix.kiwixmobile <<<

backtrace:
  #00  pc 00000000010f8818  /system/app/Chrome/Chrome.apk (offset 0xfb4000)
  #00  pc 00000000010f86f0  /system/app/Chrome/Chrome.apk (offset 0xfb4000)

And even less for the second crash cluster:

*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
pid: 0, tid: 0 >>> org.kiwix.kiwixmobile <<<

backtrace:
  #00  pc 0000000002283488  /system/app/Chrome/Chrome.apk (offset 0xf01000)

or the 3rd...:

*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
pid: 0, tid: 0 >>> org.kiwix.kiwixmobile <<<

backtrace:
  #00  pc 0000000001fa83ba  /system/app/Chrome/Chrome.apk (offset 0x1b8d000)

or the 4th:

*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
pid: 0, tid: 0 >>> org.kiwix.kiwixmobile <<<

backtrace:
  #00  pc 000000000172d3ba  /system/app/Chrome/Chrome.apk (offset 0x87b000)

The 5th crash cluster is back to 2 lines in the stack trace:

*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
pid: 0, tid: 0 >>> org.kiwix.kiwixmobile <<<

backtrace:
  #00  pc 0000000000e2ca1c  /system/app/Chrome/Chrome.apk (offset 0xf2d000)
  #00  pc 0000000000e2c947  /system/app/Chrome/Chrome.apk (offset 0xf2d000)

Here's the first of the crash clusters that's been hidden:

*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
pid: 0, tid: 0 >>> org.kiwix.kiwixmobile <<<

backtrace:
  #00  pc 0000000002425284  /system/app/Chrome/Chrome.apk (offset 0x1ea7000)

FWIW one closed ticket https://github.com/kiwix/kiwix-android/issues/287 appeared when I searched for any Chrome.apk tickets here. That ticket discusses ways to improve the logging of JNI-related issues. Perhaps a global exception handler might be one way of handling this crash a bit more gracefully. TBD as and when we learn more about this issue.

This ticket has been raised as part of https://github.com/kiwix/kiwix-android/issues/2903

julianharty avatar Jul 09 '22 16:07 julianharty

Note: these crashes also occur in older releases of Kiwix Android. In the small volume of crashes reported for WikiMed in English there are 2 related crash clusters in the top 10 (filter criteria: the last 30 days for production releases installed from Google Play in the last 30 days):

  • signal 5 (SIGTRAP), code 1 (TRAP_BRKPT) Chrome.apk (offset 0x1ea7000) which occurred 6 times.
  • signal 5 (SIGTRAP), code 1 (TRAP_BRKPT) Chrome.apk (offset 0x8c4000) which occurred 3 times.

For the Chemistry and Physics simulations app the clusters each appeared once in the last 30 days, they are:

  • signal 5 (SIGTRAP), code 1 (TRAP_BRKPT) Chrome.apk (offset 0xbd7000)
  • signal 11 (SIGSEGV), code 1 (SEGV_MAPERR) Chrome.apk (offset 0xfb4000)
  • signal 5 (SIGTRAP), code -6 (SI_TKILL) Chrome.apk (offset 0x1b53000)
  • signal 11 (SIGSEGV), code 1 (SEGV_MAPERR) Chrome.apk (offset 0xfb4000)

unusually there are two new, distinct variations: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR) and signal 5 (SIGTRAP), code -6 (SI_TKILL) . These might occur in the other Kiwix apps but be lower down the ranked lists of crash clusters.

julianharty avatar Jul 09 '22 16:07 julianharty

Other developers have faced similar crashes e.g.

Searching online finds:

  • https://www.reddit.com/r/androiddev/comments/bqs6id/many_signal_5_sigtrap_code_1_trap_brkpt_crashes/ however they didn't find a fix for their issue.
  • https://groups.google.com/g/google-admob-ads-sdk/c/I6giN0VbVa0/m/Dr_NHi6UCwAJ is a very long discussion about crashes being reported in Android Vitals Of the 100's of comments, https://groups.google.com/g/google-admob-ads-sdk/c/I6giN0VbVa0/m/2PG3apaSBwAJ claims to have developed a fix for the crash, the text is repeated below:

Raul Abreu Dec 17, 2019, 7:19:56 PM to Google Mobile Ads SDK Developers Hi everyone... We have solved the problem. We focused on OOM using the https://github.com/square/leakcanary library and common memory usage guidelines: https://developer.android.com/topic/performance/memory. Other important optimization was to reduce thread pool usage (this lead to OOMs as well), we change our thread management to single thread pool usage (see https://gist.github.com/raulccabreu/9c4a45432347b7af76ca0ad0959ae233) Thanks for all support, info and help, see ya!

julianharty avatar Jul 09 '22 17:07 julianharty

What is chrome.apk? We don’t publish such a file?!

kelson42 avatar Jul 10 '22 16:07 kelson42

I have tried with several zim and android api levels but unable to reproduce the error. here are some useful links. https://itecnote.com/tecnote/android-signal-5-sigtrap-code-1-trap_brkpt-relating-to-webview-apk/ https://groups.google.com/g/google-admob-ads-sdk/c/I6giN0VbVa0/m/Dr_NHi6UCwAJ

all articles point to same answer. It's an known, un-fixable bug with the Chrome WebView on Android 7 and above. The WebView is used to display the ads whether you create one or not. It's not specific to AdMob. Don't count on this getting fixed, it's been present since 2017 and crashes are being forwarded to the Chrome team.

I found only one in this article solution but we are already doing that. https://stackoverflow.com/questions/42925436/android-webview-crash-fatal-signal-5-sigtrap in this artical they shows (if any popup is open in webview first close that popup) (they suggest to override onBackPressed) we already doing that.

MohitMaliFtechiz avatar Dec 08 '22 13:12 MohitMaliFtechiz

What is chrome.apk? We don’t publish such a file?!

@kelson42 Chrome.apk is the binary that is part of Google Chrome and on many Android devices it provides the embedded WebView that's used in the Kiwix Android apps to render the content (from Wikipedia, etc.). So it's an essential component for our apps unless we undergo a major rearchitecture of the app in order to use another tool/service/mechanism to render and display the content of ZIM files.

julianharty avatar Dec 08 '22 17:12 julianharty

The WebView is used to display the ads whether you create one or not. It's not specific to AdMob.

@MohitMaliFtechiz Does Kiwix now display ads? My understanding is Kiwix uses the WebView to render the content contained in ZIM files.

julianharty avatar Dec 08 '22 17:12 julianharty

The WebView is used to display the ads whether you create one or not. It's not specific to AdMob.

@MohitMaliFtechiz Does Kiwix now display ads? My understanding is Kiwix uses the WebView to render the content contained in ZIM files.

No I posted the conclusion text from above post , we are only using webview to render contained.

MohitMaliFtechiz avatar Dec 09 '22 11:12 MohitMaliFtechiz

I don’t think there is anything we can do here. Changing the rendering engine is not an option because too complicated.

kelson42 avatar Dec 30 '22 08:12 kelson42