SF: Clear local sync points on hide and destroy

Clears out a Layer's local sync points when the layer is destroyed
and when it is hidden, so that any Layers waiting for frames to
appear on that Layer are not blocked when attempting to apply
transactions

Bug: 28399096
Change-Id: I380a83624f9d7ea5797f66daa711ae4b80475bdf
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index c640f58..96252f3 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -178,6 +178,9 @@
     for (auto& point : mRemoteSyncPoints) {
         point->setTransactionApplied();
     }
+    for (auto& point : mLocalSyncPoints) {
+        point->setFrameAvailable();
+    }
     mFlinger->deleteTextureAsync(mTextureName);
     mFrameTracker.logAndResetStats(mName);
 }
@@ -1478,6 +1481,17 @@
                 (type >= Transform::SCALE));
     }
 
+    // If the layer is hidden, signal and clear out all local sync points so
+    // that transactions for layers depending on this layer's frames becoming
+    // visible are not blocked
+    if (c.flags & layer_state_t::eLayerHidden) {
+        Mutex::Autolock lock(mLocalSyncPointMutex);
+        for (auto& point : mLocalSyncPoints) {
+            point->setFrameAvailable();
+        }
+        mLocalSyncPoints.clear();
+    }
+
     // Commit the transaction
     commitTransaction(c);
     return flags;