I got in error track of an app TransactionTooLargeException. Not reproducible and never had it before. In the docs it says
The Binder transaction failed because it was too large.
During a remote procedure call, the arguments and the return value of the call are transferred as Parcel objects stored in the Binder transaction buffer. If the arguments or the return value are too large to fit in the transaction buffer, then the call will fail and TransactionTooLargeException will be thrown.
...
There are two possible outcomes when a remote procedure call throws TransactionTooLargeException. Either the client was unable to send its request to the service (most likely if the arguments were too large to fit in the transaction buffer), or the service was unable to send its response back to the client (most likely if the return value was too large to fit in the transaction buffer).
...
So, ok, somewhere I'm passing or receiving arguments which exceed some unknown limit. But where?
The stacktrace doesn't show anything from my files:
java.lang.RuntimeException: Adding window failed
at android.view.ViewRootImpl.setView(ViewRootImpl.java:548)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:406)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:320)
at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:152)
at android.view.Window$LocalWindowManager.addView(Window.java:557)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2897)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$600(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1262)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:4977)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.os.TransactionTooLargeException
at android.os.BinderProxy.transact(Native Method)
at android.view.IWindowSession$Stub$Proxy.add(IWindowSession.java:569)
at android.view.ViewRootImpl.setView(ViewRootImpl.java:538)
... 16 more
android.os.TransactionTooLargeException
at android.os.BinderProxy.transact(Native Method)
at android.view.IWindowSession$Stub$Proxy.add(IWindowSession.java:569)
at android.view.ViewRootImpl.setView(ViewRootImpl.java:538)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:406)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:320)
at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:152)
at android.view.Window$LocalWindowManager.addView(Window.java:557)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2897)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$600(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1262)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:4977)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
It seems to be related with views, because all the Window / View lines? How is this related to remote procedure call? How can I look for the reason of this error?
In the app I'm using only Webservices, I'm not using Service class, are the Webservices the "remote procedure calls" or what else could be...?
P.S. Maybe it's important: Android version: 4.0.3, Device: HTC One X
Try to use
EventBus
orContentProvider
like solution.If you are in the same process(normally all your activities would be), try to use
EventBus
, cause in process data exchange does NOT need a somewhat buffer, so you do not need to worry about your data is too large. (You can just use method call to pass data indeed, and EventBus hide the ugly things) Here is the detail:If the two sides of Intent are not in the same process, try somewhat
ContentProvider
.See TransactionTooLargeException
One can use:
in Android Manifest under application tag.
This solved the issue in my case!
A solution would be for the app to write the ArrayList (or whatever object is causing the problem) to the file system, then pass a reference to that file (e.g., filename/path) via the Intent to the IntentService and then let the IntentService retrieve the file contents and convert it back to an ArrayList.
When the IntentService has done with the file, it should either delete it or pass the instruction back to the app via a Local Broadcast to delete the file that it created (passing back the same file reference that was supplied to it).
For more info see my answer to this related problem.
For me TransactionTooLargeException occurred when i tried to send large bitmap image from one activity to another via intent. I solved this problem by using Application's Global Variables.
For example if you want to send large bitmap image from an activity A to to activity B, then store that bitmap image in global variable
then start activity B and read from global variable
For me it was also the
FragmentStatePagerAdapter
, however overridingsaveState()
did not work. Here's how I fixed it:When calling the
FragmentStatePagerAdapter
constructor, keep a separate list of fragments within the class, and add a method to remove the fragments:Then in the
Activity
, save theViewPager
position and calladapter.removeFragments()
in the overriddenonSaveInstanceState()
method:Lastly, in the overridden
onResume()
method, re-instantiate the adapter if it isn'tnull
. (If it'snull
, then theActivity
is being opened for the first time or after the app has been killed off by Android, in whichonCreate
will do the adapter creation.)The
TransactionTooLargeException
has been plaguing us for about 4 months now, and we've finally resolved the issue!What was happening was we are using a
FragmentStatePagerAdapter
in aViewPager
. The user would page through and create 100+ fragments (its a reading application).Although we manage the fragments properly in
destroyItem()
, in Androids implementation ofFragmentStatePagerAdapter
there is a bug, where it kept a reference to the following list:And when the Android's
FragmentStatePagerAdapter
attempts to save the state, it will call the functionAs you can see, even if you properly manage the fragments in the
FragmentStatePagerAdapter
subclass, the base class will still store anFragment.SavedState
for every single fragment ever created. TheTransactionTooLargeException
would occur when that array was dumped to aparcelableArray
and the OS wouldn't like it 100+ items.Therefore the fix for us was to override the
saveState()
method and not store anything for"states"
.