Ensure we don't wait for VSync if we're just resuming 79/46379/2
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Wed, 19 Aug 2015 18:00:31 +0000 (19:00 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Thu, 20 Aug 2015 09:33:01 +0000 (02:33 -0700)
[Problem]  Could go into a scenario where we end up waiting for v-sync but haven't actually
           restarted the v-sync thread upon resume.
[Solution] Ensure we do not wait for a v-sync if we're just resuming.
           Also ensure we do not go to sleep if we've just resumed.

Change-Id: I225c78c9c20fee090db0842e40b02336821b75a6

adaptors/base/thread-synchronization.cpp

index 8a27ecb..191d3e9 100644 (file)
@@ -385,7 +385,8 @@ bool ThreadSynchronization::UpdateReady( bool notifyEvent, bool runUpdate, float
       {
         ConditionalWait::ScopedLock updateLock( mUpdateThreadWaitCondition );
         if( ( mState != State::STOPPED ) &&
-            ( mVSyncAheadOfUpdate == 0 ) )
+            ( mVSyncAheadOfUpdate == 0 ) &&
+            ( !mUpdateThreadResuming ) ) // Ensure we don't wait if the update-thread is JUST resuming
         {
           LOG_VSYNC_COUNTER_UPDATE( " vSyncAheadOfUpdate(%d) WAIT", mVSyncAheadOfUpdate );
           mUpdateThreadWaitCondition.Wait( updateLock );
@@ -626,7 +627,8 @@ void ThreadSynchronization::UpdateTryToSleep( bool runUpdate )
 {
   LOG_UPDATE_TRACE;
 
-  if( ! runUpdate )
+  if( ! runUpdate &&
+      ! IsUpdateThreadResuming() ) // Locks so we shouldn't have a lock, we shouldn't try to sleep if we're JUST resuming
   {
     LOG_UPDATE( "TryToSleep" );