1. Find the anomaly from the main log, such as the following:
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
Can be seen because binder communication is thrown out of atransactiontoolargeexception Abnormal results, we need to use kernel log to further locate the problem.
2. Search for keyword "5023" and "binder" from the kernel log, for example the following:
Line 5:line 18110: <6>[72111.734216]<0> (2) [1546:binder_9]binder:812:1546-5023 failed due to 5023 no Unus Ed 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 1811 0: <6>[72111.734216]<0> (2) [1546:binder_9]binder:812:1546 to 5023 failed due to 5023 no unused FD available (5 023: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>[72111.734216]<0> (2) [1546:binder_9]binder:812:1546-5023 failed due to 50 Unused FD available (5023:droid.bluetooth fd leak), -24 line 7:line 18110: <6>[72111.734216]<0> (2) [154 6:binder_9]binder:812:1546 to 5023 failed 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 51 83251 to 5023:5023 line 8:line 18112: <6>[72111.734239]<0> (2) [1546:binder_9]binder:send failed reply for TR Ansaction 5183251 to 5023:5023 line 9:line 18112: <6>[72111.734239]<0> (2) [1546: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 to 5023:5023 line 10:line 18114: <3>[72111.734447]<0> (1) [5023:dro Id.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:droid.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
Can see that is binder communication reply times an anomaly. Unable to install handle.
Corresponding Code:Drive in the 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 because binder driver for the Bluetooth process installation file handle times a error=24. This type of error indicates that the caller process has too many file handles open. Can no longer create a handle. This time the handle passed in the binder communication cannot be installed into the caller process.then binder communication failed. But the upper layer of the binder driver returned the wrong type did not do a special subdivision, directly cast aTransactiontoolargeexception Exception. So the general reporttransactiontoolargeexception type error is required to further locate with the kernel log. A very large number of people think that the paper transactiontoolargeexception that the data in this binder transfer is too big, in fact it is not.
4. Why?Addtodisplaywhenwill pass the handle? We knowUpper Roadapply join form to Windowmanagerservice is the tuneAddtodisplay interface is complete, Windowmanagerservice creates a socket for each newly added form, producing two handles. Each is the socket read end and the write end, the socket write end will pass to the 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 the pressure test. Then "Ls-l" for a period of time to see which handles are rising continuously.
Cd/proc/pid/fd/ls-l
6.finally found that Bluetooth transmission less than 3M files will result in a socket leak.
Analysis and summary of the abnormal android.os.TransactionTooLargeException of Bluetooth pressure test report