Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android.os.TransactionTooLargeException in AppWidgetManager.updateAppWidget

I receive report about android.os.TransactionTooLargeException from my widget users:

android.os.TransactionTooLargeException
android.os.BinderProxy.transact(Native Method)
com.android.internal.appwidget.IAppWidgetService$Stub$Proxy.updateAppWidgetIds(IAppWidgetService.java:611)
android.appwidget.AppWidgetManager.updateAppWidget(AppWidgetManager.java:378)
android.appwidget.AppWidgetManager.updateAppWidget(AppWidgetManager.java:445)
com.alonedroid.ooswitcher.animationRunnable.run(ProvidersShared.java:1804)
java.lang.Thread.run(Thread.java:841)

That exception occurs when I try to update my widget in separate thread through AppWidgetManager.updateAppWidget(widget_id, RemoteView). I read from documentation about TransactionTooLargeException, and, first, i thought - it is because of size of RemoteViews instance. So I start to set more layouts inside my RemoteViews instance, but never saw this error on my device.

Did somebody faced that problem too and maybe even solve it? And how to reproduce that error to debug application?

like image 445
alonedroid Avatar asked Nov 22 '13 09:11

alonedroid


1 Answers

Looking at the implementation of RemoteViews, it looks like this can happen if too many operations are done on a single RemoteViews instance.

For example calling setTextViewText 1000 times with the same parameters will add 1000 operations to the RemoteViews which will have to be transferred across processes and applied as an update.

Making sure that the same RemoteViews object is not reused for an insane amount of operations seems to fix this.

like image 170
Erik Avatar answered Oct 26 '22 18:10

Erik