java.lang.AssertionError: Binder ProxyMap has too many entries: 问题处理

发布于:2025-05-01 ⋅ 阅读:(57) ⋅ 点赞:(0)

异常栈:

*** Uncaught remote exception!  (Exceptions are not yet supported across processes.)
java.lang.AssertionError: Binder ProxyMap has too many entries: 21562 (total), 21560 (uncleared), 19487 (uncleared after GC). BinderProxy leak?
at android.os.BinderProxy$ProxyMap.set(BinderProxy.java:229)
at android.os.BinderProxy.getInstance(BinderProxy.java:422)
at android.os.Parcel.nativeReadStrongBinder(Native Method)
at android.os.Parcel.readStrongBinder(Parcel.java:2506)
at android.view.accessibility.IAccessibilityManager$Stub.onTransact(IAccessibilityManager.java:289)
at android.os.Binder.execTransactInternal(Binder.java:1159)
at android.os.Binder.execTransact(Binder.java:1123)

抛出位置

            if (size >= mWarnBucketSize) {
                final int totalSize = size();
                Log.v(Binder.TAG, "BinderProxy map growth! bucket size = " + size
                        + " total = " + totalSize);
                mWarnBucketSize += WARN_INCREMENT;
                if (Build.IS_DEBUGGABLE && totalSize >= CRASH_AT_SIZE) {
                    // Use the number of uncleared entries to determine whether we should
                    // really report a histogram and crash. We don't want to fundamentally
                    // change behavior for a debuggable process, so we GC only if we are
                    // about to crash.
                    final int totalUnclearedSize = unclearedSize();
                    if (totalUnclearedSize >= CRASH_AT_SIZE) {
                        dumpProxyInterfaceCounts();
                        dumpPerUidProxyCounts();
                        Runtime.getRuntime().gc();
                        throw new AssertionError("Binder ProxyMap has too many entries: "
                                + totalSize + " (total), " + totalUnclearedSize + " (uncleared), "
                                + unclearedSize() + " (uncleared after GC). BinderProxy leak?");
                    } else if (totalSize > 3 * totalUnclearedSize / 2) {
                        Log.v(Binder.TAG, "BinderProxy map has many cleared entries: "
                                + (totalSize - totalUnclearedSize) + " of " + totalSize
                                + " are cleared");
                    }
                }
            }

原因:BinderProxy 代理过多
看logcat

2025-04-25 [23:20:21:048]04-25 11:20:18.222   785   856 V Binder  : BinderProxy descriptor histogram (top 10):
2025-04-25 [23:20:21:048]04-25 11:20:18.222   785   856 V Binder  :  #1: android.view.accessibility.IAccessibilityManagerClient x17672
2025-04-25 [23:20:21:048]04-25 11:20:18.222   785   856 V Binder  :  #2: android.content.IIntentReceiver x394
2025-04-25 [23:20:21:392]04-25 11:20:18.222   785   856 V Binder  :  #3: <cleared weak-ref> x160
2025-04-25 [23:20:21:392]04-25 11:20:18.222   785   856 V Binder  :  #4:  x114
2025-04-25 [23:20:21:392]04-25 11:20:18.222   785   856 V Binder  :  #5: android.database.IContentObserver x114
2025-04-25 [23:20:21:392]04-25 11:20:18.222   785   856 V Binder  :  #6: android.content.IContentProvider x102
2025-04-25 [23:20:21:392]04-25 11:20:18.222   785   856 V Binder  :  #7: android.view.IWindow x48
2025-04-25 [23:20:21:392]04-25 11:20:18.222   785   856 V Binder  :  #8: android.app.IServiceConnection x38
2025-04-25 [23:20:21:392]04-25 11:20:18.222   785   856 V Binder  :  #9: android.app.IApplicationThread x36
2025-04-25 [23:20:21:392]04-25 11:20:18.223   785   856 V Binder  :  #10: android.hardware.display.IDisplayManagerCallback x36
2025-04-25 [23:20:21:392]04-25 11:20:18.223   785   856 D Binder  : Per Uid Binder Proxy Counts:
2025-04-25 [23:20:21:392]04-25 11:20:18.223   785   856 D Binder  : UID : 1000  count = 12125
2025-04-25 [23:20:21:392]04-25 11:20:18.223   785   856 D Binder  : UID : 1002  count = 51
2025-04-25 [23:20:21:392]04-25 11:20:18.223   785   856 D Binder  : UID : 1041  count = 23
2025-04-25 [23:20:21:392]04-25 11:20:18.223   785   856 D Binder  : UID : 1068  count = 3
2025-04-25 [23:20:21:392]04-25 11:20:18.223   785   856 D Binder  : UID : 10016  count = 3
2025-04-25 [23:20:21:392]04-25 11:20:18.223   785   856 D Binder  : UID : 10038  count = 3
2025-04-25 [23:20:21:392]04-25 11:20:18.224   785   856 D Binder  : UID : 10040  count = 214
2025-04-25 [23:20:21:392]04-25 11:20:18.224   785   856 D Binder  : UID : 10042  count = 29
2025-04-25 [23:20:21:392]04-25 11:20:18.224   785   856 D Binder  : UID : 10043  count = 19
2025-04-25 [23:20:21:392]04-25 11:20:18.224   785   856 D Binder  : UID : 10045  count = 50
2025-04-25 [23:20:21:392]04-25 11:20:18.224   785   856 D Binder  : UID : 10047  count = 76
2025-04-25 [23:20:21:392]04-25 11:20:18.224   785   856 D Binder  : UID : 10049  count = 36
2025-04-25 [23:20:21:392]04-25 11:20:18.224   785   856 D Binder  : UID : 10052  count = 52
2025-04-25 [23:20:21:392]04-25 11:20:18.224   785   856 D Binder  : UID : 10054  count = 5
2025-04-25 [23:20:21:392]04-25 11:20:18.224   785   856 D Binder  : UID : 10065  count = 37
2025-04-25 [23:20:21:392]04-25 11:20:18.224   785   856 D Binder  : UID : 10069  count = 20
2025-04-25 [23:20:21:392]04-25 11:20:18.224   785   856 D Binder  : UID : 10078  count = 30
2025-04-25 [23:20:21:392]04-25 11:20:18.224   785   856 D Binder  : UID : 10086  count = 5
2025-04-25 [23:20:21:392]04-25 11:20:18.224   785   856 D Binder  : UID : 10088  count = 6001
2025-04-25 [23:20:21:392]04-25 11:20:18.224   785   856 D Binder  : UID : 10089  count = 30
2025-04-25 [23:20:21:392]04-25 11:20:18.224   785   856 D Binder  : UID : 10091  count = 7
2025-04-25 [23:20:21:392]04-25 11:20:18.224   785   856 D Binder  : UID : 10094  count = 8
2025-04-25 [23:20:21:392]04-25 11:20:18.224   785   856 D Binder  : UID : 10095  count = 9

其中android.view.accessibility.IAccessibilityManagerClient占用过多
从Android源码发现Toast中使用了这个类
猜测Toast调用过多导致

结论

移除过多的Toast显示,问题解决


网站公告

今日签到

点亮在社区的每一天
去签到