Delayed SceneHolder RenderTarget initialization 72/268272/7
authorDavid Steele <david.steele@samsung.com>
Fri, 17 Dec 2021 17:28:19 +0000 (17:28 +0000)
committerDavid Steele <david.steele@samsung.com>
Fri, 21 Jan 2022 11:52:50 +0000 (11:52 +0000)
Initialization of Surface/Context pair happened in wrong thread: for
SceneHolder, the RenderTarget was being created in the Event thread,
which has effect of modifying a render-thread owned vector / queue
in the event thread, which causes crash.

Instead, moved the RenderTarget creation to
SceneGraph::Scene::Initialize(), which is executed in the render
thread.

Change-Id: Ifac94b08b4cb099267abc0353a995539ed5493c2
Signed-off-by: David Steele <david.steele@samsung.com>
automated-tests/src/dali-adaptor/dali-test-suite-utils/test-application.cpp
automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-application.cpp
automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-controller.cpp
automated-tests/src/dali-adaptor/dali-test-suite-utils/test-trace-call-stack.h
dali/integration-api/adaptor-framework/scene-holder-impl.cpp
dali/integration-api/adaptor-framework/scene-holder-impl.h

index 440270a..2862284 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
@@ -82,8 +82,9 @@ void TestApplication::CreateScene()
   // Create render target for the scene
   Graphics::RenderTargetCreateInfo rtInfo{};
   rtInfo.SetExtent({mSurfaceWidth, mSurfaceHeight});
-  mRenderTarget = mGraphicsController.CreateRenderTarget(rtInfo, nullptr);
-  mScene.SetSurfaceRenderTarget(mRenderTarget.get());
+  rtInfo.SetSurface(&mSurfaceWidth); // Can point to anything, really.
+
+  mScene.SetSurfaceRenderTarget(rtInfo);
 }
 
 void TestApplication::InitializeCore()
index cb025d0..66fae8f 100644 (file)
@@ -86,8 +86,8 @@ void TestGraphicsApplication::CreateScene()
   createInfo.SetSurface({nullptr})
     .SetExtent({mSurfaceWidth, mSurfaceHeight})
     .SetPreTransform(0 | Graphics::RenderTargetTransformFlagBits::TRANSFORM_IDENTITY_BIT);
-  mRenderTarget = mGraphicsController.CreateRenderTarget(createInfo, nullptr);
-  mScene.SetSurfaceRenderTarget(mRenderTarget.get());
+  //mRenderTarget = mGraphicsController.CreateRenderTarget(createInfo, nullptr);
+  mScene.SetSurfaceRenderTarget(createInfo);
 }
 
 void TestGraphicsApplication::InitializeCore()
index fb2afda..3ed6b56 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
@@ -1028,9 +1028,11 @@ void TestGraphicsController::BindPipeline(TestGraphicsPipeline* pipeline)
  */
 void TestGraphicsController::PresentRenderTarget(Graphics::RenderTarget* renderTarget)
 {
+  auto*                       rt = static_cast<const TestGraphicsRenderTarget*>(renderTarget);
   TraceCallStack::NamedParams namedParams;
   namedParams["renderTarget"] << std::hex << renderTarget;
-  mCallStack.PushCall("PresentRenderTarget", "", namedParams);
+  namedParams["surface"] << std::hex << rt->mCreateInfo.surface;
+  mCallStack.PushCall("PresentRenderTarget", namedParams.str(), namedParams);
 }
 
 /**
@@ -1237,7 +1239,10 @@ Graphics::UniquePtr<Graphics::Sampler> TestGraphicsController::CreateSampler(con
 
 Graphics::UniquePtr<Graphics::RenderTarget> TestGraphicsController::CreateRenderTarget(const Graphics::RenderTargetCreateInfo& renderTargetCreateInfo, Graphics::UniquePtr<Graphics::RenderTarget>&& oldRenderTarget)
 {
-  mCallStack.PushCall("CreateRenderTarget", "");
+  TraceCallStack::NamedParams namedParams;
+  namedParams["surface"] << std::hex << renderTargetCreateInfo.surface;
+  mCallStack.PushCall("CreateRenderTarget", namedParams.str(), namedParams);
+
   return Graphics::MakeUnique<TestGraphicsRenderTarget>(mGl, renderTargetCreateInfo);
 }
 
index 7631630..6f720c5 100644 (file)
@@ -2,7 +2,7 @@
 #define TEST_TRACE_CALL_STACK_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
@@ -121,6 +121,25 @@ public:
       }
     }
 
+    const std::ostringstream& operator[](std::string name) const
+    {
+      static std::ostringstream empty;
+      auto                      iter = mParams.begin();
+      for(; iter != mParams.end(); ++iter)
+      {
+        if(!iter->parameterName.compare(name))
+        {
+          break;
+        }
+      }
+
+      if(iter != mParams.end())
+      {
+        return iter->value;
+      }
+      return empty;
+    }
+
     std::string str() const
     {
       std::ostringstream out;
index 5b64638..13b93d7 100644 (file)
@@ -238,9 +238,8 @@ void SceneHolder::CreateRenderTarget()
     .SetSurface(mSurface.get())
     .SetExtent({static_cast<uint32_t>(mSurface->GetPositionSize().width), static_cast<uint32_t>(mSurface->GetPositionSize().height)})
     .SetPreTransform(0 | Graphics::RenderTargetTransformFlagBits::TRANSFORM_IDENTITY_BIT);
-  mRenderTarget = mAdaptor->GetGraphicsInterface().GetController().CreateRenderTarget(rtInfo, std::move(mRenderTarget));
 
-  mScene.SetSurfaceRenderTarget(mRenderTarget.get());
+  mScene.SetSurfaceRenderTarget(rtInfo);
 }
 
 void SceneHolder::Pause()
index 7f6c9ff..598addc 100644 (file)
@@ -338,9 +338,6 @@ private:
   class SceneHolderLifeCycleObserver;
   std::unique_ptr<SceneHolderLifeCycleObserver> mLifeCycleObserver; ///< The adaptor life cycle observer
 
-private:
-  Graphics::UniquePtr<Graphics::RenderTarget> mRenderTarget{nullptr};
-
 protected:
   uint32_t                 mId;    ///< A unique ID to identify the SceneHolder starting from 0
   Dali::Integration::Scene mScene; ///< The Scene