When ANR occurs for Launcher,dialog pops up and the Launcher resume then. Select OK to restart Launcher after the launcher resume to respond, the rest keys will be dropped.
The problem occurs in my developing environment and it's hard to reproduce.So I do a test for this:
- Create a simple APK as Launcher, and sleep some time in onCreat or onResume to let the ANR occurs
- Start the Launcher and press key to let ANR occurs
- after sleep the view is normally shown behind the ANR dialog select OK to restart launcher, then keys can't be received because the activity can't created
- Dropping event because there is no focused window or focused application
The APK is used on Android4.0 and Android2.2 there is no problem in Android2.2, it looks like a problem on Android 4.03. Log are suppled for the real test issue and the emulate issue in 2.2, 4.03. Plus: I modify the original Launcher2 as well and sleep in onResume, It has no such issue but I can't find any clue.
Any help is appreciated.
Android4.0
09-10 17:29:44.716 W/ActivityManager( 77): Force finishing activity com.example.testanr2/.MainActivity
09-10 17:29:44.716 W/WindowManager( 77): Failure taking screenshot for (180x300) to layer 21005
09-10 17:29:44.736 I/ActivityManager( 77): Clearing package preferred activities from com.example.testanr2
09-10 17:29:44.736 I/ActivityManager( 77): Killing ProcessRecord{415df8d8 2409:com.example.testanr2/10040}: user's request
09-10 17:29:44.756 I/WindowManager( 77): WIN DEATH: Window{41444c48 com.example.testanr2/com.example.testanr2.MainActivity paused=true}
09-10 17:29:44.765 I/ActivityManager( 77): START {act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10000000 cmp=com.example.testanr2/.MainActivity} from pid 0
09-10 17:29:44.786 W/ActivityManager( 77): Exception when starting activity com.example.testanr2/.MainActivity
09-10 17:29:44.786 W/ActivityManager( 77): android.os.DeadObjectException
09-10 17:29:44.786 W/ActivityManager( 77): at android.os.BinderProxy.transact(Native Method)
09-10 17:29:44.786 W/ActivityManager( 77): at android.app.ApplicationThreadProxy.scheduleLaunchActivity(ApplicationThreadNative.java:660)
09-10 17:29:44.786 W/ActivityManager( 77): at com.android.server.am.ActivityStack.realStartActivityLocked(ActivityStack.java:593)
09-10 17:29:44.786 W/ActivityManager( 77): at com.android.server.am.ActivityStack.startSpecificActivityLocked(ActivityStack.java:701)
09-10 17:29:44.786 W/ActivityManager( 77): at com.android.server.am.ActivityStack.resumeTopActivityLocked(ActivityStack.java:1571)
09-10 17:29:44.786 W/ActivityManager( 77): at com.android.server.am.ActivityStack.completePauseLocked(ActivityStack.java:1000)
09-10 17:29:44.786 W/ActivityManager( 77): at com.android.server.am.ActivityStack.activityPaused(ActivityStack.java:928)
09-10 17:29:44.786 W/ActivityManager( 77): at com.android.server.am.ActivityManagerService.activityPaused(ActivityManagerService.java:3957)
09-10 17:29:44.786 W/ActivityManager( 77): at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:371)
09-10 17:29:44.786 W/ActivityManager( 77): at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:1496)
09-10 17:29:44.786 W/ActivityManager( 77): at android.os.Binder.execTransact(Binder.java:338)
09-10 17:29:44.786 W/ActivityManager( 77): at dalvik.system.NativeStart.run(Native Method)
09-10 17:29:44.786 W/ActivityManager( 77): Force removing ActivityRecord{414b0020 com.example.testanr2/.MainActivity}: app died, no saved state
09-10 17:29:44.836 D/dalvikvm( 2438): Not late-enabling CheckJNI (already on)
09-10 17:29:44.855 I/ActivityManager( 77): Start proc com.example.testanr2 for activity com.example.testanr2/.MainActivity: pid=2438 uid=10040 gids={}
09-10 17:29:44.855 I/ActivityManager( 77): Process com.example.testanr2 (pid 2409) has died and restarted (pid 2438).
09-10 17:29:44.855 W/NetworkManagementSocketTagger( 77): setKernelCountSet(10040, 0) failed with errno -2
09-10 17:29:47.562 I/InputDispatcher( 77): Dropping event because there is no touched window or focused application.
09-10 17:29:47.828 I/InputDispatcher( 77): Dropping event because there is no touched window or focused application.
09-10 17:29:47.965 D/dalvikvm( 161): GC_CONCURRENT freed 384K, 6% free 10331K/10951K, paused 7ms+3ms
09-10 17:29:48.135 I/InputDispatcher( 77): Dropping event because there is no touched window or focused application.
09-10 17:29:50.207 I/InputDispatcher( 77): Dropping event because there is no touched window or focused application.
09-10 17:29:50.708 I/InputDispatcher( 77): Dropping event because there is no touched window or focused application.
09-10 17:29:50.991 I/InputDispatcher( 77): Dropping event because there is no touched window or focused application.
09-10 17:29:51.205 I/InputDispatcher( 77): Dropping event because there is no touched window or focused application.
09-10 17:29:51.362 I/InputDispatcher( 77): Dropping event because there is no touched window or focused application.
09-10 17:29:54.746 W/ActivityManager( 77): Launch timeout has expired, giving up wake lock!
09-10 17:29:57.877 I/InputDispatcher( 77): Dropping event because there is no touched window or focused application.
Android2.2
09-10 16:40:32.254 D/PackageManager( 72): New package installed in /data/app/com.example.testanr2-1.apk
09-10 16:40:32.304 D/lixin ( 668): sleep~ in application10
09-10 16:40:32.394 I/ActivityManager( 72): Force stopping package com.example.testanr2 uid=10040
09-10 16:40:32.394 I/Process ( 72): Sending signal. PID: 668 SIG: 9
09-10 16:40:32.414 I/ActivityManager( 72): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10000000 cmp=com.example.testanr2/.MainActivity }
09-10 16:40:32.484 D/dalvikvm( 72): GC_FOR_MALLOC freed 11945 objects / 732440 bytes in 67ms
09-10 16:40:32.484 I/ActivityManager( 72): Start proc com.example.testanr2 for activity com.example.testanr2/.MainActivity: pid=674 uid=10040 gids={}
09-10 16:40:32.604 D/dalvikvm( 198): GC_EXPLICIT freed 2644 objects / 128328 bytes in 105ms
09-10 16:40:32.734 D/dalvikvm( 72): GC_EXPLICIT freed 939 objects / 49752 bytes in 229ms
09-10 16:40:32.734 I/UsageStats( 72): Unexpected resume of com.example.testanr2 while already resumed in com.example.testanr2
09-10 16:40:32.834 W/RecognitionManagerService( 72): no available voice recognition services found
09-10 16:40:32.864 D/lixin ( 674): sleep~ in application10
09-10 16:40:32.915 D/dalvikvm( 72): GC_EXPLICIT freed 2356 objects / 116024 bytes in 77ms
09-10 16:40:32.954 I/installd( 34): unlink /data/dalvik-cache/data@app@com.example.testanr2-2.apk@classes.dex
09-10 16:40:32.984 D/AndroidRuntime( 654): Shutting down VM
09-10 16:40:32.984 D/dalvikvm( 654): Debugger has detached; object registry had 1 entries
09-10 16:40:33.245 D/AndroidRuntime( 684):
09-10 16:40:33.245 D/AndroidRuntime( 684): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
09-10 16:40:33.245 D/AndroidRuntime( 684): CheckJNI is ON
09-10 16:40:33.334 D/AndroidRuntime( 684): --- registering native functions ---
09-10 16:40:33.665 I/ActivityManager( 72): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.testanr2/.MainActivity }
09-10 16:40:33.665 D/AndroidRuntime( 684): Shutting down VM
09-10 16:40:33.665 D/dalvikvm( 684): Debugger has detached; object registry had 1 entries
09-10 16:40:33.674 I/AndroidRuntime( 684): NOTE: attach of thread 'Binder Thread #3' failed
09-10 16:40:34.169 W/ActivityManager( 72): Activity pause timeout for HistoryRecord{45060dd8 com.example.testanr2/.MainActivity}
09-10 16:40:40.057 W/WindowManager( 72): No window to dispatch pointer action 0
09-10 16:40:40.074 W/WindowManager( 72): No window to dispatch pointer action 1
09-10 16:40:40.275 W/WindowManager( 72): No window to dispatch pointer action 0
09-10 16:40:40.314 W/WindowManager( 72): No window to dispatch pointer action 1
09-10 16:40:40.445 W/WindowManager( 72): No window to dispatch pointer action 0
09-10 16:40:40.484 W/WindowManager( 72): No window to dispatch pointer action 1
09-10 16:40:40.528 W/ActivityManager( 72): Launch timeout has expired, giving up wake lock!
09-10 16:40:40.678 W/WindowManager( 72): No window to dispatch pointer action 0
09-10 16:40:40.714 W/WindowManager( 72): No window to dispatch pointer action 1
09-10 16:40:40.864 W/WindowManager( 72): No window to dispatch pointer action 0
09-10 16:40:40.874 W/WindowManager( 72): No window to dispatch pointer action 1
09-10 16:40:41.604 W/WindowManager( 72): No window to dispatch pointer action 0
09-10 16:40:41.637 W/WindowManager( 72): No window to dispatch pointer action 1
09-10 16:40:41.755 W/WindowManager( 72): No window to dispatch pointer action 0
09-10 16:40:41.786 W/WindowManager( 72): No window to dispatch pointer action 1
09-10 16:40:41.936 W/WindowManager( 72): No window to dispatch pointer action 0
09-10 16:40:41.954 W/WindowManager( 72): No window to dispatch pointer action 1
09-10 16:40:42.088 W/WindowManager( 72): No window to dispatch pointer action 0
09-10 16:40:42.124 W/WindowManager( 72): No window to dispatch pointer action 1
09-10 16:40:42.234 W/WindowManager( 72): No window to dispatch pointer action 0
09-10 16:40:42.295 W/WindowManager( 72): No window to dispatch pointer action 1
09-10 16:40:42.404 W/WindowManager( 72): No window to dispatch pointer action 0
09-10 16:40:42.444 W/WindowManager( 72): No window to dispatch pointer action 1
09-10 16:40:42.595 W/WindowManager( 72): No window to dispatch pointer action 0
09-10 16:40:42.614 W/WindowManager( 72): No window to dispatch pointer action 1
09-10 16:40:42.744 W/ActivityManager( 72): Activity idle timeout for HistoryRecord{45060dd8 com.example.testanr2/.MainActivity}
09-10 16:40:42.744 W/WindowManager( 72): No window to dispatch pointer action 0
09-10 16:40:42.754 W/WindowManager( 72): No window to dispatch pointer action 1
09-10 16:40:42.885 W/WindowManager( 72): No window to dispatch pointer action 0
09-10 16:40:42.885 D/lixin ( 674): sleep~ in application10
09-10 16:40:42.926 W/WindowManager( 72): No window to dispatch pointer action 1
09-10 16:40:44.181 W/ActivityManager( 72): Activity idle timeout for HistoryRecord{451b0480 com.example.testanr2/.MainActivity}
09-10 16:40:47.029 W/WindowManager( 72): No window to dispatch pointer action 0
09-10 16:40:47.045 W/WindowManager( 72): No window to dispatch pointer action 1
09-10 16:40:47.280 W/WindowManager( 72): No window to dispatch pointer action 0
09-10 16:40:47.345 W/WindowManager( 72): No window to dispatch pointer action 1
09-10 16:40:47.545 W/WindowManager( 72): No window to dispatch pointer action 0
09-10 16:40:47.595 W/WindowManager( 72): No window to dispatch pointer action 1
09-10 16:40:47.794 W/WindowManager( 72): No window to dispatch pointer action 0
09-10 16:40:47.865 W/WindowManager( 72): No window to dispatch pointer action 1
09-10 16:40:49.235 D/dalvikvm( 289): GC_EXPLICIT freed 353 objects / 19600 bytes in 56ms
09-10 16:40:52.924 W/InputManagerService( 72): Got RemoteException sending setActive(false) notification to pid 575 uid 10040
09-10 16:40:52.964 I/ActivityManager( 72): Displayed activity com.example.testanr2/.MainActivity: 18800 ms (total 22687 ms)
Launcher2
01-01 08:12:56.140 I/WindowManager( 1259): Handle special keys: 23
01-01 08:12:56.145 W/ActivityManager( 1259): Force finishing activity com.android.launcher/com.android.launcher2.Launcher
01-01 08:12:56.239 D/dalvikvm( 1259): GC_FOR_ALLOC freed 462K, 13% free 10871K/12423K, paused 48ms
01-01 08:12:56.242 D/UsageStats( 1259): UsageStats: broadcasting intent
01-01 08:12:56.244 I/ActivityManager( 1259): Clearing package preferred activities from com.android.launcher
01-01 08:12:56.244 I/ActivityManager( 1259): Killing ProcessRecord{40c2f498 2970:com.android.launcher/10032}: user's request
01-01 08:12:56.252 I/ActivityManager( 1259): START {act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10000000 cmp=com.android.launcher/com.android.launcher2.Launcher} from pid 0
01-01 08:12:56.303 E/JavaBinder( 1259): !!! FAILED BINDER TRANSACTION !!!
01-01 08:12:56.330 W/ActivityManager( 1259): Exception when starting activity com.android.launcher/com.android.launcher2.Launcher
01-01 08:12:56.330 W/ActivityManager( 1259): android.os.TransactionTooLargeException
01-01 08:12:56.330 W/ActivityManager( 1259): at android.os.BinderProxy.transact(Native Method)
01-01 08:12:56.330 W/ActivityManager( 1259): at android.app.ApplicationThreadProxy.scheduleLaunchActivity(ApplicationThreadNative.java:660)
01-01 08:12:56.330 W/ActivityManager( 1259): at com.android.server.am.ActivityStack.realStartActivityLocked(ActivityStack.java:615)
01-01 08:12:56.330 W/ActivityManager( 1259): at com.android.server.am.ActivityStack.startSpecificActivityLocked(ActivityStack.java:724)
01-01 08:12:56.330 W/ActivityManager( 1259): at com.android.server.am.ActivityStack.resumeTopActivityLocked(ActivityStack.java:1614)
01-01 08:12:56.330 W/ActivityManager( 1259): at com.android.server.am.ActivityStack.startActivityLocked(ActivityStack.java:1760)
01-01 08:12:56.330 W/ActivityManager( 1259): at com.android.server.am.ActivityStack.startActivityUncheckedLocked(ActivityStack.java:2802)
01-01 08:12:56.330 W/ActivityManager( 1259): at com.android.server.am.ActivityStack.startActivityLocked(ActivityStack.java:2422)
01-01 08:12:56.330 W/ActivityManager( 1259): at com.android.server.am.ActivityManagerService.startHomeActivityLocked(ActivityManagerService.java:2063)
01-01 08:12:56.330 W/ActivityManager( 1259): at com.android.server.am.ActivityStack.resumeTopActivityLocked(ActivityStack.java:1299)
01-01 08:12:56.330 W/ActivityManager( 1259): at com.android.server.am.ActivityStack.completePauseLocked(ActivityStack.java:1040)
01-01 08:12:56.330 W/ActivityManager( 1259): at com.android.server.am.ActivityStack.activityPaused(ActivityStack.java:952)
01-01 08:12:56.330 W/ActivityManager( 1259): at com.android.server.am.ActivityManagerService.activityPaused(ActivityManagerService.java:4140)
01-01 08:12:56.330 W/ActivityManager( 1259): at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:371)
01-01 08:12:56.330 W/ActivityManager( 1259): at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:1548)
01-01 08:12:56.330 W/ActivityManager( 1259): at android.os.Binder.execTransact(Binder.java:338)
01-01 08:12:56.330 W/ActivityManager( 1259): at com.android.server.SystemServer.init1(Native Method)
01-01 08:12:56.330 W/ActivityManager( 1259): at com.android.server.SystemServer.main(SystemServer.java:860)
01-01 08:12:56.330 W/ActivityManager( 1259): at java.lang.reflect.Method.invokeNative(Native Method)
01-01 08:12:56.330 W/ActivityManager( 1259): at java.lang.reflect.Method.invoke(Method.java:511)
01-01 08:12:56.330 W/ActivityManager( 1259): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
01-01 08:12:56.330 W/ActivityManager( 1259): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
01-01 08:12:56.330 W/ActivityManager( 1259): at dalvik.system.NativeStart.main(Native Method)
01-01 08:12:56.345 E/JavaBinder( 1259): !!! FAILED BINDER TRANSACTION !!!
01-01 08:12:56.408 I/ActivityManager( 1259): Start proc com.android.launcher for activity com.android.launcher/com.android.launcher2.Launcher: pid=3000 uid=10032 gids={}
01-01 08:12:56.484 D/UsageStats( 1259): UsageStats: broadcasting intent
01-01 08:12:56.613 I/ActivityThread( 3000): Pub com.android.launcher2.settings: com.android.launcher2.LauncherProvider
01-01 08:12:56.862 D/dalvikvm( 3000): GC_FOR_ALLOC freed 164K, 5% free 7837K/8199K, paused 21ms
01-01 08:12:56.986 I/Process ( 1259): Sending signal. PID: 3000 SIG: 3
01-01 08:12:56.986 I/dalvikvm( 3000): threadid=3: reacting to signal 3
01-01 08:12:57.007 W/WindowManager( 1259): Rebuild removed 2 windows but added 1
01-01 08:12:57.012 W/WindowManager( 1259): This window was lost: Window{40c51350 com.android.launcher/com.android.launcher2.Launcher paused=true}
01-01 08:12:57.012 W/WindowManager( 1259): mSession=Session{40bee818 uid 10032} mClient=android.os.BinderProxy@40bbecd8
01-01 08:12:57.012 W/WindowManager( 1259): mAttrs=WM.LayoutParams{(0,0)(fillxfill) sim=#20 ty=1 fl=#1810100 pfl=0x8 fmt=-2 wanim=0x1030292}
01-01 08:12:57.012 W/WindowManager( 1259): Requested w=1920 h=1080 mLayoutSeq=148
01-01 08:12:57.012 W/WindowManager( 1259): mBaseLayer=21000 mSubLayer=0 mAnimLayer=21000+0=21000 mLastLayer=21000
01-01 08:12:57.012 W/WindowManager( 1259): mSurface=Surface(name=com.android.launcher/com.android.launcher2.Launcher, identity=34)
01-01 08:12:57.012 W/WindowManager( 1259): Surface: shown=false layer=21000 alpha=1.0 rect=(0.0,0.0) 1920.0 x 1080.0
01-01 08:12:57.012 W/WindowManager( 1259): mToken=AppWindowToken{40cb7750 token=Token{40b37598 ActivityRecord{40b9c4c0 com.android.launcher/com.android.launcher2.Launcher}}}
01-01 08:12:57.012 W/WindowManager( 1259): mRootToken=AppWindowToken{40cb7750 token=Token{40b37598 ActivityRecord{40b9c4c0 com.android.launcher/com.android.launcher2.Launcher}}}
01-01 08:12:57.012 W/WindowManager( 1259): mAppToken=AppWindowToken{40cb7750 token=Token{40b37598 ActivityRecord{40b9c4c0 com.android.launcher/com.android.launcher2.Launcher}}}
01-01 08:12:57.012 W/WindowManager( 1259): mViewVisibility=0x0 mLastHidden=true mHaveFrame=true mObscured=false
01-01 08:12:57.012 W/WindowManager( 1259): mSeq=0 mSystemUiVisibility=0x0
01-01 08:12:57.012 W/WindowManager( 1259): mGivenContentInsets=[0,0][0,0] mGivenVisibleInsets=[0,0][0,0]
01-01 08:12:57.012 W/WindowManager( 1259): mConfiguration={1.0 0mcc0mnc zh_CN layoutdir=0 sw720dp w1280dp h720dp xlrg long land -touch -keyb/v/h dpad/v s.4}
01-01 08:12:57.012 W/WindowManager( 1259): mShownFrame=[0.0,0.0][1920.0,1080.0]
01-01 08:12:57.012 W/WindowManager( 1259): mFrame=[0,0][1920,1080] last=[0,0][1920,1080]
01-01 08:12:57.012 W/WindowManager( 1259): mContainingFrame=[0,0][1920,1080] mParentFrame=[0,0][1920,1080] mDisplayFrame=[0,0][1920,1080]
01-01 08:12:57.012 W/WindowManager( 1259): mContentFrame=[0,0][1920,1080] mVisibleFrame=[0,0][1920,1080]
01-01 08:12:57.012 W/WindowManager( 1259): mContentInsets=[0,0][0,0] last=[0,0][0,0] mVisibleInsets=[0,0][0,0] last=[0,0][0,0]
01-01 08:12:57.012 W/WindowManager( 1259): mDrawPending=false mCommitDrawPending=false mReadyToShow=false mHasDrawn=true
01-01 08:12:57.012 W/WindowManager( 1259): mWallpaperX=0.5 mWallpaperY=0.5
01-01 08:12:57.012 W/WindowManager( 1259): mWallpaperXStep=0.25 mWallpaperYStep=1.0
01-01 08:12:57.012 W/WindowManager( 1259): Current app token list:
01-01 08:12:57.012 V/WindowManager( 1259): #0: Token{40ba4ee8 ActivityRecord{40bb8cd8 com.android.launcher/com.android.launcher2.Launcher}}
01-01 08:12:57.012 W/WindowManager( 1259): Final window list:
01-01 08:12:57.012 V/WindowManager( 1259): #1: Window{40b78338 InputMethod paused=false}
01-01 08:12:57.012 V/WindowManager( 1259): #0: Window{40c6f7b8 Starting com.android.launcher paused=false}
01-01 08:12:57.035 I/WindowManager( 1259): WIN DEATH: Window{40c51350 com.android.launcher/com.android.launcher2.Launcher paused=true}
01-01 08:12:57.039 I/dalvikvm( 3000): Wrote stack traces to '/data/anr/traces.txt'
01-01 08:12:57.051 D/dalvikvm( 3000): GC_CONCURRENT freed 264K, 6% free 8034K/8519K, paused 5ms+1ms
01-01 08:12:57.251 D/dalvikvm( 3000): GC_FOR_ALLOC freed 168K, 5% free 8217K/8583K, paused 14ms
01-01 08:12:57.263 I/dalvikvm-heap( 3000): Grow heap (frag case) to 10.641MB for 2560016-byte allocation
01-01 08:12:57.278 D/dalvikvm( 3000): GC_CONCURRENT freed 13K, 4% free 10704K/11143K, paused 2ms+1ms
01-01 08:12:57.358 D/dalvikvm( 3000): GC_FOR_ALLOC freed 0K, 4% free 10704K/11143K, paused 10ms
01-01 08:12:57.370 D/KeyLayoutMap( 1259): mapKey: scanCode=106 ~ Result keyCode=22, flags=0x00000002.
01-01 08:12:57.370 D/InputReader( 1259): receive key event: device=6 type=0x0001 scancode=106(0x006a) keycode=22(0x0016) value=0x00000001 flags=0x00000002
01-01 08:12:57.370 I/WindowManager( 1259): Handle special keys: 22
01-01 08:12:57.372 I/dalvikvm-heap( 3000): Grow heap (frag case) to 12.001MB for 1440016-byte allocation
01-01 08:12:57.394 D/dalvikvm( 3000): GC_CONCURRENT freed 0K, 4% free 12110K/12551K, paused 1ms+2ms
01-01 08:12:57.453 D/Launcher( 3000): #### onCreate setBackgroundColor
01-01 08:12:57.454 D/Launcher( 3000): sleep~main10