1:一些基本概念
a: 主线程,子线程的关系,凭什么你是主线程,我是子线程?
其实线程都是一样,只是我们指定了某一线程为主进程而已。
b: 为什么Activity.onCreate,Broadcast.onReceiver,Service.onBind等一系列方法在主线程运行呢?
通过查看以上这些方法调用方,就可以知道答案了。他们都是通过handler消息来处理的
android.app.ActivityThread.H#handleMessage
case RECEIVER:
Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "broadcastReceiveComp");
handleReceiver((ReceiverData)msg.obj);
Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
break;
具体流程参考:
https://www.jianshu.com/p/b114cf78b297
https://blog.csdn.net/renshuguo123723/article/details/86471734
c: 想要监控咱们APP的各种事件消耗的时间,咱们就可以通过监控主线程的handler 的handleMessage消耗的时间来查看。
查看handler代码:
// android.os.Looper#loop
if (logging != null) {
logging.println(">>>>> Dispatching to " + msg.target + " " +
msg.callback + ": " + msg.what);
}
msg.target.dispatchMessage(msg); //分发消息
if (logging != null) {
logging.println("<<<<< Finished to " + msg.target + " " + msg.callback);
}
刚好这个logging对象可以自定义,然后我们重写println方法,通过比较两条消息时间差,就可以得知当前事件的执行时间。
android.os.Looper#setMessageLogging
2:ANR是啥呢?
Android系统中,ActivityManagerService(简称AMS)和WindowManagerService(简称WMS)会检测App的响应时间,如果App在特定时间无法相应屏幕触摸或键盘输入时间,或者特定事件没有处理完毕,就会出现ANR,即Application Not Responding。
3:ANR的种类,产生条件?
在某一事件后的某一时间之后,系统还未做出对应响应,就会产生ANR
事件 | 时间 | 关键日志 |
---|---|---|
用户输入 | 5S | Input event dispatching timed out |
广播 | 前台10S,后台60S | Timeout of broadcast BroadcastRecord |
服务 | 前台10S,后台 | Timeout executing service |
content provider | 10S | Timeout publishing content providers |
为什么是这个时间?
// ActivityTaskManagerService.java API 30
// How long we wait until we timeout on key dispatching.
public static final int KEY_DISPATCHING_TIMEOUT_MS = 5 * 1000;
// ActivityManagerService.java API 30
// How long we allow a receiver to run before giving up on it.
static final int BROADCAST_FG_TIMEOUT = 10*1000;
static final int BROADCAST_BG_TIMEOUT = 60*1000;
// ActiveServices.java API 30
// How long we wait for a service to finish executing.
static final int SERVICE_TIMEOUT = 20*1000;
// How long we wait for a service to finish executing.
static final int SERVICE_BACKGROUND_TIMEOUT = SERVICE_TIMEOUT * 10;
来看个例子,猜猜看,当我们点击button时,会产生ANR吗?:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mViewDataBinding = DataBindingUtil.setContentView(this,
R.layout.activity_main);
mViewDataBinding.button
.setOnClickListener(v -> {
Toast.makeText(this, "dianji", Toast.LENGTH_SHORT).show();
waitTime();
});
}
private void waitTime() {
long start = System.currentTimeMillis();
long end = start;
while (end - start < 8000) {
mViewDataBinding.button.setText(end + "");
end = System.currentTimeMillis();
}
}
注意事项: Input的超时机制与其他的不同,对于input来说即便某次事件执行时间超过timeout时长,只要用户后续在没有再生成输入事件,则不会触发ANR.
----- pid 6416 at 2021-05-31 01:25:26 -----
Cmd line: com.example.myapplication
DALVIK THREADS (16):
"main" prio=5 tid=1 Runnable
| group="main" sCount=0 dsCount=0 flags=0 obj=0x70e9ac28 self=0xe6cc5410
| sysTid=6416 nice=-10 cgrp=top-app sched=0/0 handle=0xf525b478
| state=R schedstat=( 7028777690 179773124 1205 ) utm=23 stm=679 core=3 HZ=100
| stack=0xff6af000-0xff6b1000 stackSize=8192KB
| held mutexes= "mutator lock"(shared held)
at com.example.myapplication.MainActivity.waitTime(MainActivity.java:31)
at com.example.myapplication.MainActivity.lambda$onCreate$0$MainActivity(MainActivity.java:24)
at com.example.myapplication.-$$Lambda$MainActivity$jRtpOGtrw8cqMNyhtDGNK0XOTPE.onClick(lambda:-1)
at android.view.View.performClick(View.java:7448)
at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:967)
at android.view.View.performClickInternal(View.java:7425)
at android.view.View.access$3600(View.java:810)
at android.view.View$PerformClick.run(View.java:28305)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
再来看看监控信息:
Looper.getMainLooper().setMessageLogging(new Printer() {
//分发和处理消息开始前的log
private static final String START = ">>>>> Dispatching";
//分发和处理消息结束后的log
private static final String END = "<<<<< Finished";
@Override
public void println(String x) {
if (x.startsWith(START)) {
//开始计时
BlockMonitor.getInstance().startMonitor();
}
if (x.startsWith(END)) {
//结束计时
BlockMonitor.getInstance().removeMonitor();
}
}
});
public class BlockMonitor {
private static final String TAG = "=====BlockMonitor=====";
private static final BlockMonitor sInstance = new BlockMonitor();
private final Handler mHandler;
//方法耗时的卡口,500毫秒
private static final long TIME_BLOCK = 500L;
private int mCount;
private BlockMonitor() {
HandlerThread logThread = new HandlerThread("BlockMonitor");
logThread.start();
mHandler = new Handler(logThread.getLooper());
}
private final Runnable mLogRunnable = new Runnable() {
@Override
public void run() {
//继续检测
startMonitor();
mCount++;
//打印出执行的耗时方法的栈消息
StackTraceElement[] stackTrace = Looper.getMainLooper().getThread().getStackTrace();
StringBuilder sb = new StringBuilder();
for (StackTraceElement s : stackTrace) {
sb.append(s.toString());
sb.append("\n");
}
String s = sb.toString();
Log.e(BlockMonitor.TAG, "mCount--- " + mCount + s);
}
};
public static BlockMonitor getInstance() {
return sInstance;
}
/**
* 开始计时
*/
public void startMonitor() {
mHandler.postDelayed(mLogRunnable, TIME_BLOCK);
}
/**
* 停止计时
*/
public void removeMonitor() {
mHandler.removeCallbacks(mLogRunnable);
mCount = 0;
}
}
代码来源:https://blog.csdn.net/itobot/article/details/88930669
2021-05-31 09:26:33.915 6646-6697/com.example.myapplication E/=====BlockMonitor=====: mCount--- 14java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:542)
java.lang.StringBuilder.append(StringBuilder.java:176)
java.lang.StringBuilder.append(StringBuilder.java:77)
android.icu.impl.CaseMapImpl.appendUnchanged(CaseMapImpl.java:407)
android.icu.impl.CaseMapImpl.internalToUpper(CaseMapImpl.java:591)
android.icu.impl.CaseMapImpl.toUpper(CaseMapImpl.java:650)
android.icu.text.CaseMap$Upper.apply(CaseMap.java:170)
android.text.TextUtils.toUpperCase(TextUtils.java:1198)
android.text.method.AllCapsTransformationMethod.getTransformation(AllCapsTransformationMethod.java:66)
android.widget.TextView.setText(TextView.java:6268)
android.widget.TextView.setText(TextView.java:6139)
android.widget.TextView.setText(TextView.java:6091)
com.example.myapplication.MainActivity.waitTime(MainActivity.java:32)
com.example.myapplication.MainActivity.lambda$onCreate$0$MainActivity(MainActivity.java:24)
com.example.myapplication.-$$Lambda$MainActivity$jRtpOGtrw8cqMNyhtDGNK0XOTPE.onClick(Unknown Source:2)
android.view.View.performClick(View.java:7448)
com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:967)
android.view.View.performClickInternal(View.java:7425)
android.view.View.access$3600(View.java:810)
android.view.View$PerformClick.run(View.java:28305)
android.os.Handler.handleCallback(Handler.java:938)
android.os.Handler.dispatchMessage(Handler.java:99)
android.os.Looper.loop(Looper.java:223)
android.app.ActivityThread.main(ActivityThread.java:7656)
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
2021-05-31 09:26:34.417 6646-6697/com.example.myapplication E/=====BlockMonitor=====: mCount--- 15android.icu.impl.CaseMapImpl.internalToUpper(CaseMapImpl.java:534)
android.icu.impl.CaseMapImpl.toUpper(CaseMapImpl.java:650)
android.icu.text.CaseMap$Upper.apply(CaseMap.java:170)
android.text.TextUtils.toUpperCase(TextUtils.java:1198)
android.text.method.AllCapsTransformationMethod.getTransformation(AllCapsTransformationMethod.java:66)
android.widget.TextView.setText(TextView.java:6268)
android.widget.TextView.setText(TextView.java:6139)
android.widget.TextView.setText(TextView.java:6091)
com.example.myapplication.MainActivity.waitTime(MainActivity.java:32)
com.example.myapplication.MainActivity.lambda$onCreate$0$MainActivity(MainActivity.java:24)
com.example.myapplication.-$$Lambda$MainActivity$jRtpOGtrw8cqMNyhtDGNK0XOTPE.onClick(Unknown Source:2)
android.view.View.performClick(View.java:7448)
com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:967)
android.view.View.performClickInternal(View.java:7425)
android.view.View.access$3600(View.java:810)
android.view.View$PerformClick.run(View.java:28305)
android.os.Handler.handleCallback(Handler.java:938)
android.os.Handler.dispatchMessage(Handler.java:99)
android.os.Looper.loop(Looper.java:223)
android.app.ActivityThread.main(ActivityThread.java:7656)
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
再来看个等锁:
public class MainActivity extends AppCompatActivity {
private static final String TAG = "MainActivity--";
private ActivityMainBinding mViewDataBinding;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mViewDataBinding = DataBindingUtil.setContentView(this,
R.layout.activity_main);
mViewDataBinding.button
.setOnClickListener(v -> {
toast2();
});
new Thread() {
@Override
public void run() {
super.run();
toast1();
}
}.start();
}
public synchronized void toast1() {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
public synchronized void toast2() {
Toast.makeText(this, "hahaha", Toast.LENGTH_SHORT).show();
}
}
----- pid 7736 at 2021-05-31 02:54:05 -----
Cmd line: com.example.myapplication
"main" prio=5 tid=1 Blocked
| group="main" sCount=1 dsCount=0 flags=1 obj=0x70e9ac28 self=0xe6cc5410
| sysTid=7736 nice=-10 cgrp=top-app sched=0/0 handle=0xf525b478
| state=S schedstat=( 935875280 95958190 467 ) utm=37 stm=55 core=0 HZ=100
| stack=0xff6af000-0xff6b1000 stackSize=8192KB
| held mutexes=
at com.example.myapplication.MainActivity.toast2(MainActivity.java:-1)
- waiting to lock <0x0d672707> (a com.example.myapplication.MainActivity) held by thread 22
at com.example.myapplication.MainActivity.lambda$onCreate$0$MainActivity(MainActivity.java:23)
at com.example.myapplication.-$$Lambda$MainActivity$jRtpOGtrw8cqMNyhtDGNK0XOTPE.onClick(lambda:-1)
at android.view.View.performClick(View.java:7448)
at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:967)
at android.view.View.performClickInternal(View.java:7425)
at android.view.View.access$3600(View.java:810)
at android.view.View$PerformClick.run(View.java:28305)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
"Thread-2" prio=5 tid=22 Sleeping
| group="main" sCount=1 dsCount=0 flags=1 obj=0x13182d90 self=0xe6cd5e10
| sysTid=7764 nice=0 cgrp=top-app sched=0/0 handle=0xc54bc1e0
| state=S schedstat=( 571026 0 1 ) utm=0 stm=0 core=2 HZ=100
| stack=0xc53b9000-0xc53bb000 stackSize=1040KB
| held mutexes=
at java.lang.Thread.sleep(Native method)
- sleeping on <0x06a79777> (a java.lang.Object)
at java.lang.Thread.sleep(Thread.java:442)
- locked <0x06a79777> (a java.lang.Object)
at java.lang.Thread.sleep(Thread.java:358)
at com.example.myapplication.MainActivity.toast1(MainActivity.java:37)
- locked <0x0d672707> (a com.example.myapplication.MainActivity)
at com.example.myapplication.MainActivity$1.run(MainActivity.java:30)
广播例子:
Process: com.example.myapplication
PID: 8141
UID: 10153
Flags: 0x30e8bf46
Package: com.example.myapplication v1 (1.0)
Foreground: Yes
Process-Runtime: 15023
Subject: Broadcast of Intent { act=android.intent.action.SCREEN_ON flg=0x50200010 }
Build: google/sdk_gphone_x86_arm/generic_x86_arm:11/RSR1.201013.001/6903271:userdebug/dev-keys
----- Output from /proc/pressure/memory -----
some avg10=0.08 avg60=0.07 avg300=0.01 total=3675977
full avg10=0.05 avg60=0.04 avg300=0.00 total=555677
----- End output from /proc/pressure/memory -----
CPU usage from 21530ms to 0ms ago (2021-05-31 03:08:00.773 to 2021-05-31 03:08:22.303):
8% 604/system_server: 0.9% user + 7.1% kernel / faults: 4464 minor 17 major
2.6% 335/surfaceflinger: 0% user + 2.5% kernel / faults: 36 minor 4 major
2.1% 2701/com.google.android.googlequicksearchbox:search: 0.6% user + 1.4% kernel / faults: 5069 minor 3 major
1.9% 304/android.hardware.bluetooth@1.1-service.sim: 0% user + 1.9% kernel
1.6% 314/android.hardware.graphics.composer@2.3-service: 0% user + 1.6% kernel / faults: 2 major
1.3% 866/com.android.systemui: 0.3% user + 1% kernel / faults: 1041 minor 2 major
1.2% 2179/com.google.android.gms: 0.2% user + 0.9% kernel / faults: 2276 minor 6 major
1.1% 1294/com.google.android.gms.persistent: 0.3% user + 0.7% kernel / faults: 1249 minor 4 major
0.9% 170/logd: 0% user + 0.9% kernel / faults: 1 minor 2 major
0.9% 313/android.hardware.graphics.allocator@3.0-service: 0% user + 0.9% kernel
0.6% 355/adbd: 0% user + 0.6% kernel / faults: 285 minor
0.5% 1104/com.google.android.apps.nexuslauncher: 0.1% user + 0.3% kernel / faults: 267 minor
0.3% 216/android.system.suspend@1.0-service: 0% user + 0.2% kernel / faults: 10 minor 3 major
0.3% 322/android.hardware.sensors@2.1-service.multihal: 0% user + 0.3% kernel
0% 846/com.android.bluetooth: 0% user + 0% kernel / faults: 354 minor 11 major
0.3% 1163/com.android.phone: 0% user + 0.2% kernel / faults: 179 minor
0.3% 1626/com.google.process.gservices: 0% user + 0.3% kernel / faults: 353 minor
0.1% 337/logcat: 0% user + 0.1% kernel
0.1% 1472/com.google.android.inputmethod.latin: 0% user + 0.1% kernel / faults: 122 minor 1 major
0.1% 10/rcu_preempt: 0% user + 0.1% kernel
0.1% 171/lmkd: 0% user + 0.1% kernel
0.1% 297/statsd: 0% user + 0.1% kernel
0.1% 8089/logcat: 0% user + 0.1% kernel / faults: 7 minor
0.1% 8096/kworker/u8:4-kverityd: 0% user + 0.1% kernel
0% 1/init: 0% user + 0% kernel / faults: 1 minor
0% 9/ksoftirqd/0: 0% user + 0% kernel
0% 366/traced_probes: 0% user + 0% kernel / faults: 1 minor
0% 16/ksoftirqd/1: 0% user + 0% kernel
0% 21/ksoftirqd/2: 0% user + 0% kernel
0% 26/ksoftirqd/3: 0% user + 0% kernel
0% 172/servicemanager: 0% user + 0% kernel
0% 212/jbd2/dm-5-8: 0% user + 0% kernel
0% 300/zygote: 0% user + 0% kernel / faults: 166 minor
0% 315/android.hardware.health@2.1-service: 0% user + 0% kernel
0% 325/android.hardware.wifi@1.0-service: 0% user + 0% kernel
0% 374/iorapd: 0% user + 0% kernel / faults: 24 minor
0% 380/wificond: 0% user + 0% kernel
0% 2872/com.google.android.ims: 0% user + 0% kernel / faults: 32 minor
0% 4697/com.google.android.googlequicksearchbox:interactor: 0% user + 0% kernel / faults: 16 minor
0% 6833/com.google.android.videos: 0% user + 0% kernel / faults: 9 minor
0% 7353/kworker/3:1-mm_percpu_wq: 0% user + 0% kernel
0% 7365/com.google.process.gapps: 0% user + 0% kernel / faults: 163 minor
0% 7447/kworker/0:1-events: 0% user + 0% kernel
0% 7522/kworker/u8:3-events_unbound: 0% user + 0% kernel
0% 8092/kworker/u8:2-kverityd: 0% user + 0% kernel
+0% 8140/kworker/2:1-events: 0% user + 0% kernel
+0% 8141/com.example.myapplication: 0% user + 0% kernel
18% TOTAL: 1% user + 17% kernel + 0.4% iowait + 0% softirq
----- pid 8141 at 2021-05-31 03:08:22 -----
Cmd line: com.example.myapplication
"main" prio=5 tid=1 Runnable
| group="main" sCount=0 dsCount=0 flags=0 obj=0x70e9ac28 self=0xe6cc5410
| sysTid=8141 nice=-10 cgrp=top-app sched=0/0 handle=0xf525b478
| state=R schedstat=( 11098270485 152588332 1096 ) utm=24 stm=1085 core=0 HZ=100
| stack=0xff6af000-0xff6b1000 stackSize=8192KB
| held mutexes= "mutator lock"(shared held)
at com.example.myapplication.MainActivity.waitTime(MainActivity.java:37)
at com.example.myapplication.MainActivity.access$000(MainActivity.java:14)
at com.example.myapplication.MainActivity$1.onReceive(MainActivity.java:29)
at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0$LoadedApk$ReceiverDispatcher$Args(LoadedApk.java:1556)
at android.app.-$$Lambda$LoadedApk$ReceiverDispatcher$Args$_BumDX2UKsnxLVrE6UJsJZkotuA.run(lambda:-1)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
binder通信 :
Process: com.example.myapplication
PID: 12020
UID: 10153
Flags: 0x30e8bf46
Package: com.example.myapplication v1 (1.0)
Foreground: Yes
Process-Runtime: 10051
Activity: com.example.myapplication/.MainActivity
Subject: Input dispatching timed out (937ec95 com.example.myapplication/com.example.myapplication.MainActivity (server) is not responding. Waited 5002ms for MotionEvent(deviceId=9, source=0x00001002, displayId=0, action=DOWN, actionButton=0x00000000, flags=0x00000000, metaState=0x00000000, buttonState=0x00000000, classification=NONE, edgeFlags=0x00000000, xPrecision=68.3, yPrecision=41.0, xCursorPosition=nan, yCursorPosition=nan, pointers=[0: (53.0, 154.0)]), policyFlags=0x62000000)
Build: google/sdk_gphone_x86_arm/generic_x86_arm:11/RSR1.201013.001/6903271:userdebug/dev-keys
"main" prio=5 tid=1 Native
| group="main" sCount=1 dsCount=0 flags=1 obj=0x70e9ac28 self=0xe6cc5410
| sysTid=12020 nice=-10 cgrp=top-app sched=0/0 handle=0xf525b478
| state=S schedstat=( 879447610 99133049 374 ) utm=36 stm=51 core=3 HZ=100
| stack=0xff6af000-0xff6b1000 stackSize=8192KB
| held mutexes=
native: #00 pc 00000b97 [vdso] (__kernel_vsyscall+7)
native: #01 pc 000cd46c /apex/com.android.runtime/lib/bionic/libc.so (__ioctl+28)
native: #02 pc 00080e6a /apex/com.android.runtime/lib/bionic/libc.so (ioctl+58)
native: #03 pc 00050edb /system/lib/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+331)
native: #04 pc 000522af /system/lib/libbinder.so (android::IPCThreadState::waitForResponse(android::Parcel*, int*)+47)
native: #05 pc 00051fb1 /system/lib/libbinder.so (android::IPCThreadState::transact(int, unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+177)
native: #06 pc 00048de9 /system/lib/libbinder.so (android::BpBinder::transact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+153)
native: #07 pc 0012302f /system/lib/libandroid_runtime.so (android_os_BinderProxy_transact(_JNIEnv*, _jobject*, int, _jobject*, _jobject*, int)+143)
at android.os.BinderProxy.transactNative(Native method)
at android.os.BinderProxy.transact(BinderProxy.java:540)
at android.app.IActivityManager$Stub$Proxy.getContentProvider(IActivityManager.java:5698)
at android.app.ActivityThread.acquireProvider(ActivityThread.java:6813)
- locked <0x079a8838> (a android.app.ActivityThread$ProviderKey)
at android.app.ContextImpl$ApplicationContentResolver.acquireProvider(ContextImpl.java:2916)
at android.content.ContentResolver.acquireProvider(ContentResolver.java:2432)
at android.content.ContentResolver.insert(ContentResolver.java:2143)
at android.content.ContentResolver.insert(ContentResolver.java:2111)
at com.example.myapplication.MainActivity$1.onClick(MainActivity.java:38)
at android.view.View.performClick(View.java:7448)
at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:967)
at android.view.View.performClickInternal(View.java:7425)
at android.view.View.access$3600(View.java:810)
at android.view.View$PerformClick.run(View.java:28305)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
"Binder:604_10" prio=5 tid=122 TimedWaiting
| group="main" sCount=1 dsCount=0 flags=1 obj=0x14702ba0 self=0xbf630210
| sysTid=1798 nice=-10 cgrp=foreground sched=0/0 handle=0xb024a1e0
| state=S schedstat=( 2839200490 1359000443 9706 ) utm=34 stm=249 core=0 HZ=100
| stack=0xb014f000-0xb0151000 stackSize=1008KB
| held mutexes=
at java.lang.Object.wait(Native method)
- waiting on <0x078f07ba> (a com.android.server.am.ContentProviderRecord)
at java.lang.Object.wait(Object.java:442)
at com.android.server.am.ActivityManagerService.getContentProviderImpl(ActivityManagerService.java:7461)
- locked <0x078f07ba> (a com.android.server.am.ContentProviderRecord)
at com.android.server.am.ActivityManagerService.getContentProvider(ActivityManagerService.java:7594)
at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2381)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2883)
at android.os.Binder.execTransactInternal(Binder.java:1154)
at android.os.Binder.execTransact(Binder.java:1123)
2021-05-31 13:49:02.025 604-1798/system_process E/ActivityManager: Timeout waiting for provider com.example.myapplication/10153 for provider com.example.myapplication providerRunning=false caller=com.example.myapplication/10153
2021-05-31 13:49:02.021 604-655/system_process I/ActivityManager: Killing 12020:com.example.myapplication/u0a153 (adj 0): depends on provider com.example.myapplication/.MyProvider in dying proc com.example.myapplication:hahaha (adj 0)
2021-05-31 13:49:02.022 604-655/system_process I/ActivityManager: Killing 12048:com.example.myapplication:hahaha/u0a153 (adj 0): timeout publishing content providers
=====BlockMonitor=====: mCount--- 3android.os.BinderProxy.transactNative(Native Method)
android.os.BinderProxy.transact(BinderProxy.java:540)
android.app.IActivityManager$Stub$Proxy.getContentProvider(IActivityManager.java:5698)
android.app.ActivityThread.acquireProvider(ActivityThread.java:6813)
android.app.ContextImpl$ApplicationContentResolver.acquireProvider(ContextImpl.java:2916)
android.content.ContentResolver.acquireProvider(ContentResolver.java:2432)
android.content.ContentResolver.insert(ContentResolver.java:2143)
android.content.ContentResolver.insert(ContentResolver.java:2111)
com.example.myapplication.MainActivity$1.onClick(MainActivity.java:38)
android.view.View.performClick(View.java:7448)
com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:967)
android.view.View.performClickInternal(View.java:7425)
android.view.View.access$3600(View.java:810)
android.view.View$PerformClick.run(View.java:28305)
android.os.Handler.handleCallback(Handler.java:938)
android.os.Handler.dispatchMessage(Handler.java:99)
android.os.Looper.loop(Looper.java:223)
android.app.ActivityThread.main(ActivityThread.java:7656)
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
网友评论