大家。我遇到了一个令人担忧的ANR问题。
在Log中,我的ActivityA启动ActivityB,然后ActivityA转到onPause()和onStop()方法。在onStop()完成大约10秒后,ActivityManagerService打印出:
Activity stop timeout for ActivityRecord{ActivityA}
Activity reported stop, but no longer stopping: ActivityRecord{ActivityA}
然后我的ActivityA会被切片很长一段时间。如果我在此期间输入了某些内容,则会显示ANR对话框。
我确信ActivityA每次都会在onStop()方法的最后一行打印消息。所以onStop()方法应该已经完成了。
为什么ActivityManagerService仍会打印这些信息?为什么ActivityA会出现ANR问题?
traces.txt中的主要线程(我希望它会有所帮助):
"main" prio=5 tid=1 WAIT
| group="main" sCount=1 dsCount=0 obj=0x2cb39ca8 self=0x2cb26390
| sysTid=3811 nice=0 sched=0/0 cgrp=[fopen-error:2] handle=721600852
| state=S schedstat=( 0 0 0 ) utm=74 stm=17 core=2
at java.lang.Object.wait(Native Method)
- waiting on <0x2cb39d78> (a java.lang.VMThread) held by tid=1 (main)
at java.lang.Thread.parkFor(Thread.java:1205)
at sun.misc.Unsafe.park(Unsafe.java:325)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:813)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:846)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1175)
at java.util.concurrent.locks.ReentrantLock$NonfairSync.lock(ReentrantLock.java:180)
at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:256)
at android.view.SurfaceView.updateWindow(SurfaceView.java:555)
at android.view.SurfaceView.onWindowVisibilityChanged(SurfaceView.java:234)
at android.view.View.dispatchWindowVisibilityChanged(View.java:8004)
at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1077)
at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1077)
at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1077)
at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1077)
at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1077)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1237)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5670)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
at android.view.Choreographer.doCallbacks(Choreographer.java:574)
at android.view.Choreographer.doFrame(Choreographer.java:544)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5030)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)