(OffscreenWindow) Acquire buffer forcibly if we cannot enqueue buffer 72/316572/3
authorEunkiki Hong <eunkiki.hong@samsung.com>
Fri, 23 Aug 2024 08:38:23 +0000 (17:38 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Mon, 26 Aug 2024 02:24:23 +0000 (11:24 +0900)
Since DDK don't cancel the enqueue buffer automatically, we should acquire tbm buffer by ourside manually.

Let we call acquire forcibly at PreRender time before render scene

Change-Id: Ibdba1b5fec5eac1e05b3feda26741e568ec8c6a0
Signed-off-by: Eunkiki Hong <eunkiki.hong@samsung.com>
dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.cpp

index c409919d13ac3385663f5251faa4230c3a57fdeb..ff2168be739032e4b811bae81f166dc6ba8b90ff 100644 (file)
@@ -299,6 +299,39 @@ bool NativeRenderSurfaceEcoreWl::PreRender(bool resizingSurface, const std::vect
 {
   // Not support partial update
   clippingRect = Rect<int32_t>(0, 0, mSurfaceSize.GetWidth(), mSurfaceSize.GetHeight());
+
+  // Discard old surface if we cannot enqueue to tbm buffer.
+  // If we don't acquire & release any buffer, it will be dead lock when we call
+  // any glClear, or glFlush, glDraw, etc.
+  if(DALI_UNLIKELY(mTbmQueue && !tbm_surface_queue_can_dequeue(mTbmQueue, 0)))
+  {
+    if(tbm_surface_queue_can_acquire(mTbmQueue, 0))
+    {
+      tbm_surface_h surface;
+
+      auto ret = tbm_surface_queue_acquire(mTbmQueue, &surface);
+
+      if(ret != TBM_SURFACE_QUEUE_ERROR_NONE)
+      {
+        DALI_LOG_ERROR("Failed to aquire a tbm_surface. error : 0x%x. Deadlock might be occured!!\n", ret);
+      }
+      else
+      {
+        if(tbm_surface_internal_is_valid(surface))
+        {
+          ret = tbm_surface_queue_release(mTbmQueue, surface);
+          if(ret != TBM_SURFACE_QUEUE_ERROR_NONE)
+          {
+            DALI_LOG_ERROR("Failed to release a tbm_surface[%p]. error : 0x%x. Deadlock might be occured!!\n", surface, ret);
+          }
+        }
+        else
+        {
+          DALI_LOG_ERROR("tbm_surface[%p] is not valid!. Deadlock might be occured!!\n", surface);
+        }
+      }
+    }
+  }
   return true;
 }