Fix the race condition issue of RenderOnce() in GlWindow 89/253289/2
authorWonsik Jung <sidein@samsung.com>
Mon, 8 Feb 2021 10:13:26 +0000 (19:13 +0900)
committerWonsik Jung <sidein@samsung.com>
Thu, 11 Mar 2021 10:00:08 +0000 (19:00 +0900)
Fix the race condition issue of RenderOnce() in GlWindow.
If RenderOnce() function is called in event thread continuously,
the race condition issue will be occured.
Because the renderOnce flag is written in event thread
and the flag is read and written in render thread without lock.
This patch is to fix the issue.

Change-Id: I0a45c0e538c19b9c552d75fd1cf1e2ca4cbd042a

dali/internal/window-system/common/gl-window-render-thread.cpp

index 783ff36..55010ce 100644 (file)
@@ -130,6 +130,7 @@ void GlWindowRenderThread::SetOnDemandRenderMode(bool onDemand)
 
 void GlWindowRenderThread::RenderOnce()
 {
+  // Most of all, this function is called in event thread
   ConditionalWait::ScopedLock lock(mRenderThreadWaitCondition);
   mRequestRenderOnce = 1;
   mRenderThreadWaitCondition.Notify(lock);
@@ -188,11 +189,6 @@ void GlWindowRenderThread::Run()
     }
 
     TimeService::SleepUntil(timeToSleepUntil);
-
-    if(mRequestRenderOnce)
-    {
-      mRequestRenderOnce = 0;
-    }
   }
 
   if(mGLTerminateCallback)
@@ -263,6 +259,7 @@ bool GlWindowRenderThread::RenderReady(uint64_t& timeToSleepUntil)
     mRenderThreadWaitCondition.Wait(updateLock);
   }
 
+  mRequestRenderOnce = 0;
   // Keep the update-render thread alive if this thread is NOT to be destroyed
   return !mDestroyRenderThread;
 }