返回活动时,我遇到了应用崩溃的麻烦.
I'm having trouble with an app crashing when returning to the activity.
如果我使用主页按钮导航,则会根据生命周期调用电话(或仿真器)onPause,onSaveInstanceState和onStop:
If I navigate away with the home button the phone (or emulator) onPause, onSaveInstanceState, and onStop are all called as per the lifecycle:
05-05 14:12:20.790 2043-2043/? I/myview: onPause was run 05-05 14:12:20.790 2043-2043/? I/myview: onSaveInstanceState was run 05-05 14:12:20.790 2043-2043/? I/myview: onStop was run活动中的代码:
@Override protected void onPause(){ super.onPause(); Log.i("myview", "onPause was run"); } @Override protected void onStop(){ super.onStop(); Log.i("myview", "onStop was run"); } @Override public void onSaveInstanceState(Bundle savedInstanceState) { // Always call the superclass so it can save the view hierarchy state super.onSaveInstanceState(savedInstanceState); Log.i("myview", "onSaveInstanceState was run"); }但是,在十秒钟后,将报告以下内容:
However after ten seconds the following is reported:
05-05 14:12:31.420 1586-1601/? W/ActivityManager: Activity stop timeout for ActivityRecord{9d354dc0 u0 com.example.gavin.youdrowned/.MainActivity t2} 05-05 14:12:31.420 1586-1601/? I/ActivityManager: Activity reported stop, but no longer stopping: ActivityRecord{9d354dc0 u0 com.example.gavin.youdrowned/.MainActivity t2}我可以导航回该活动,但是不会调用onResume或onCreate.
I'm able to navigate back to the activity, but onResume or onCreate are not called.
该应用程序将按预期全屏运行,直到我尝试与其进行交互.点击/单击屏幕会导致大约5秒钟左右发生以下错误:
The app runs full screen as expected until I try to interact with it. Tap/Clicking on the screen causes the following error to occur after about 5 seconds or so:
05-05 14:12:31.420 1586-1601/? E/ActivityManager: ANR in com.example.gavin.youdrowned (com.example.gavin.youdrowned/.MainActivity) PID: 2043 Reason: Input dispatching timed out (Waiting because the touched window has not finished processing the input events that were previously delivered to it.) Load: 0.54 / 0.13 / 0.04 CPU usage from 2796ms to -2455ms ago: 86% 2043/com.example.gavin.youdrowned: 11% user + 74% kernel / faults: 193 minor 1 major 49% 1586/system_server: 0.1% user + 48% kernel / faults: 874 minor 2% 1162/surfaceflinger: 0% user + 2% kernel / faults: 7 minor 0.1% 1160/debuggerd: 0.1% user + 0% kernel / faults: 3473 minor 12 major 0.3% 1165/mediaserver: 0% user + 0.3% kernel / faults: 15 minor 0.3% 1173/adbd: 0% user + 0.3% kernel / faults: 216 minor 0.3% 1938/com.google.android.gms: 0% user + 0.3% kernel / faults: 62 minor 0.1% 1186/logcat: 0% user + 0.1% kernel 0.1% 1708/com.google.android.gms.persistent: 0% user + 0.1% kernel / faults: 22 minor 0.1% 1746/com.android.phone: 0.1% user + 0% kernel / faults: 98 minor +0% 2373/com.google.android.gms.ui: 0% user + 0% kernel 71% TOTAL: 7.8% user + 63% kernel CPU usage from 1945ms to 2451ms later: 98% 1586/system_server: 0% user + 98% kernel / faults: 1 minor 96% 1622/Thread-35: 0% user + 96% kernel 1.9% 1601/ActivityManager: 0% user + 1.9% kernel 98% 2043/com.example.gavin.youdrowned: 12% user + 86% kernel / faults: 4 minor 98% 2088/Thread-62: 12% user + 86% kernel +0% 2401/AudioTrack: 0% user + 0% kernel 1.6% 1162/surfaceflinger: 0% user + 1.6% kernel 100% TOTAL: 6% user + 94% kernelonResume从未被调用过,并且onStop超时似乎表明触摸事件背后的ANR错误不是主要问题,但是onStop除了记录它被调用的日志外没有任何作用.
The onResume never being called and the onStop timeout seems to indicate the ANR error on the back of the touch event isn't the main issue, however the onStop does no work other than a log to say it was called.
我不确定是什么原因导致此问题或在哪里寻找它进行调试,任何见识都将不胜感激.
I'm not sure what's causing this issue or where to look to debug it and any insight would be greatly appreciated.
推荐答案经过数月的开关量猜测之后:
After months of on-off power guessing changing:
holder.getSurface().unlockCanvasAndPost(c);到
holder.unlockCanvasAndPost(c);在管理屏幕更新的代码中,似乎已解决了此问题.
In the code that manages screen updates seems to have fixed this problem.
更多推荐
尽管不进行操作,Android onStop仍超时
发布评论