Webview Activity crash due to TransactionTooLarge error

518 Views Asked by At

I using webview to render a form. Application get crash after onPageStarted method and in LogCat I am finding below error.

 java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 603696 bytes
        at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:160)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
     Caused by: android.os.TransactionTooLargeException: data parcel size 603696 bytes
        at android.os.BinderProxy.transactNative(Native Method)
        at android.os.BinderProxy.transact(Binder.java:1127)
        at android.app.IActivityManager$Stub$Proxy.activityStopped(IActivityManager.java:4027)
        at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:144)
        at android.os.Handler.handleCallback(Handler.java:873) 
        at android.os.Handler.dispatchMessage(Handler.java:99) 
        at android.os.Looper.loop(Looper.java:193) 
        at android.app.ActivityThread.main(ActivityThread.java:6669) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 

I am not saving anything in OnSavedInstanceState().

2

There are 2 best solutions below

0
On

add

webView.getSettings().domStorageEnabled = true 

before load url and after load url add these two line it will works.

webView.webChromeClient = WebChromeClient()
webView.webViewClient = WebViewClient()
0
On

the WebView itself might be saving a large state which exceeds the Binder transaction buffer limit.

override fun onSaveInstanceState(outState: Bundle) {
    super.onSaveInstanceState(outState)
    outState.putParcelable("android:webViewState", null)
}

this replace the WebView state with a null value, ensuring that it doesn't get saved.