Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Adding window failed / android.os.TransactionTooLargeException on Samsung devices

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)
like image 694
user1026605 Avatar asked Oct 15 '14 15:10

user1026605


1 Answers

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.

like image 93
Abhinav Singh Maurya Avatar answered Oct 16 '22 16:10

Abhinav Singh Maurya