(Animation) Bug fix when Cleared state animation finish normally don't emit signal 39/319939/1
authorEunki, Hong <eunkiki.hong@samsung.com>
Thu, 20 Feb 2025 02:11:51 +0000 (11:11 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Thu, 20 Feb 2025 02:26:23 +0000 (11:26 +0900)
Their was some bug if

(Event Thread) Clear()
(Render Thread) Finish animation normally
(Event Thread) NotificationManager->ProcessMessages() -> HasFinished() called
...
(Event Thread) Play()
(Render Thread) Finish animation normally
(Event Thread) NotificationManager->ProcessMessages() -> HasFinished() called

progress comes.

The first HasFinished() should not emit finished signal.
But second HasFinisehd() should emit finished signal, but not.

It was bugs since HasFinished() update some values, but we don't use it.
(Cleared state should have mNotificationCount always) It make bug.

Change-Id: I593c9983fe97924638c85f0ef30d3c98064d9415
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
automated-tests/src/dali/utc-Dali-Animation.cpp
dali/internal/common/core-impl.cpp
dali/internal/event/animation/animation-impl.cpp

index d80998159eaf78c2b4c1f5c0f4e8af366371bef3..c8b44049895f81e31834660d9788b888a0a57038 100644 (file)
@@ -3989,6 +3989,53 @@ int UtcDaliAnimationClearIgnoreFinishedSignal(void)
     application.SendNotification();
     application.Render(0);
   }
+  {
+    tet_printf("Check whether clear and render-well case don't send signal\n");
+    // Play the animation, and clear when animation finished naturally, and play again.
+    animation.Play();
+
+    application.SendNotification();
+    application.Render(static_cast<uint32_t>(durationSeconds * 500.0f));
+    finishCheck.CheckSignalNotReceived();
+    finishCheck.Reset();
+
+    application.SendNotification();
+    finishCheck.CheckSignalNotReceived();
+    finishCheck.Reset();
+
+    // Call Clear now.
+    animation.Clear();
+
+    // Finish animation naturally. (Note that dali don't call finished callback even if one render frame spend more than duration.)
+    application.Render(static_cast<uint32_t>(durationSeconds * 500.0f) + 10u);
+    application.SendNotification();
+
+    // expect finished signal not be recieved due to Animation cleared.
+    finishCheck.CheckSignalNotReceived();
+    finishCheck.Reset();
+
+    application.SendNotification();
+    finishCheck.CheckSignalNotReceived();
+    finishCheck.Reset();
+
+    // Play again
+    animation.Play();
+    application.SendNotification();
+    application.Render(static_cast<uint32_t>(durationSeconds * 500.0f));
+    finishCheck.CheckSignalNotReceived();
+    finishCheck.Reset();
+
+    application.Render(static_cast<uint32_t>(durationSeconds * 500.0f) + 10u);
+    application.SendNotification();
+
+    // expect finished signal recieved due to Animation finished.
+    application.SendNotification();
+    finishCheck.CheckSignalReceived();
+    finishCheck.Reset();
+
+    application.SendNotification();
+    application.Render(0);
+  }
 
   END_TEST;
 }
index 3c9b6cb955bf21316298e507dbfd15f151ec8f91..22d037dd2a3666e0592d601427a9be85175edd4a 100644 (file)
@@ -270,7 +270,9 @@ void Core::ForceRelayout()
   // Copy the Scene container locally to avoid possibly invalid iterator
   SceneContainer scenes = mScenes;
 
+  DALI_LOG_DEBUG_INFO("ForceRelayout()\n");
   RelayoutAndFlush(scenes);
+  DALI_LOG_DEBUG_INFO("ForceRelayout() done\n");
 }
 
 void Core::ProcessEvents()
@@ -347,6 +349,8 @@ void Core::RelayoutAndFlush(SceneContainer& scenes)
 
     // Signal that any messages received will be flushed soon
     mUpdateManager->EventProcessingStarted();
+
+    mNotificationManager->ProcessMessages();
   }
 
   mRelayoutFlush = true;
@@ -386,6 +390,9 @@ void Core::RelayoutAndFlush(SceneContainer& scenes)
 
   if(!isProcessEvents)
   {
+    // Notify to animation play list that event processing has finished.
+    mAnimationPlaylist->EventLoopFinished();
+
     // Revert fake informations
     mProcessingEvent = false;
     mRelayoutController->SetProcessingCoreEvents(false);
index 4e9dc88bd19d888b508aed1afb3e7dff93d0fbef..efce1b8d1119dc0c6ba97760f276a8a79eb15c46 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -954,9 +954,6 @@ bool Animation::HasFinished()
 
   if(playedCount > mNotificationCount)
   {
-    // Note that only one signal is emitted, if the animation has been played repeatedly
-    mNotificationCount = playedCount;
-
     switch(mState)
     {
       case Internal::Animation::InternalState::PLAYING:
@@ -983,6 +980,12 @@ bool Animation::HasFinished()
         break;
       }
     }
+
+    if(hasFinished)
+    {
+      // Note that only one signal is emitted, if the animation has been played repeatedly
+      mNotificationCount = playedCount;
+    }
   }
 
   return hasFinished;