Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebView causes SQLiteDiskIOException

I've been getting reports of SQLiteDiskIOExceptions for some time now (via Flurry/acra). I haven't been able to reproduce the issue locally, but it's my most frequent crash, occurring up to once in fifty sessions on a bad day. They seem to be particularly frequent under Android 2.3.x.

I make absolutely no use of SQL in my own code, but I have more than one WebView running simultaneously (two, plus an ads SDK). The errors all appear to be caused by a WebView, via one of any of the following methods:

  • android.webkit.WebViewDatabase.clearCache
  • android.webkit.WebViewDatabase.flushCacheStat
  • android.webkit.WebViewDatabase.deleteCookies
  • android.webkit.WebViewDatabase.removeCache

(Also received a couple of reports of an android.database.sqlite.SQLiteDatabaseCorruptException , but these are extremely rare). I commented out anything relating to clearing the WebView cache in my own code, but that didn't help.

Full LogCat dumps here.

Does anyone know of any way I could prevent, catch, or more clearly isolate the cause of these exceptions? They're too frequent to just be caused by bad SD memory.

Thanks!

Edit: Source code by request:

  browser=(WebView)findViewById(R.id.webkit);
  browser.setWebViewClient( new CustomWebViewClient(this,browser) );
  WebSettings webSettings = browser.getSettings();
  webSettings.setJavaScriptEnabled(true);
  webSettings.setPluginsEnabled(true);
  browser.setScrollBarStyle(WebView.SCROLLBARS_INSIDE_OVERLAY);
  webSettings.setBuiltInZoomControls(true);

  browser.setWebChromeClient(new WebChromeClient() {
    public void onProgressChanged(WebView view, int progress) {
      progressbarhorizontal.setProgress(progress);
    }
  });

XML:

        <WebView android:id="@+id/webkit" android:layout_width="fill_parent" android:layout_height="fill_parent" android:focusable="true" android:nextFocusDown="@+id/bottomview"></WebView>
like image 811
Sven Viking Avatar asked Aug 23 '11 08:08

Sven Viking


1 Answers

You may be able to utilize setUncaughtExceptionHandler() in order to catch the exception and gracefully handle it.

like image 194
NuSkooler Avatar answered Oct 20 '22 18:10

NuSkooler