1. Find the anomaly from the main log as follows:
08-20 11:05:19.754 5023 5023 e androidruntime:fatal exception:main08-20 11:05:19.754 5023 5023 e Androidruntime:pro Cess:com.android.bluetooth, pid:502308-20 11:05:19.754 5023 5023 E AndroidRuntime:java.lang.RuntimeException:Unable To start receiver com.android.bluetooth.opp.BluetoothOppHandoverReceiver:java.lang.RuntimeException:Adding window failed08-20 11:05:19.754 5023 5023 E androidruntime:at android.app.ActivityThread.handleReceiver (Activitythread.java : 2913) 08-20 11:05:19.754 5023 5023 E androidruntime:at android.app.activitythread.access$1700 (ActivityThread.java : 177) 08-20 11:05:19.754 5023 5023 E androidruntime:at android.app.activitythread$h.handlemessage (ActivityThread.java : 1611) 08-20 11:05:19.754 5023 5023 E androidruntime:at android.os.Handler.dispatchMessage (handler.java:111) 08-20 11:05:19.754 5023 5023 e androidruntime:at android.os.Looper.loop (looper.java:194) 08-20 11:05:19.754 5023 5023 E Android Oidruntime:at Android.app.ActivityThread.main (Activitythread.java:5733) 08-20 11:05:19.754 5023 5023 E androidruntime:at java.lang.reflect.Method.invoke (Native Method) 08-20 11:05:19.754 5023 5023 E androidruntime:at java.lang.reflect.Method.invoke (method.java:372) 08-20 11:05:19.754 5023 5023 E androidruntime:at com.android.internal.os.zygoteinit$methodandargscaller.run ( zygoteinit.java:959) 08-20 11:05:19.754 5023 5023 E androidruntime:at com.android.internal.os.ZygoteInit.main ( zygoteinit.java:754) 08-20 11:05:19.754 5023 5023 E androidruntime:caused by:java.lang.RuntimeException:Adding window failed08-20 11:05:19.754 5023 5023 E androidruntime:at android.view.ViewRootImpl.setView (viewrootimpl.java:668) 08-20 11:05:19.754 5023 5023 E androidruntime:at android.view.WindowManagerGlobal.addView (windowmanagerglobal.java:289) 08-20 11:05:19.754 5023 5023 E androidruntime:at android.view.WindowManagerImpl.addView (windowmanagerimpl.java:85) 08-20 11:05:19.754 5023 5023 E androidruntime:at android.app.Dialog.show (Dialog.java:311) 08-20 11:05:19.754 5023 5023 E androidruntime:at android.app.AlertDialog.show (alertdialog.java:1127) 08-20 11:05:19.754 5023 5023 E androidruntime:at com.android.bluetooth.opp.MzBluetoothTurnOffPromptDialog.showDialog (mzbluetoothturnoffpromptdialog.java:64) 08-20 11:05:19.754 5023 5023 E androidruntime:at Com.android.bluetooth.opp.BluetoothOppHandoverReceiver.onReceive (bluetoothopphandoverreceiver.java:251) 08-20 11:05:19.754 5023 5023 E androidruntime:at android.app.ActivityThread.handleReceiver (activitythread.java:2906) 08-20 11:05:19.754 5023 5023 E androidruntime: ... 9 more08-20 11:05:19.754 5023 5023 E androidruntime:caused by:android.os.transactiontoolargeexception08-20 11:05:19.75 4 5023 5023 e androidruntime:at android.os.BinderProxy.transactNative (Native Method) 08-20 11:05:19.754 5023 5023 E an Droidruntime:at android.os.BinderProxy.transact (binder.java:504) 08-20 11:05:19.754 5023 5023 E androidruntime:at Android Oid.view.iwindowsession$stub$proxy. Addtodisplay (iwindowsession.java:768) 08-20 11:05:19.754 5023 5023 E androidruntime:at Android.view.ViewRootImpl.setView (viewrootimpl.java:657) 08-20 11:05:19.754 5023 5023 E androidruntime: ... More
It can be seen that binder communication is thrown out of atransactiontoolargeexception Abnormal results, we need to use kernel log to further locate the problem.
2. Search for the keyword "5023" and "binder" from the kernel log as follows:
Line 5:line 18110: <6>[72111.734216]<0> (2) [1546:binder_9]binder:812:1546-5023 failed due to 5023 no UNU SED fd available (5023:droid.bluetooth fd leak?), -24 line 5:line 18110: <6>[72111.734216]<0> (2) [1546:binder _9]binder:812:1546 to 5023 failed due to 5023 no unused FD available (5023:droid.bluetooth fd leak?), -24 line 6:line 181 Ten: <6>[72111.734216]<0> (2) [1546:binder_9]binder:812:1546 to 5023 failed due to 5023 no unused FD available ( 5023:droid.bluetooth fd leak?), -24 line 6:line 18110: <6>[72111.734216]<0> (2) [1546:binder_9]binder: 812:1546 to 5023 failed due to 5023 no unused FD available (5023:droid.bluetooth fd leak?), -24 line 7:line 18110: <6&G T [72111.734216]<0> (2) [1546:binder_9]binder:812:1546 to 5023 failed due to 5023 no unused FD available (5023:DROID.BL Uetooth fd leak?), -24 line 7:line 18110: <6>[72111.734216]<0> (2) [1546:binder_9]binder:812:1546 to 5023 FAI LED due to 5023 no unused FD Available (5023:droid.bluetooth fd leak?), -24 line 8:line 18112: <6>[72111.734239]<0> (2) [1546:binder_9] Binder:send failed reply for transaction 5183251 to 5023:5023 line 8:line 18112: <6>[72111.734239]<0> (2) [15 46:binder_9]binder:send failed reply for transaction 5183251 to 5023:5023 line 9:line 18112: <6>[72111.734239]< 0> (2) [1546:binder_9]binder:send failed reply for transaction 5183251-5023:5023 line 9:line 18112: <6>[72111 .734239]<0> (2) [1546:binder_9]binder:send failed reply for transaction 5183251-5023:5023 line 10:line 18114: &L T;3>[72111.734447]<0> (1) [5023:droid.bluetooth]binder:read put err 29201 to user 00000000f4f2f708, thread Error 29201:29185 line 21:line 26440: <7>[72131.351513]<1>-(2) [1634:binder_c][1634:binder_c] Sig 9 to [5023 :d Roid.bluetooth] stat=x line 21:line 26440: <7>[72131.351513]<1>-(2) [1634:binder_c][1634:binder_c] Sig 9 To [5023:droid.bluetooth] Stat=x
It can be seen that the binder communication reply times the exception, unable to install the handle.
Corresponding Code:in the driver binder.c file
TARGET_FD = Task_get_unused_fd_flags (Target_proc, o_cloexec), if (TARGET_FD < 0) {fput (file); #ifdef Mtk_binder_ Debugbinder_user_error ("%d:%d to%d failed due to%d no unused FD available (%d:%s fd leak?),%d\n", Proc->pid, THREAD-&G T;pid,target_proc->pid, Target_proc->pid, Target_proc->pid,target_proc->tsk? Target_proc->tsk->comm: "", target_fd); #endifreturn_error = Br_failed_reply;goto err_get_unused_fd_failed;} Task_fd_install (Target_proc, target_fd, file);
3, from the above log we can see is due to binder driver for Bluetooth process installation file handle times a error=24, this type of error indicates that the caller process opened a file handle too many, can not create a handle. This time the handle passed in the binder communication cannot be installed into the caller process.In turn, binder communication failed, but the upper layer on the binder driver returned the wrong type did not do a special subdivision processing, directly cast aTransactiontoolargeexception Exception, so the general reporttransactiontoolargeexception type error is required for further positioning with the kernel log. Many people think that the transactiontoolargeexception of the binder in the transfer of data is too large, in fact, it is not the case.
4. Why?Addtodisplaywhenwill pass the handle? We knowUpper RoadApply Add window to Windowmanagerservice is the tuneAddtodisplay interface, Windowmanagerservice to create a socket for each newly added window, generating two handles, respectively, the socket read and write end, Socket write end is passed to Inputdispatcher,socthe KET read end will beThis binder transfer reply is returned to the application process.
5, the next thing is to check the handle leaked, the following two commands can be used. Do stress tests and then "ls-l" at intervals to see which handles are constantly rising.
Cd/proc/pid/fd/ls-l
6.finally found that Bluetooth transmission less than 3M files will result in a socket leak.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Analysis and summary of android.os.TransactionTooLargeException anomaly of Bluetooth pressure test report