开发者

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 co开发者_StackOverflow中文版de, 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>


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


I too am struggling to find the exact source of these errors. I have found a thread on the Google Groups AdMob forum that suggests it might be related to the AdMod SDK. For me, these errors started showing up after I published my latest update, which among other changes included upgrading the AdMob SDK from v4.1.1 to v4.3.1. Are you using AdMob?

Seems that the AdMob SDK in some circumstances manipulates its WebViews off of the UI thread, which I guess could cause various problems, possibly i.e. concurrent SQLite access from different threads when managing the cache. Possibly related to SQLiteDiskIOException in Android. Might also be worthwhile checking that your own code does not manipulate WebViews off of the UI thread.


There is an issue reported in code.google site.

EDIT : If you are ready to disable the cache, the exception's frequency might decrease a bit.

try
{
  Method m = CacheManager.class.getDeclaredMethod("setCacheDisabled", boolean.class);
  m.setAccessible(true);
  m.invoke(null, true);
}
catch (Throwable e)
{
  Log.i("myapp","Reflection failed", e);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜