attempt to fix an ANR in various apps

recent changes in SF introduced a hang where some windows would
stop being refreshed.
This is an attemp to fix that.

Change-Id: I6aa32ac0d6f1c0a6aea8f6195825dc4f4e6f93f9
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 870235b..ee37efb 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -425,12 +425,12 @@
         } break;
 
         case MessageQueue::REFRESH: {
-            if (!mDirtyRegion.isEmpty()) {
-                // NOTE: it is mandatory to call hw.compositionComplete()
-                // after handleRefresh()
-                handleRefresh();
+            // NOTE: it is mandatory to call hw.compositionComplete()
+            // after handleRefresh()
+            const DisplayHardware& hw(graphicPlane(0).displayHardware());
+            handleRefresh();
 
-                const DisplayHardware& hw(graphicPlane(0).displayHardware());
+            if (!mDirtyRegion.isEmpty()) {
                 if (CC_UNLIKELY(mHwWorkListDirty)) {
                     // build the h/w work list
                     handleWorkList();
@@ -445,6 +445,8 @@
                     // pretend we did the post
                     hw.compositionComplete();
                 }
+            } else {
+                hw.compositionComplete();
             }
         } break;
     }