title: Main android screen doesn't go back up after resuming from suspend
body: <p>I am debugging a bug where the android main screen won't show up after resuming from suspend (after hitting end-key).  Sometimes it can go back up, but when it doesn't, it will keep the screen dim and black, but the shell is still working.<br>
  I can dump the bugreport and use chkbugreport app... Sorry that I am a beginner android developer and any help is appreciated to point me where to investigate from the bugreport:</p>
  
  <p>It actually triggers ANR after leaving the phone a few minutes.</p>
  
  <p>The interesting logcat after resuming and no android screen (powermanager screen timeout):</p>
  
  <pre><code>   01-09 03:14:29.550 1565 1620 I PowerManagerService: Waking up from sleep...
     01-09 03:14:29.560 1347 1424 D SurfaceFlinger: Screen acquired, type=0    flinger=0x4178c408
     01-09 03:14:29.610 1565 1620 I WindowManager: Lock screen displayed!
     01-09 03:14:29.690 1350 1704 D audio_hw: ENTERING adev_set_parameters() screen_state=on
     01-09 03:14:29.690 1350 1704 V audio_hw: setFMParameters: screen_state=on 
     01-09 03:14:29.690 1350 1704 V audio_hw: LEAVING adev_set_parameters()
     01-09 03:14:29.710 1565 1712 I qtaguid : Failed write_ctrl(s 1 10022) res=-1 errno=
     01-09 03:14:29.810 1865 2388 I NfcService: applyRouting(), screenState = 2
     01-09 03:14:33.320 1565 1694 I PowerManagerService: Going to sleep by user request...
     01-09 03:14:33.750 1347 1424 D SurfaceFlinger: Screen released, type=0 flinger=0x4178c408
     01-09 03:14:33.800 1565 1712 I qtaguid : Failed write_ctrl(s 0 10022) res=-1 errno=1
     01-09 03:14:39.470 1565 1620 D EmergencyButton: Is Sim 1 Locked = false, Is Sim 2 locked = false
     01-09 03:14:39.500 1565 1620 D EmergencyButton: enalbe emergency call button = false
     01-09 03:14:39.590 1565 1620 I Choreographer: Skipped 176 frames! The application may be doing too much work on its main thread.
     01-09 03:14:39.640 1565 1568 D dalvikvm: GC_CONCURRENT freed 698K, 21% free 6985K/8792K, paused 5ms+13ms, total 102ms
     01-09 03:14:39.650 1565 1620 I PowerManagerService: Waking up from sleep...
     01-09 03:14:39.660 1347 1424 D SurfaceFlinger: Screen acquired, type=0 flinger=0x4178c408
     01-09 03:14:39.730 1565 1620 I WindowManager: Lock screen displayed!
     01-09 03:14:39.800 1565 1712 I qtaguid : Failed write_ctrl(s 1 10022) res=-1 errno=1
     01-09 03:14:49.660 1565 1688 I PowerManagerService: Going to sleep due to screen timeout...
     01-09 03:14:50.100 1347 1424 D SurfaceFlinger: Screen released, type=0 flinger=0x4178c408   
  </code></pre>
  
  <p>From the bugreport chkbugreport, I can see there are some busy threads:</p>
  
  <pre><code>  system_server(1565)/PowerManagerService
      •system_server(1565)/ActivityManager
      •system_server(1565)/UI
      •system_server(1565)/PowerManagerService
      •system_server(1565)/ActivityManager
      •system_server(1565)/UI
  
  PowerManagerService (tid=22 pid=1688 prio=5  state=NATIVE)
  android.view.Surface.nativeCreate
  android.view.Surface. (Surface.java)
  com.android.server.power.ElectronBeam.createSurface (ElectronBeam.java)
  com.android.server.power.ElectronBeam.tryPrepare (ElectronBeam.java)
  com.android.server.power.ElectronBeam.prepare (ElectronBeam.java)
  com.android.server.power.DisplayPowerState.prepareElectronBeam (DisplayPowerState.java)
  com.android.server.power.DisplayPowerController.updatePowerState   (DisplayPowerController.java)
  com.android.server.power.DisplayPowerController.access$300 (DisplayPowerController.java)
  com.android.server.power.DisplayPowerController$DisplayControllerHandler.handleMessage (DisplayPowerController.java)
  android.os.Handler.dispatchMessage (Handler.java)
  android.os.Looper.loop (Looper.java)
  android.os.HandlerThread.run (HandlerThread.java)
  
  
  ActivityManager (tid=15 pid=1628 prio=5  state=NATIVE)
  
  
  android.view.Surface.nativeCreate
  android.view.Surface. (Surface.java)
  com.android.server.wm.WindowStateAnimator.createSurfaceLocked (WindowStateAnimator.java)
  com.android.server.wm.WindowManagerService.relayoutWindow (WindowManagerService.java)
  com.android.server.wm.Session.relayout (Session.java)
  android.view.ViewRootImpl.relayoutWindow (ViewRootImpl.java)
  android.view.ViewRootImpl.performTraversals (ViewRootImpl.java)
  android.view.ViewRootImpl.doTraversal (ViewRootImpl.java)
  android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java)
  android.view.Choreographer$CallbackRecord.run (Choreographer.java)
  android.view.Choreographer.doCallbacks (Choreographer.java)
  android.view.Choreographer.doFrame (Choreographer.java)
  android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java)
  android.os.Handler.handleCallback (Handler.java)
  android.os.Handler.dispatchMessage (Handler.java)
  android.os.Looper.loop (Looper.java)
  com.android.server.am.ActivityManagerService$AThread.run (ActivityManagerService.java)
  
  UI (tid=13 pid=1620 prio=5  state=NATIVE)
  
  com.google.android.gles_jni.EGLImpl.eglSwapBuffers
  android.view.HardwareRenderer$GlRenderer.draw (HardwareRenderer.java)
  android.view.ViewRootImpl.draw (ViewRootImpl.java)
  android.view.ViewRootImpl.performDraw (ViewRootImpl.java)
  android.view.ViewRootImpl.performTraversals (ViewRootImpl.java)
  android.view.ViewRootImpl.doTraversal (ViewRootImpl.java)
  android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java)
  android.view.Choreographer$CallbackRecord.run (Choreographer.java)
  android.view.Choreographer.doCallbacks (Choreographer.java)
  android.view.Choreographer.doFrame (Choreographer.java)
  android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java)
  android.os.Handler.handleCallback (Handler.java)
  android.os.Handler.dispatchMessage (Handler.java)
  android.os.Looper.loop (Looper.java)
  android.os.HandlerThread.run (HandlerThread.java)
  
  
  01-09 03:21:02.820 1565 1628 E ActivityManager: ANR in com.android.launcher
  01-09 03:21:02.820 1565 1628 E ActivityManager: Reason: Broadcast of Intent { act=android.intent.action.TIME_TICK flg=0x40000014 (has extras) }
  01-09 03:21:02.820 1565 1628 E ActivityManager: Load: 0.04 / 0.39 / 0.26
  01-09 03:21:02.820 1565 1628 E ActivityManager: CPU usage from 55055ms to 0ms ago:
  01-09 03:21:02.820 1565 1628 E ActivityManager: 0.1% 1565/system_server: 0% user + 0.1% kernel / faults: 10 minor
  01-09 03:21:02.820 1565 1628 E ActivityManager: 0% 1736/com.android.systemui: 0% user + 0% kernel / faults: 18 minor
  01-09 03:21:02.820 1565 1628 E ActivityManager: 0% 482/kworker/0:2: 0% user + 0% kernel
  01-09 03:21:02.820 1565 1628 E ActivityManager: 0% 412/kworker/3:1: 0% user + 0% kernel
   1-09 03:21:02.820 1565 1628 E ActivityManager: 0% 1347/surfaceflinger: 0% user + 0% kernel
  01-09 03:21:02.820 1565 1628 E ActivityManager: 0% 1361/gpslogd: 0% user + 0% kernel
  01-09 03:21:02.820 1565 1628 E ActivityManager: 0% TOTAL: 0% user + 0% kernel
  01-09 03:21:02.820 1565 1628 E ActivityManager: CPU usage from 1987ms to 2629ms later:
  01-09 03:21:02.820 1565 1628 E ActivityManager: 21% 1565/system_server: 0% user + 21% kernel / faults: 1 minor
  01-09 03:21:02.820 1565 1628 E ActivityManager: 21% 1628/ActivityManager: 1.5% user + 20% kernel
  01-09 03:21:02.820 1565 1628 E ActivityManager: 4.6% TOTAL: 0.5% user + 4.1% kernel
  </code></pre>
  
  <p>From here, with my limited knowledge about android, I can guess it stucks when powermanager waiting to create electronbeam animation to show the main screen. It is waiting for some native (or kernel code) to finish ?  Therefore, it could be issue with lower layer....?</p>
  
  <p>Thanks for any help. </p>