Android跨进程调用,Binder线程池溢出导致ANR

Android跨进程调用,Binder线程池溢出导致ANR

如果发生ANR,找到trace.txt 、/data/anr目录下,

json 复制代码
"main" prio=5 tid=1 Native
  | group="main" sCount=1 dsCount=0 flags=1 obj=0x72c33e38 self=0x78a64c2a00
  | sysTid=1863 nice=0 cgrp=default sched=0/0 handle=0x792b5f49a8
  | state=S schedstat=( 2587940558080 1667956760666 8922333 ) utm=201251 stm=57543 core=7 HZ=100
  | stack=0x7fd02c9000-0x7fd02cb000 stackSize=8MB
  | held mutexes=
  kernel: (couldn't read /proc/self/task/1863/stack)
  native: #00 pc 000000000007a2c4  /system/lib64/libc.so (__ioctl+4)
  native: #01 pc 0000000000027a34  /system/lib64/libc.so (ioctl+132)
  native: #02 pc 0000000000058458  /system/lib64/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+252)
  native: #03 pc 000000000005912c  /system/lib64/libbinder.so (android::IPCThreadState::waitForResponse(android::Parcel*, int*)+60)
  native: #04 pc 0000000000058f68  /system/lib64/libbinder.so (android::IPCThreadState::transact(int, unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+216)
  native: #05 pc 000000000004f3ec  /system/lib64/libbinder.so (android::BpBinder::transact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+72)
  native: #06 pc 0000000000127890  /system/lib64/libandroid_runtime.so (???)
  native: #07 pc 000000000093b1e4  /system/framework/arm64/boot-framework.oat (Java_android_os_BinderProxy_transactNative__ILandroid_os_Parcel_2Landroid_os_Parcel_2I+196)
  at android.os.BinderProxy.transactNative(Native method)
  at android.os.BinderProxy.transact(Binder.java:769)
  at android.app.IActivityManager$Stub$Proxy.getCurrentUser(IActivityManager.java:7528)
  at android.app.ActivityManager.getCurrentUser(ActivityManager.java:4081)

sysTid=1863是进程号,ANR发生在at android.os.BinderProxy.transactNative(Native method),在transcatNative函数中,transcatNative 函数式客户端发起端的函数,猜测这是Binder卡住,客户端等待响应中,

我们可以去查看针对性的binder运行日志

cat transactions这个文件来查看运行状况的,

这个地方连续出现thread很多次,猜测是binder线程池耗尽了

这种问题基本上就是我们在跨进程通信调用服务端的时候太频繁了,大部分原因是由于业务逻辑,才会写这种代码,解决办法就是降低调用的频率,或者延迟调用,设置一些时间间隔,app端不要频繁调用服务端。

相关推荐
齊家治國平天下6 小时前
Android 14 Input 事件派发机制深度剖析
android·input·hal
2501_916013747 小时前
iOS 推送开发完整指南,APNs 配置、证书申请、远程推送实现与上架调试经验分享
android·ios·小程序·https·uni-app·iphone·webview
李艺为9 小时前
非预置应用使用platform签名并且添加了android.uid.system无法adb安装解决方法
android·adb
李宥小哥11 小时前
C#基础11-常用类
android·java·c#
Jerry16 小时前
Compose 中的绘制功能简介
android
我科绝伦(Huanhuan Zhou)17 小时前
【脚本升级】银河麒麟V10一键安装MySQL9.3.0
android·adb
消失的旧时光-194317 小时前
Android回退按钮处理方法总结
android·开发语言·kotlin
叫我龙翔18 小时前
【MySQL】从零开始了解数据库开发 --- 数据表的约束
android·c++·mysql·数据库开发
2501_9160137418 小时前
iOS 上架 App 全流程实战,应用打包、ipa 上传、App Store 审核与工具组合最佳实践
android·ios·小程序·https·uni-app·iphone·webview