11

Since a couple of month I'm having a large number of exceptions in my app with the error message: Adding window failed (android.os.TransactionTooLargeException)

I know about the IPC buffer transaction size being limited to 1024KB, but I just send ids to my service (Long value). What's strange is that these exceptions only occurs on Samsung devices with Android 4.4.2 (every single one of more than 50K crashes). Do you know a a specific bug in the latest Samsung ROM ?

    java.lang.RuntimeException: Adding window failed
       at android.view.ViewRootImpl.setView(ViewRootImpl.java:738)
       at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:278)
       at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
       at android.widget.Toast$TN.handleShow(Toast.java:478)
       at android.widget.Toast$TN$1.run(Toast.java:374)
       at android.os.Handler.handleCallback(Handler.java:733)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:136)
       at android.app.ActivityThread.main(ActivityThread.java:5476)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:515)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
       at dalvik.system.NativeStart.main(NativeStart.java)
Caused by: android.os.TransactionTooLargeException
       at android.os.BinderProxy.transact(Binder.java)
       at android.view.IWindowSession$Stub$Proxy.addToDisplay(IWindowSession.java:710)
       at android.view.ViewRootImpl.setView(ViewRootImpl.java:727)
       at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:278)
       at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
       at android.widget.Toast$TN.handleShow(Toast.java:478)
       at android.widget.Toast$TN$1.run(Toast.java:374)
       at android.os.Handler.handleCallback(Handler.java:733)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:136)
       at android.app.ActivityThread.main(ActivityThread.java:5476)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:515)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
       at dalvik.system.NativeStart.main(NativeStart.java)

or

    java.lang.RuntimeException: Adding window failed
       at android.view.ViewRootImpl.setView(ViewRootImpl.java:726)
       at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:278)
       at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
       at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3038)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2368)
       at android.app.ActivityThread.access$900(ActivityThread.java:161)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:157)
       at android.app.ActivityThread.main(ActivityThread.java:5356)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:515)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
       at dalvik.system.NativeStart.main(NativeStart.java)
Caused by: android.os.TransactionTooLargeException
       at android.os.BinderProxy.transact(Binder.java)
       at android.view.IWindowSession$Stub$Proxy.addToDisplay(IWindowSession.java:710)
       at android.view.ViewRootImpl.setView(ViewRootImpl.java:715)
       at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:278)
       at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
       at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3038)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2368)
       at android.app.ActivityThread.access$900(ActivityThread.java:161)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:157)
       at android.app.ActivityThread.main(ActivityThread.java:5356)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:515)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
       at dalvik.system.NativeStart.main(NativeStart.java)
user1026605
  • 1,633
  • 4
  • 22
  • 58
  • This is coming from a `Toast` that you or somebody is showing. Are you showing any `Toasts`? Are any more complicated than just a short string? – CommonsWare Oct 15 '14 at 15:43
  • Yes I'm using some SpannableString content in some Toast messages: SpannableString span = new SpannableString(builder.toString()); if (!isEmptyErrorMessage) { span.setSpan(new ForegroundColorSpan(this.service.getResources().getColor(R.color.orange_logo)), pos, builder.toString().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); span.setSpan(new StyleSpan(Typeface.BOLD), pos, builder.toString().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } But the result doesn't exceed 200 characters – user1026605 Oct 15 '14 at 15:53
  • In fact I added a second stacktrace which happen way more often than the 1st one. Still only on Samsung devices... – user1026605 Oct 15 '14 at 16:25
  • "Do you know a specific bug in the latest Samsung ROM?" You have statistically proven that there is one. - As far as I understand it, that 1MB transaction buffer will have to keep all data buffered while the transaction isn't finished, like this case: http://stackoverflow.com/a/16895870/995891 . So maybe something isn't cleaning up correctly on those devices, leaving only a smaller buffer than usual and your app just happens to use more than that. There is maybe a chance to see what is using the buffer with a heap dump, though IPC buffer is probably in native code. – zapl Oct 25 '14 at 10:50
  • What is your question exactly? – Virus Oct 25 '14 at 17:17
  • My question is just "Do you know where this issue is coming from and how to fix it?" – user1026605 Oct 25 '14 at 21:42
  • I have the same issue but all the reports only show that it is happening in only one version of OS android 4.4, seems to me its not an issue with Binder but one particular ROM that isn't doing something right. Question is do you for this exception that maybe Samsung didn't add or handle some C library properly? – JPM Sep 18 '15 at 20:52
  • Possible duplicate of [What to do on TransactionTooLargeException](http://stackoverflow.com/questions/11451393/what-to-do-on-transactiontoolargeexception) – petey Sep 28 '16 at 15:44

3 Answers3

1

Please check the answer provided here at stack overflow.

Durairaj Packirisamy answered the same question of TransactionTooLarge error which is below.

Durairaj Packirisamy says:-

I encountered this issue, and I found that when there huge amount of data getting exchanged between a service and an application,(This involves transferring lots of thumbnails). Actually data size was around 500kb, and the IPC transaction buffer size is set to 1024KB. I am not sure why it exceeded the transaction buffer.

This also can occur, when you pass lot of data through intent extras

When you get this exception in your application, please analyze your code.

Are you exchanging lot of data between your services and application? Using intents to share huge data, (for example, the user selects huge number of files from gallery share press share, the URIs of the selected files will be transferred using intents) receiving bitmap files from service waiting for android to respond back with huge data (for example, getInstalledApplications() when the user installed lot of applications) using applyBatch() with lot of operations pending How to handle when you get this exception

If possible, split the big operation in to small chunks, for example, instead of calling applyBatch() with 1000 operations, call it with 100 each.

Do not exchange huge data (>1MB) between services and application

I don't know how to do this, but, Do not query android, which can return huge data :-)


Me:- Recently I also encountered this problem. My issue was I was copying videos from raw folder to sd card and then creating its thumbnail and after it showing on list view. This whole process was performed on single thread and exception was thrown. I resolved this problem by separating the whole process of copying video from raw folder to sdcard, creating thumb nail and showing on list. These all there action was performed on 3 different threads and my problem was resolved.

Please let me know if it helps you.

Community
  • 1
  • 1
Abhinav Singh Maurya
  • 3,313
  • 8
  • 33
  • 51
0

I think you need to take a look at TransactionTooLargeException Class Overview

Ibrahim Disouki
  • 2,642
  • 4
  • 21
  • 52
0

I also got TransactionTooLargeException on Samsung devices. I was transferring too huge html data in intent extras but now i resolved this by reducing huge amount data .

When you got TransactionTooLargeException exception in your application, please check your code. Avoid huge data in intent extras.

Devraj Singh
  • 447
  • 4
  • 6