Repeat ProcessEvents idler if requested. 48/284148/11
authorEunki, Hong <eunkiki.hong@samsung.com>
Thu, 10 Nov 2022 13:00:02 +0000 (22:00 +0900)
committerEunki Hong <eunkiki.hong@samsung.com>
Thu, 13 Jul 2023 09:21:17 +0000 (09:21 +0000)
If someone request ProcessEvents during ProcessEventsOnIdle API,
that request was ignored.

To make all requested events process well, make we idler run again.

TODO : WinCallbackManager don't consider repeat idle case.
We should fix it somedays.

Change-Id: I74b1f5d50b2f16ee539350eaf570d558e445cf15
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
dali/internal/adaptor/common/adaptor-impl.cpp
dali/internal/adaptor/common/adaptor-impl.h
dali/internal/system/libuv/callback-manager-libuv.cpp
dali/internal/system/windows/callback-manager-win.cpp

index 3fc83d0..5268156 100644 (file)
@@ -973,11 +973,20 @@ void Adaptor::RequestUpdate()
 
 void Adaptor::RequestProcessEventsOnIdle()
 {
-  // Only request a notification if we haven't installed the idle notification
   // We want to run the processes even when paused
-  if(!mNotificationOnIdleInstalled && STOPPED != mState)
+  if(STOPPED != mState)
   {
-    mNotificationOnIdleInstalled = AddIdleEnterer(MakeCallback(this, &Adaptor::ProcessCoreEventsFromIdle), true);
+    if(!mNotificationOnIdleInstalled)
+    {
+      // If we haven't installed the idle notification, install it idle enterer.
+      mNotificationOnIdleInstalled = AddIdleEnterer(MakeCallback(this, &Adaptor::ProcessCoreEventsFromIdle), true);
+    }
+    else
+    {
+      // Request comes during ProcessCoreEventsFromIdle running.
+      // Mark as we need to call ProcessEvents in next idle events.
+      mRequiredIdleRepeat = true;
+    }
   }
 }
 
@@ -1170,12 +1179,20 @@ void Adaptor::RequestUpdateOnce()
 
 bool Adaptor::ProcessCoreEventsFromIdle()
 {
+  // Reset repeat idler flag.
+  mRequiredIdleRepeat = false;
   ProcessCoreEvents();
 
-  // the idle handle automatically un-installs itself
-  mNotificationOnIdleInstalled = false;
+  // If someone request ProcessCoreEvents during above ProcessCoreEvents call, we might need to run idle one more times.
+  // Else, the idle handle automatically un-installs itself
+  mNotificationOnIdleInstalled = mRequiredIdleRepeat;
 
-  return false;
+  if(mRequiredIdleRepeat)
+  {
+    DALI_LOG_DEBUG_INFO("Required ProcessCoreEvents one more times\n");
+  }
+
+  return mRequiredIdleRepeat;
 }
 
 Dali::Internal::Adaptor::SceneHolder* Adaptor::GetWindow(Dali::Actor& actor)
@@ -1247,6 +1264,7 @@ Adaptor::Adaptor(Dali::Integration::SceneHolder window, Dali::Adaptor& adaptor,
   mPlatformAbstraction(nullptr),
   mCallbackManager(nullptr),
   mNotificationOnIdleInstalled(false),
+  mRequiredIdleRepeat(false),
   mNotificationTrigger(nullptr),
   mDaliFeedbackPlugin(),
   mFeedbackController(nullptr),
index e058047..a1e5be6 100644 (file)
@@ -691,6 +691,7 @@ private:                                          // Data
 
   std::unique_ptr<CallbackManager> mCallbackManager;                       ///< Used to install callbacks
   bool                             mNotificationOnIdleInstalled;           ///< whether the idle handler is installed to send an notification event
+  bool                             mRequiredIdleRepeat;                    ///< whether we need to repeat installed notification event in idle handler
   TriggerEventInterface*           mNotificationTrigger;                   ///< Notification event trigger
   FeedbackPluginProxy*             mDaliFeedbackPlugin;                    ///< Used to access feedback support
   FeedbackController*              mFeedbackController;                    ///< Plays feedback effects for Dali-Toolkit UI Controls.
index 72326f9..9a6ae75 100644 (file)
@@ -111,6 +111,9 @@ void IdleCallback(uv_idle_t* handle)
     {
       // remove callback data from the container
       CallbackBase::Execute(*callbackData->mRemoveFromContainerFunction, callbackData);
+
+      // will clear up the handle
+      delete callbackData;
     }
   }
   else
@@ -120,10 +123,10 @@ void IdleCallback(uv_idle_t* handle)
 
     // run the function
     CallbackBase::Execute(*callbackData->mCallback);
-  }
 
-  // will clear up the handle
-  delete callbackData;
+    // will clear up the handle
+    delete callbackData;
+  }
 }
 } // namespace
 
index 7871819..f57945a 100644 (file)
@@ -78,6 +78,7 @@ bool WinCallbackManager::ProcessIdle()
 {\r
   const bool idleProcessed = !mCallbacks.empty();\r
 \r
+  // @todo : Need to consider callback with return & don't erase callback when it return true.\r
   for(CallbackBase* cb : mCallbacks)\r
   {\r
     Dali::CallbackBase::Execute(*cb);\r