From a7fb09d54904a7b99cbd8ec3298c4a00edf4c601 Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Wed, 3 Jul 2024 20:24:22 +0900 Subject: [PATCH] [Tizen] Print log if worker thread destruction occured for UI items. Change-Id: I15db9dd5d6763b403b4b5015c95e3491c18443dc Signed-off-by: Eunki, Hong --- automated-tests/src/dali/utc-Dali-Actor.cpp | 40 ++++++++++++ automated-tests/src/dali/utc-Dali-Animation.cpp | 42 +++++++++++- automated-tests/src/dali/utc-Dali-FrameBuffer.cpp | 45 ++++++++++++- automated-tests/src/dali/utc-Dali-Geometry.cpp | 42 +++++++++++- .../src/dali/utc-Dali-GestureDetector.cpp | 76 ++++++++++++++++------ automated-tests/src/dali/utc-Dali-RenderTask.cpp | 61 +++++++++++++++-- .../src/dali/utc-Dali-RenderTaskList.cpp | 49 +++++++++++++- automated-tests/src/dali/utc-Dali-Renderer.cpp | 49 ++++++++++++-- automated-tests/src/dali/utc-Dali-Sampler.cpp | 42 +++++++++++- automated-tests/src/dali/utc-Dali-Scene.cpp | 56 ++++++++++++++++ automated-tests/src/dali/utc-Dali-Shader.cpp | 42 +++++++++++- automated-tests/src/dali/utc-Dali-Texture.cpp | 53 +++++++++++++++ automated-tests/src/dali/utc-Dali-TextureSet.cpp | 42 +++++++++++- automated-tests/src/dali/utc-Dali-VertexBuffer.cpp | 44 ++++++++++++- dali/internal/event/actors/actor-impl.cpp | 11 +++- dali/internal/event/actors/layer-impl.cpp | 2 +- dali/internal/event/animation/animation-impl.cpp | 5 ++ dali/internal/event/animation/constraint-base.cpp | 9 ++- dali/internal/event/common/object-impl.cpp | 7 ++ dali/internal/event/common/scene-impl.cpp | 19 +++++- .../event/events/gesture-detector-impl.cpp | 14 ++-- .../event/render-tasks/render-task-impl.cpp | 11 +++- .../event/render-tasks/render-task-list-impl.cpp | 14 ++-- .../internal/event/rendering/frame-buffer-impl.cpp | 9 ++- dali/internal/event/rendering/geometry-impl.cpp | 9 ++- dali/internal/event/rendering/renderer-impl.cpp | 9 ++- dali/internal/event/rendering/sampler-impl.cpp | 9 ++- dali/internal/event/rendering/shader-impl.cpp | 7 +- dali/internal/event/rendering/texture-impl.cpp | 27 ++++++-- dali/internal/event/rendering/texture-set-impl.cpp | 9 ++- .../event/rendering/vertex-buffer-impl.cpp | 9 ++- 31 files changed, 779 insertions(+), 84 deletions(-) diff --git a/automated-tests/src/dali/utc-Dali-Actor.cpp b/automated-tests/src/dali/utc-Dali-Actor.cpp index f08e19d..8597d18 100644 --- a/automated-tests/src/dali/utc-Dali-Actor.cpp +++ b/automated-tests/src/dali/utc-Dali-Actor.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -14652,3 +14653,42 @@ int UtcDaliActorDispatchHoverMotionPropertyN(void) } END_TEST; } + +int UtcDaliActorDestructWorkerThreadN(void) +{ + TestApplication application; + tet_infoline("UtcDaliActorDestructWorkerThreadN Test, for line coverage"); + + try + { + class TestThread : public Thread + { + public: + virtual void Run() + { + tet_printf("Run TestThread\n"); + // Destruct at worker thread. + mActor.Reset(); + } + + Dali::Actor mActor; + }; + TestThread thread; + + Dali::Actor actor = Dali::Actor::New(); + thread.mActor = std::move(actor); + actor.Reset(); + + thread.Start(); + + thread.Join(); + } + catch(...) + { + } + + // Always success + DALI_TEST_CHECK(true); + + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-Animation.cpp b/automated-tests/src/dali/utc-Dali-Animation.cpp index 6adfc79..137c5d0 100644 --- a/automated-tests/src/dali/utc-Dali-Animation.cpp +++ b/automated-tests/src/dali/utc-Dali-Animation.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -16672,4 +16673,43 @@ int UtcDaliAnimationPlayAfterStopGetState(void) } END_TEST; -} \ No newline at end of file +} + +int UtcDaliAnimationDestructWorkerThreadN(void) +{ + TestApplication application; + tet_infoline("UtcDaliAnimationDestructWorkerThreadN Test, for line coverage"); + + try + { + class TestThread : public Thread + { + public: + virtual void Run() + { + tet_printf("Run TestThread\n"); + // Destruct at worker thread. + mAnimation.Reset(); + } + + Dali::Animation mAnimation; + }; + TestThread thread; + + Dali::Animation animation = Dali::Animation::New(0); + thread.mAnimation = std::move(animation); + animation.Reset(); + + thread.Start(); + + thread.Join(); + } + catch(...) + { + } + + // Always success + DALI_TEST_CHECK(true); + + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-FrameBuffer.cpp b/automated-tests/src/dali/utc-Dali-FrameBuffer.cpp index dfb0db1..e0725ad 100644 --- a/automated-tests/src/dali/utc-Dali-FrameBuffer.cpp +++ b/automated-tests/src/dali/utc-Dali-FrameBuffer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -17,6 +17,7 @@ #include #include +#include #include using namespace Dali; @@ -33,6 +34,8 @@ void framebuffer_set_cleanup(void) test_return_value = TET_PASS; } +namespace +{ RenderTask CreateRenderTask(TestApplication& application, FrameBuffer framebuffer) { @@ -61,6 +64,7 @@ RenderTask CreateRenderTask(TestApplication& application, return newTask; } +} // namespace int UtcDaliFrameBufferNew01(void) { @@ -768,3 +772,42 @@ int UtcDaliFrameBufferAttachColorTextureNegative02(void) } END_TEST; } + +int UtcDaliFrameBufferDestructWorkerThreadN(void) +{ + TestApplication application; + tet_infoline("UtcDaliFrameBufferDestructWorkerThreadN Test, for line coverage"); + + try + { + class TestThread : public Thread + { + public: + virtual void Run() + { + tet_printf("Run TestThread\n"); + // Destruct at worker thread. + mFrameBuffer.Reset(); + } + + Dali::FrameBuffer mFrameBuffer; + }; + TestThread thread; + + Dali::FrameBuffer frameBuffer = Dali::FrameBuffer::New(100, 100); + thread.mFrameBuffer = std::move(frameBuffer); + frameBuffer.Reset(); + + thread.Start(); + + thread.Join(); + } + catch(...) + { + } + + // Always success + DALI_TEST_CHECK(true); + + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-Geometry.cpp b/automated-tests/src/dali/utc-Dali-Geometry.cpp index bb1205d..437ea1b 100644 --- a/automated-tests/src/dali/utc-Dali-Geometry.cpp +++ b/automated-tests/src/dali/utc-Dali-Geometry.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -16,6 +16,7 @@ */ #include +#include #include using namespace Dali; @@ -774,3 +775,42 @@ int UtcDaliGeometryGetTypeNegative(void) } END_TEST; } + +int UtcDaliGeometryDestructWorkerThreadN(void) +{ + TestApplication application; + tet_infoline("UtcDaliGeometryDestructWorkerThreadN Test, for line coverage"); + + try + { + class TestThread : public Thread + { + public: + virtual void Run() + { + tet_printf("Run TestThread\n"); + // Destruct at worker thread. + mGeometry.Reset(); + } + + Dali::Geometry mGeometry; + }; + TestThread thread; + + Dali::Geometry geometry = Dali::Geometry::New(); + thread.mGeometry = std::move(geometry); + geometry.Reset(); + + thread.Start(); + + thread.Join(); + } + catch(...) + { + } + + // Always success + DALI_TEST_CHECK(true); + + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-GestureDetector.cpp b/automated-tests/src/dali/utc-Dali-GestureDetector.cpp index e12bbdb..c064f8d 100644 --- a/automated-tests/src/dali/utc-Dali-GestureDetector.cpp +++ b/automated-tests/src/dali/utc-Dali-GestureDetector.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -16,13 +16,14 @@ */ #include -#include +#include #include #include #include +#include #include #include -#include +#include #include #include @@ -125,8 +126,7 @@ Integration::TouchEvent GenerateDoubleTouch(PointState::Type stateA, const Vecto return touchEvent; } -} - +} // namespace int UtcDaliGestureDetectorConstructorN(void) { @@ -598,10 +598,10 @@ int UtcDaliGestureDetectorRegisterProperty(void) int UtcDaliGestureDetectorCancelProcessing(void) { - TestApplication application; - Integration::Scene scene = application.GetScene(); - RenderTaskList taskList = scene.GetRenderTaskList(); - Dali::RenderTask task = taskList.GetTask(0); + TestApplication application; + Integration::Scene scene = application.GetScene(); + RenderTaskList taskList = scene.GetRenderTaskList(); + Dali::RenderTask task = taskList.GetTask(0); LongPressGestureDetector longDetector = LongPressGestureDetector::New(); TapGestureDetector tapDetector = TapGestureDetector::New(); @@ -646,13 +646,12 @@ int UtcDaliGestureDetectorCancelProcessing(void) TestTriggerLongPress(application); longDetector.CancelAllOtherGestureDetectors(); - DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(false, tData.functorCalled, TEST_LOCATION); data.Reset(); tData.Reset(); - tp = GenerateSingleTouch(PointState::UP, Vector2(50.0f, 50.0f), 1, 650); + tp = GenerateSingleTouch(PointState::UP, Vector2(50.0f, 50.0f), 1, 650); touchEventImpl = new Internal::TouchEvent(650); touchEventImpl->AddPoint(tp.GetPoint(0)); touchEventImpl->SetRenderTask(task); @@ -670,7 +669,7 @@ int UtcDaliGestureDetectorCancelProcessing(void) longDetector.SetTouchesRequired(2, 2); - tp = GenerateDoubleTouch(PointState::DOWN, Vector2(2.0f, 20.0f), PointState::DOWN, Vector2(38.0f, 20.0f), 100); + tp = GenerateDoubleTouch(PointState::DOWN, Vector2(2.0f, 20.0f), PointState::DOWN, Vector2(38.0f, 20.0f), 100); touchEventImpl = new Internal::TouchEvent(100); touchEventImpl->AddPoint(tp.GetPoint(0)); touchEventImpl->AddPoint(tp.GetPoint(1)); @@ -684,7 +683,7 @@ int UtcDaliGestureDetectorCancelProcessing(void) pinchDetector.CancelAllOtherGestureDetectors(); - tp = GenerateDoubleTouch(PointState::MOTION, Vector2(10.0f, 20.0f), PointState::MOTION, Vector2(30.0f, 20.0f), 150); + tp = GenerateDoubleTouch(PointState::MOTION, Vector2(10.0f, 20.0f), PointState::MOTION, Vector2(30.0f, 20.0f), 150); touchEventImpl = new Internal::TouchEvent(150); touchEventImpl->AddPoint(tp.GetPoint(0)); touchEventImpl->AddPoint(tp.GetPoint(1)); @@ -696,8 +695,7 @@ int UtcDaliGestureDetectorCancelProcessing(void) pinchDetector.HandleEvent(actor, touchEventHandle); rotationDetector.HandleEvent(actor, touchEventHandle); - - tp = GenerateDoubleTouch(PointState::MOTION, Vector2(10.0f, 20.0f), PointState::MOTION, Vector2(30.0f, 20.0f), 200); + tp = GenerateDoubleTouch(PointState::MOTION, Vector2(10.0f, 20.0f), PointState::MOTION, Vector2(30.0f, 20.0f), 200); touchEventImpl = new Internal::TouchEvent(200); touchEventImpl->AddPoint(tp.GetPoint(0)); touchEventImpl->AddPoint(tp.GetPoint(1)); @@ -709,8 +707,7 @@ int UtcDaliGestureDetectorCancelProcessing(void) pinchDetector.HandleEvent(actor, touchEventHandle); rotationDetector.HandleEvent(actor, touchEventHandle); - - tp = GenerateDoubleTouch(PointState::MOTION, Vector2(10.0f, 20.0f), PointState::MOTION, Vector2(30.0f, 20.0f), 250); + tp = GenerateDoubleTouch(PointState::MOTION, Vector2(10.0f, 20.0f), PointState::MOTION, Vector2(30.0f, 20.0f), 250); touchEventImpl = new Internal::TouchEvent(250); touchEventImpl->AddPoint(tp.GetPoint(0)); touchEventImpl->AddPoint(tp.GetPoint(1)); @@ -722,8 +719,7 @@ int UtcDaliGestureDetectorCancelProcessing(void) pinchDetector.HandleEvent(actor, touchEventHandle); rotationDetector.HandleEvent(actor, touchEventHandle); - - tp = GenerateDoubleTouch(PointState::MOTION, Vector2(10.0f, 20.0f), PointState::MOTION, Vector2(30.0f, 20.0f), 300); + tp = GenerateDoubleTouch(PointState::MOTION, Vector2(10.0f, 20.0f), PointState::MOTION, Vector2(30.0f, 20.0f), 300); touchEventImpl = new Internal::TouchEvent(300); touchEventImpl->AddPoint(tp.GetPoint(0)); touchEventImpl->AddPoint(tp.GetPoint(1)); @@ -735,8 +731,7 @@ int UtcDaliGestureDetectorCancelProcessing(void) pinchDetector.HandleEvent(actor, touchEventHandle); rotationDetector.HandleEvent(actor, touchEventHandle); - - tp = GenerateDoubleTouch(PointState::UP, Vector2(10.0f, 20.0f), PointState::UP, Vector2(30.0f, 20.0f), 350); + tp = GenerateDoubleTouch(PointState::UP, Vector2(10.0f, 20.0f), PointState::UP, Vector2(30.0f, 20.0f), 350); touchEventImpl = new Internal::TouchEvent(350); touchEventImpl->AddPoint(tp.GetPoint(0)); touchEventImpl->AddPoint(tp.GetPoint(1)); @@ -757,3 +752,42 @@ int UtcDaliGestureDetectorCancelProcessing(void) END_TEST; } + +int UtcDaliGestureDetectorDestructWorkerThreadN(void) +{ + TestApplication application; + tet_infoline("UtcDaliGestureDetectorDestructWorkerThreadN Test, for line coverage"); + + try + { + class TestThread : public Thread + { + public: + virtual void Run() + { + tet_printf("Run TestThread\n"); + // Destruct at worker thread. + mGestureDetector.Reset(); + } + + Dali::GestureDetector mGestureDetector; + }; + TestThread thread; + + GestureDetector detector = PanGestureDetector::New(); + thread.mGestureDetector = std::move(detector); + detector.Reset(); + + thread.Start(); + + thread.Join(); + } + catch(...) + { + } + + // Always success + DALI_TEST_CHECK(true); + + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-RenderTask.cpp b/automated-tests/src/dali/utc-Dali-RenderTask.cpp index cf7bd97..087c6ea 100644 --- a/automated-tests/src/dali/utc-Dali-RenderTask.cpp +++ b/automated-tests/src/dali/utc-Dali-RenderTask.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -4274,7 +4275,7 @@ int UtcDaliRenderTaskOrderIndex01(void) RenderTask renderTask1 = renderTaskList.CreateTask(); application.SendNotification(); - uint32_t answer1[2] = {0u, 0u}; + uint32_t answer1[2] = {0u, 0u}; DALI_TEST_EQUALS(2, renderTaskList.GetTaskCount(), TEST_LOCATION); for(uint32_t i = 0; i < 2; ++i) { @@ -4356,19 +4357,19 @@ int UtcDaliRenderTaskOrderIndex02(void) RenderTask renderTask1 = renderTaskList.CreateTask(); application.SendNotification(); DALI_TEST_EQUALS(renderTask1, renderTaskList.GetTask(1u), TEST_LOCATION); - - RenderTask renderTask2 = renderTaskList.CreateTask(); + + RenderTask renderTask2 = renderTaskList.CreateTask(); application.SendNotification(); DALI_TEST_EQUALS(renderTask1, renderTaskList.GetTask(1u), TEST_LOCATION); DALI_TEST_EQUALS(renderTask2, renderTaskList.GetTask(2u), TEST_LOCATION); - RenderTask renderTask3 = renderTaskList.CreateTask(); + RenderTask renderTask3 = renderTaskList.CreateTask(); application.SendNotification(); DALI_TEST_EQUALS(renderTask1, renderTaskList.GetTask(1u), TEST_LOCATION); DALI_TEST_EQUALS(renderTask2, renderTaskList.GetTask(2u), TEST_LOCATION); DALI_TEST_EQUALS(renderTask3, renderTaskList.GetTask(3u), TEST_LOCATION); - RenderTask renderTask4 = renderTaskList.CreateTask(); + RenderTask renderTask4 = renderTaskList.CreateTask(); application.SendNotification(); DALI_TEST_EQUALS(renderTask1, renderTaskList.GetTask(1u), TEST_LOCATION); DALI_TEST_EQUALS(renderTask2, renderTaskList.GetTask(2u), TEST_LOCATION); @@ -4402,10 +4403,56 @@ int UtcDaliRenderTaskGetRenderTaskId(void) DALI_TEST_CHECK(renderTask1.GetRenderTaskId() != 0u); DALI_TEST_CHECK(renderTask2.GetRenderTaskId() != 0u); DALI_TEST_CHECK(renderTask3.GetRenderTaskId() != 0u); - + DALI_TEST_CHECK(renderTask1.GetRenderTaskId() != renderTask2.GetRenderTaskId()); DALI_TEST_CHECK(renderTask2.GetRenderTaskId() != renderTask3.GetRenderTaskId()); DALI_TEST_CHECK(renderTask3.GetRenderTaskId() != renderTask1.GetRenderTaskId()); END_TEST; } + +int UtcDaliRenderTaskDestructWorkerThreadN(void) +{ + TestApplication application; + tet_infoline("UtcDaliRenderTaskDestructWorkerThreadN Test, for line coverage"); + + try + { + class TestThread : public Thread + { + public: + virtual void Run() + { + tet_printf("Run TestThread\n"); + // Destruct at worker thread. + mRenderTask.Reset(); + } + + Dali::RenderTask mRenderTask; + }; + TestThread thread; + Stage stage = Stage::GetCurrent(); + Vector2 stageSize(stage.GetSize()); + + RenderTaskList renderTaskList = stage.GetRenderTaskList(); + + RenderTask renderTask = renderTaskList.CreateTask(); + + renderTaskList.RemoveTask(renderTask); + + thread.mRenderTask = std::move(renderTask); + renderTask.Reset(); + + thread.Start(); + + thread.Join(); + } + catch(...) + { + } + + // Always success + DALI_TEST_CHECK(true); + + END_TEST; +} \ No newline at end of file diff --git a/automated-tests/src/dali/utc-Dali-RenderTaskList.cpp b/automated-tests/src/dali/utc-Dali-RenderTaskList.cpp index c024dff..50dc71f 100644 --- a/automated-tests/src/dali/utc-Dali-RenderTaskList.cpp +++ b/automated-tests/src/dali/utc-Dali-RenderTaskList.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -16,6 +16,7 @@ */ #include +#include #include #include @@ -293,3 +294,49 @@ int UtcDaliRenderTaskListGetTaskNegative(void) } END_TEST; } + +int UtcDaliRenderTaskListDestructWorkerThreadN(void) +{ + TestApplication application; + tet_infoline("UtcDaliRenderTaskListDestructWorkerThreadN Test, for line coverage"); + + try + { + class TestThread : public Thread + { + public: + virtual void Run() + { + tet_printf("Run TestThread\n"); + // Destruct at worker thread. + mRenderTaskList.Reset(); + } + + Dali::RenderTaskList mRenderTaskList; + }; + TestThread thread; + + Dali::Integration::Scene scene = Dali::Integration::Scene::New(Size(480.0f, 800.0f)); + + RenderTaskList renderTaskList = scene.GetRenderTaskList(); + + thread.mRenderTaskList = std::move(renderTaskList); + renderTaskList.Reset(); + + scene.RemoveSceneObject(); + scene.Discard(); + scene.Reset(); + + thread.Start(); + + thread.Join(); + } + catch(...) + { + } + + // Always success + DALI_TEST_CHECK(true); + + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-Renderer.cpp b/automated-tests/src/dali/utc-Dali-Renderer.cpp index 0b09348..dba76d2 100644 --- a/automated-tests/src/dali/utc-Dali-Renderer.cpp +++ b/automated-tests/src/dali/utc-Dali-Renderer.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -4937,11 +4938,6 @@ int UtcDaliRendererUniformBlocks02(void) END_TEST; } -int AlignSize(int size, int align) -{ - return (size % align == 0) ? size : ((size / align) + 1) * align; -} - int UtcDaliRendererUniformBlocks03(void) { setenv("LOG_UNIFORM_BUFFER", "5f", 1); // Turns on buffer logging @@ -5210,4 +5206,45 @@ int UtcDaliRendererUniformArrayOverflow(void) // if r is 0.0f then test fails as the array stomped on the uniform's memory. DALI_TEST_EQUALS((uniformColor.r != 0.0f), true, TEST_LOCATION); END_TEST; -} \ No newline at end of file +} + +int UtcDaliRendererDestructWorkerThreadN(void) +{ + TestApplication application; + tet_infoline("UtcDaliRendererDestructWorkerThreadN Test, for line coverage"); + + try + { + class TestThread : public Thread + { + public: + virtual void Run() + { + tet_printf("Run TestThread\n"); + // Destruct at worker thread. + mRenderer.Reset(); + } + + Dali::Renderer mRenderer; + }; + TestThread thread; + + Dali::Geometry geometry = CreateQuadGeometry(); + Dali::Shader shader = Dali::Shader::New("vertexSrc", "fragmentSrc"); + Dali::Renderer renderer = Dali::Renderer::New(geometry, shader); + thread.mRenderer = std::move(renderer); + renderer.Reset(); + + thread.Start(); + + thread.Join(); + } + catch(...) + { + } + + // Always success + DALI_TEST_CHECK(true); + + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-Sampler.cpp b/automated-tests/src/dali/utc-Dali-Sampler.cpp index ae14fd7..273b79b 100644 --- a/automated-tests/src/dali/utc-Dali-Sampler.cpp +++ b/automated-tests/src/dali/utc-Dali-Sampler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -16,6 +16,7 @@ */ // EXTERNAL INCLUDES +#include #include #include #include @@ -558,3 +559,42 @@ int UtcDaliSamplerSetFilterModeNegative(void) } END_TEST; } + +int UtcDaliSamplerDestructWorkerThreadN(void) +{ + TestApplication application; + tet_infoline("UtcDaliSamplerDestructWorkerThreadN Test, for line coverage"); + + try + { + class TestThread : public Thread + { + public: + virtual void Run() + { + tet_printf("Run TestThread\n"); + // Destruct at worker thread. + mSampler.Reset(); + } + + Dali::Sampler mSampler; + }; + TestThread thread; + + Dali::Sampler sampler = Dali::Sampler::New(); + thread.mSampler = std::move(sampler); + sampler.Reset(); + + thread.Start(); + + thread.Join(); + } + catch(...) + { + } + + // Always success + DALI_TEST_CHECK(true); + + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-Scene.cpp b/automated-tests/src/dali/utc-Dali-Scene.cpp index 367d617..a055704 100644 --- a/automated-tests/src/dali/utc-Dali-Scene.cpp +++ b/automated-tests/src/dali/utc-Dali-Scene.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -3090,3 +3091,58 @@ int UtcDaliSceneGetNativeId(void) DALI_TEST_EQUALS(nativeId, 1, TEST_LOCATION); END_TEST; } + +int UtcDaliSceneDestructWorkerThreadN(void) +{ + TestApplication application; + tet_infoline("UtcDaliSceneDestructWorkerThreadN Test, for line coverage"); + + try + { + class TestThread : public Thread + { + public: + virtual void Run() + { + tet_printf("Run TestThread\n"); + // RemoveSceneObject, Discard and Destruct at worker thread. + mScene.RemoveSceneObject(); + mScene.Discard(); + + mScene.Reset(); + } + + Dali::Integration::Scene mScene; + }; + TestThread thread; + + Dali::Integration::Scene scene = Dali::Integration::Scene::New(Size(480.0f, 800.0f)); + + // Unparent of DefaultCamera might throw exception. and exception at destructor will make abort. + // To avoid it, we should remove all children of root layer. + while(scene.GetRootLayer().GetChildCount() > 0) + { + auto child = scene.GetRootLayer().GetChildAt(0); + scene.GetRootLayer().Remove(child); + } + + // To make ensure the last reference is in thread, call Discard first. + scene.Discard(); + + thread.mScene = std::move(scene); + scene.Reset(); + + thread.Start(); + + thread.Join(); + } + catch(...) + { + } + + // Always success + DALI_TEST_CHECK(true); + + END_TEST; +} +>>>>>>> 42f1aca96... Print log if worker thread destruction occured for UI items. diff --git a/automated-tests/src/dali/utc-Dali-Shader.cpp b/automated-tests/src/dali/utc-Dali-Shader.cpp index cf23d79..f419d74 100644 --- a/automated-tests/src/dali/utc-Dali-Shader.cpp +++ b/automated-tests/src/dali/utc-Dali-Shader.cpp @@ -16,6 +16,7 @@ */ #include +#include #include #include #include @@ -730,4 +731,43 @@ int UtcDaliShaderWrongData(void) DALI_TEST_CHECK(arrayCount == 0u); END_TEST; -} \ No newline at end of file +} + +int UtcDaliShaderDestructWorkerThreadN(void) +{ + TestApplication application; + tet_infoline("UtcDaliShaderDestructWorkerThreadN Test, for line coverage"); + + try + { + class TestThread : public Thread + { + public: + virtual void Run() + { + tet_printf("Run TestThread\n"); + // Destruct at worker thread. + mShader.Reset(); + } + + Dali::Shader mShader; + }; + TestThread thread; + + Dali::Shader shader = Dali::Shader::New("", ""); + thread.mShader = std::move(shader); + shader.Reset(); + + thread.Start(); + + thread.Join(); + } + catch(...) + { + } + + // Always success + DALI_TEST_CHECK(true); + + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-Texture.cpp b/automated-tests/src/dali/utc-Dali-Texture.cpp index 8bbbdaa..655136e 100644 --- a/automated-tests/src/dali/utc-Dali-Texture.cpp +++ b/automated-tests/src/dali/utc-Dali-Texture.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -1726,3 +1727,55 @@ int utcDaliTexturePartialUpdate02(void) END_TEST; } + +int UtcDaliTextureDestructWorkerThreadN(void) +{ + TestApplication application; + tet_infoline("UtcDaliTextureDestructWorkerThreadN Test, for line coverage"); + + try + { + class TestThread : public Thread + { + public: + virtual void Run() + { + tet_printf("Run TestThread\n"); + // Upload at worker thread + uint8_t* rawBuffer = new uint8_t[4]; + Dali::PixelData pixelData = Dali::PixelData::New(rawBuffer, 4, 1, 1, Pixel::RGBA8888, Dali::PixelData::DELETE_ARRAY); + + // Use try-catch to avoid memory leak false alarm + try + { + // Upload, GenerateMipmaps, and Destruct at worker thread. + mTexture.Upload(pixelData); + mTexture.GenerateMipmaps(); + mTexture.Reset(); + } + catch(...) + { + } + } + + Dali::Texture mTexture; + }; + TestThread thread; + + Dali::Texture texture = Dali::Texture::New(Dali::TextureType::TEXTURE_2D, Pixel::RGBA8888, 100, 100); + thread.mTexture = std::move(texture); + texture.Reset(); + + thread.Start(); + + thread.Join(); + } + catch(...) + { + } + + // Always success + DALI_TEST_CHECK(true); + + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-TextureSet.cpp b/automated-tests/src/dali/utc-Dali-TextureSet.cpp index a06ae42..07ef1f7 100644 --- a/automated-tests/src/dali/utc-Dali-TextureSet.cpp +++ b/automated-tests/src/dali/utc-Dali-TextureSet.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -16,6 +16,7 @@ */ // EXTERNAL INCLUDES +#include #include // INTERNAL INCLUDES @@ -653,3 +654,42 @@ int UtcDaliTextureSetMultipleTextures(void) END_TEST; } + +int UtcDaliTextureSetDestructWorkerThreadN(void) +{ + TestApplication application; + tet_infoline("UtcDaliTextureSetDestructWorkerThreadN Test, for line coverage"); + + try + { + class TestThread : public Thread + { + public: + virtual void Run() + { + tet_printf("Run TestThread\n"); + // Destruct at worker thread. + mTextureSet.Reset(); + } + + Dali::TextureSet mTextureSet; + }; + TestThread thread; + + Dali::TextureSet textureSet = Dali::TextureSet::New(); + thread.mTextureSet = std::move(textureSet); + textureSet.Reset(); + + thread.Start(); + + thread.Join(); + } + catch(...) + { + } + + // Always success + DALI_TEST_CHECK(true); + + END_TEST; +} diff --git a/automated-tests/src/dali/utc-Dali-VertexBuffer.cpp b/automated-tests/src/dali/utc-Dali-VertexBuffer.cpp index d407b36..d72fa2b 100644 --- a/automated-tests/src/dali/utc-Dali-VertexBuffer.cpp +++ b/automated-tests/src/dali/utc-Dali-VertexBuffer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -16,6 +16,7 @@ */ #include +#include #include #include using namespace std::chrono_literals; @@ -723,3 +724,44 @@ int UtcDaliSetAndRemoveVertexBufferUpdateCallback(void) END_TEST; } + +int UtcDaliVertexBufferDestructWorkerThreadN(void) +{ + TestApplication application; + tet_infoline("UtcDaliAnimationDestructWorkerThreadN Test, for line coverage"); + + try + { + class TestThread : public Thread + { + public: + virtual void Run() + { + tet_printf("Run TestThread\n"); + // Destruct at worker thread. + mVertexBuffer.Reset(); + } + + Dali::VertexBuffer mVertexBuffer; + }; + TestThread thread; + + Dali::VertexBuffer vertexBuffer = VertexBuffer::New(Property::Map() = { + {"aPosition", Property::Type::VECTOR2}, + {"aTexCoord", Property::Type::VECTOR2}}); + thread.mVertexBuffer = std::move(vertexBuffer); + vertexBuffer.Reset(); + + thread.Start(); + + thread.Join(); + } + catch(...) + { + } + + // Always success + DALI_TEST_CHECK(true); + + END_TEST; +} diff --git a/dali/internal/event/actors/actor-impl.cpp b/dali/internal/event/actors/actor-impl.cpp index 92ac85c..a327783 100644 --- a/dali/internal/event/actors/actor-impl.cpp +++ b/dali/internal/event/actors/actor-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -1152,12 +1152,17 @@ void Actor::Initialize() Actor::~Actor() { + if(DALI_UNLIKELY(!Dali::Stage::IsCoreThread())) + { + DALI_LOG_ERROR("~Actor[%p] called from non-UI thread! something unknown issue will be happened!\n", this); + } + // Remove mParent pointers from children even if we're destroying core, // to guard against GetParent() & Unparent() calls from CustomActor destructors. UnparentChildren(); // Guard to allow handle destruction after Core has been destroyed - if(EventThreadServices::IsCoreRunning()) + if(DALI_LIKELY(EventThreadServices::IsCoreRunning())) { if(mRenderers) { @@ -1346,7 +1351,7 @@ void Actor::NotifyStageDisconnection(bool notify) // Actors can be added (in a callback), before the off-stage state is reported. // Also if the actor was added & removed before mOnSceneSignalled was set, then we don't notify here. // only do this step if there is a stage, i.e. Core is not being shut down - if(EventThreadServices::IsCoreRunning() && !OnScene() && mOnSceneSignalled) + if(DALI_LIKELY(EventThreadServices::IsCoreRunning()) && !OnScene() && mOnSceneSignalled) { if(notify) { diff --git a/dali/internal/event/actors/layer-impl.cpp b/dali/internal/event/actors/layer-impl.cpp index 6e02cb0..e4a671b 100644 --- a/dali/internal/event/actors/layer-impl.cpp +++ b/dali/internal/event/actors/layer-impl.cpp @@ -145,7 +145,7 @@ Layer::~Layer() if(mIsRoot) { // Guard to allow handle destruction after Core has been destroyed - if(EventThreadServices::IsCoreRunning()) + if(DALI_LIKELY(EventThreadServices::IsCoreRunning())) { UninstallRootMessage(GetEventThreadServices().GetUpdateManager(), &GetSceneGraphLayer()); diff --git a/dali/internal/event/animation/animation-impl.cpp b/dali/internal/event/animation/animation-impl.cpp index 1adfcf3..908126e 100644 --- a/dali/internal/event/animation/animation-impl.cpp +++ b/dali/internal/event/animation/animation-impl.cpp @@ -261,6 +261,11 @@ void Animation::Initialize() Animation::~Animation() { + if(DALI_UNLIKELY(!Dali::Stage::IsCoreThread())) + { + DALI_LOG_ERROR("~Animation[%p] called from non-UI thread! something unknown issue will be happened!\n", this); + } + // Guard to allow handle destruction after Core has been destroyed if(Stage::IsInstalled()) { diff --git a/dali/internal/event/animation/constraint-base.cpp b/dali/internal/event/animation/constraint-base.cpp index d41825d..d27a5ef 100644 --- a/dali/internal/event/animation/constraint-base.cpp +++ b/dali/internal/event/animation/constraint-base.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -81,6 +81,11 @@ ConstraintBase* ConstraintBase::Clone(Object& object) ConstraintBase::~ConstraintBase() { + if(DALI_UNLIKELY(!Dali::Stage::IsCoreThread())) + { + DALI_LOG_ERROR("~ConstraintBase[%p] called from non-UI thread! something unknown issue will be happened!\n", this); + } + StopObservation(); RemoveInternal(); @@ -108,7 +113,7 @@ void ConstraintBase::Apply(bool isPreConstraint) { if(mTargetObject && !mApplied && !mSourceDestroyed) { - mApplied = true; + mApplied = true; mIsPreConstraint = isPreConstraint; ConnectConstraint(mIsPreConstraint); diff --git a/dali/internal/event/common/object-impl.cpp b/dali/internal/event/common/object-impl.cpp index 5200ac0..3bec4cf 100644 --- a/dali/internal/event/common/object-impl.cpp +++ b/dali/internal/event/common/object-impl.cpp @@ -977,6 +977,13 @@ Object::Object(const SceneGraph::PropertyOwner* sceneObject) Object::~Object() { + if(DALI_UNLIKELY(!Dali::Stage::IsCoreThread())) + { + if(nullptr != mUpdateObject) + { + DALI_LOG_ERROR("~Object[%p] called from non-UI thread! something unknown issue will be happened!\n", this); + } + } // Notification for observers for(auto&& item : mObservers) { diff --git a/dali/internal/event/common/scene-impl.cpp b/dali/internal/event/common/scene-impl.cpp index 25655de..25cd4e6 100644 --- a/dali/internal/event/common/scene-impl.cpp +++ b/dali/internal/event/common/scene-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -68,6 +68,11 @@ Scene::Scene() Scene::~Scene() { + if(DALI_UNLIKELY(!Dali::Stage::IsCoreThread())) + { + DALI_LOG_ERROR("~Scene[%p] called from non-UI thread! something unknown issue will be happened!\n", this); + } + if(mDefaultCamera) { // its enough to release the handle so the object is released @@ -240,21 +245,29 @@ void Scene::SurfaceReplaced() void Scene::RemoveSceneObject() { - if(EventThreadServices::IsCoreRunning() && mSceneObject) + if(DALI_LIKELY(EventThreadServices::IsCoreRunning() && mSceneObject)) { ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal(); RemoveSceneMessage(tls->GetUpdateManager(), *mSceneObject); mSceneObject = nullptr; } + else if(DALI_UNLIKELY(!Dali::Stage::IsCoreThread())) + { + DALI_LOG_ERROR("Scene[%p] called RemoveSceneObject API from non-UI thread!\n", this); + } } void Scene::Discard() { - if(EventThreadServices::IsCoreRunning()) + if(DALI_LIKELY(EventThreadServices::IsCoreRunning())) { ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal(); tls->RemoveScene(this); } + else if(DALI_UNLIKELY(!Dali::Stage::IsCoreThread())) + { + DALI_LOG_ERROR("Scene[%p] called Discard API from non-UI thread!\n", this); + } } void Scene::RequestRebuildDepthTree() diff --git a/dali/internal/event/events/gesture-detector-impl.cpp b/dali/internal/event/events/gesture-detector-impl.cpp index fc6f510..2d48070 100644 --- a/dali/internal/event/events/gesture-detector-impl.cpp +++ b/dali/internal/event/events/gesture-detector-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -47,6 +47,11 @@ GestureDetector::GestureDetector(GestureType::Value type, const SceneGraph::Prop GestureDetector::~GestureDetector() { + if(DALI_UNLIKELY(!Dali::Stage::IsCoreThread())) + { + DALI_LOG_ERROR("~GestureDetector[%p] called from non-UI thread! something unknown issue will be happened!\n", this); + } + if(!mPendingAttachActors.empty()) { for(GestureDetectorActorContainer::iterator iter = mPendingAttachActors.begin(), endIter = mPendingAttachActors.end(); iter != endIter; ++iter) @@ -265,7 +270,7 @@ Dali::Actor GestureDetector::GetAttachedActor(size_t index) const bool GestureDetector::HandleEvent(Dali::Actor& actor, Dali::TouchEvent& touch) { - bool ret = false; + bool ret = false; Dali::Internal::Actor& actorImpl(GetImplementation(actor)); if(touch.GetPointCount() > 0 && actorImpl.OnScene()) { @@ -279,9 +284,9 @@ bool GestureDetector::HandleEvent(Dali::Actor& actor, Dali::TouchEvent& touch) } Integration::TouchEvent touchEvent(touch.GetTime()); - for(std::size_t i = 0; i< touch.GetPointCount(); i++) + for(std::size_t i = 0; i < touch.GetPointCount(); i++) { - Integration::Point point; + Integration::Point point; point.SetState(touch.GetState(i)); point.SetDeviceId(touch.GetDeviceId(i)); point.SetScreenPosition(touch.GetScreenPosition(i)); @@ -296,7 +301,6 @@ bool GestureDetector::HandleEvent(Dali::Actor& actor, Dali::TouchEvent& touch) touchEvent.points.push_back(point); } - Dali::Internal::TouchEvent& touchEventImpl(GetImplementation(touch)); mFeededActor.SetActor(&actorImpl); mRenderTask = &GetImplementation(touchEventImpl.GetRenderTaskPtr()); diff --git a/dali/internal/event/render-tasks/render-task-impl.cpp b/dali/internal/event/render-tasks/render-task-impl.cpp index 4ac98f3..acb8b7a 100644 --- a/dali/internal/event/render-tasks/render-task-impl.cpp +++ b/dali/internal/event/render-tasks/render-task-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -495,8 +495,8 @@ bool RenderTask::TranslateCoordinates(Vector2& screenCoords) const return false; } - CameraActor* localCamera = GetCameraActor(); - StagePtr stage = Stage::GetCurrent(); + CameraActor* localCamera = GetCameraActor(); + StagePtr stage = Stage::GetCurrent(); if(stage) { Vector2 size(stage->GetSize()); @@ -972,6 +972,11 @@ RenderTask::RenderTask(const SceneGraph::RenderTask* sceneObject, RenderTaskList RenderTask::~RenderTask() { + if(DALI_UNLIKELY(!Dali::Stage::IsCoreThread())) + { + DALI_LOG_ERROR("~RenderTask[%p] called from non-UI thread! something unknown issue will be happened!\n", this); + } + DALI_LOG_INFO(gLogRender, Debug::General, "RenderTask::~RenderTask(this:%p)\n", this); // scene object deletion is handled by our parent // scene object handles observation of source and camera diff --git a/dali/internal/event/render-tasks/render-task-list-impl.cpp b/dali/internal/event/render-tasks/render-task-list-impl.cpp index 34912a0..c130e37 100644 --- a/dali/internal/event/render-tasks/render-task-list-impl.cpp +++ b/dali/internal/event/render-tasks/render-task-list-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -176,11 +176,10 @@ void RenderTaskList::SortTasks() return; } - std::stable_sort(mTasks.begin(), mTasks.end(), [](RenderTaskPtr first, RenderTaskPtr second) -> bool - { return first->GetOrderIndex() < second->GetOrderIndex(); }); + std::stable_sort(mTasks.begin(), mTasks.end(), [](RenderTaskPtr first, RenderTaskPtr second) -> bool { return first->GetOrderIndex() < second->GetOrderIndex(); }); OwnerPointer> sortedTasks(new std::vector()); - for(auto && task : mTasks) + for(auto&& task : mTasks) { sortedTasks->push_back(task->GetRenderTaskSceneObject()); } @@ -197,7 +196,12 @@ RenderTaskList::RenderTaskList() RenderTaskList::~RenderTaskList() { - if(EventThreadServices::IsCoreRunning() && mSceneObject) + if(DALI_UNLIKELY(!Dali::Stage::IsCoreThread())) + { + DALI_LOG_ERROR("~RenderTaskList[%p] called from non-UI thread! something unknown issue will be happened!\n", this); + } + + if(DALI_LIKELY(EventThreadServices::IsCoreRunning() && mSceneObject)) { // Remove the render task list using a message to the update manager RemoveRenderTaskListMessage(mEventThreadServices.GetUpdateManager(), *mSceneObject); diff --git a/dali/internal/event/rendering/frame-buffer-impl.cpp b/dali/internal/event/rendering/frame-buffer-impl.cpp index eb01d3c..4b37a4a 100644 --- a/dali/internal/event/rendering/frame-buffer-impl.cpp +++ b/dali/internal/event/rendering/frame-buffer-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -135,7 +135,12 @@ void FrameBuffer::SetSize(uint32_t width, uint32_t height) FrameBuffer::~FrameBuffer() { - if(EventThreadServices::IsCoreRunning() && mRenderObject) + if(DALI_UNLIKELY(!Dali::Stage::IsCoreThread())) + { + DALI_LOG_ERROR("~FrameBuffer[%p] called from non-UI thread! something unknown issue will be happened!\n", this); + } + + if(DALI_LIKELY(EventThreadServices::IsCoreRunning() && mRenderObject)) { RemoveFrameBuffer(mEventThreadServices.GetUpdateManager(), *mRenderObject); } diff --git a/dali/internal/event/rendering/geometry-impl.cpp b/dali/internal/event/rendering/geometry-impl.cpp index 3ec6362..1b965c8 100644 --- a/dali/internal/event/rendering/geometry-impl.cpp +++ b/dali/internal/event/rendering/geometry-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -114,7 +114,12 @@ void Geometry::Initialize() Geometry::~Geometry() { - if(EventThreadServices::IsCoreRunning() && mRenderObject) + if(DALI_UNLIKELY(!Dali::Stage::IsCoreThread())) + { + DALI_LOG_ERROR("~Geometry[%p] called from non-UI thread! something unknown issue will be happened!\n", this); + } + + if(DALI_LIKELY(EventThreadServices::IsCoreRunning() && mRenderObject)) { RemoveGeometry(mEventThreadServices.GetUpdateManager(), *mRenderObject); } diff --git a/dali/internal/event/rendering/renderer-impl.cpp b/dali/internal/event/rendering/renderer-impl.cpp index a34ad18..0132367 100644 --- a/dali/internal/event/rendering/renderer-impl.cpp +++ b/dali/internal/event/rendering/renderer-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -817,7 +817,12 @@ Renderer::Renderer(const SceneGraph::Renderer* sceneObject) Renderer::~Renderer() { - if(EventThreadServices::IsCoreRunning()) + if(DALI_UNLIKELY(!Dali::Stage::IsCoreThread())) + { + DALI_LOG_ERROR("~Renderer[%p] called from non-UI thread! something unknown issue will be happened!\n", this); + } + + if(DALI_LIKELY(EventThreadServices::IsCoreRunning())) { EventThreadServices& eventThreadServices = GetEventThreadServices(); SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager(); diff --git a/dali/internal/event/rendering/sampler-impl.cpp b/dali/internal/event/rendering/sampler-impl.cpp index a1960ee..b3ed0a3 100644 --- a/dali/internal/event/rendering/sampler-impl.cpp +++ b/dali/internal/event/rendering/sampler-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -72,7 +72,12 @@ void Sampler::Initialize() Sampler::~Sampler() { - if(EventThreadServices::IsCoreRunning() && mRenderObject) + if(DALI_UNLIKELY(!Dali::Stage::IsCoreThread())) + { + DALI_LOG_ERROR("~Sampler[%p] called from non-UI thread! something unknown issue will be happened!\n", this); + } + + if(DALI_LIKELY(EventThreadServices::IsCoreRunning() && mRenderObject)) { SceneGraph::UpdateManager& updateManager = mEventThreadServices.GetUpdateManager(); RemoveSamplerMessage(updateManager, *mRenderObject); diff --git a/dali/internal/event/rendering/shader-impl.cpp b/dali/internal/event/rendering/shader-impl.cpp index de3c95e..0e3022a 100644 --- a/dali/internal/event/rendering/shader-impl.cpp +++ b/dali/internal/event/rendering/shader-impl.cpp @@ -318,7 +318,12 @@ void Shader::SetShaderProperty(const Dali::Property::Value& shaderMap) Shader::~Shader() { - if(EventThreadServices::IsCoreRunning()) + if(DALI_UNLIKELY(!Dali::Stage::IsCoreThread())) + { + DALI_LOG_ERROR("~Shader[%p] called from non-UI thread! something unknown issue will be happened!\n", this); + } + + if(DALI_LIKELY(EventThreadServices::IsCoreRunning())) { EventThreadServices& eventThreadServices = GetEventThreadServices(); SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager(); diff --git a/dali/internal/event/rendering/texture-impl.cpp b/dali/internal/event/rendering/texture-impl.cpp index 7488fc5..15a861a 100644 --- a/dali/internal/event/rendering/texture-impl.cpp +++ b/dali/internal/event/rendering/texture-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -93,7 +93,7 @@ Texture::Texture(TextureType::Type type, uint32_t resourceId) void Texture::Initialize() { - if(EventThreadServices::IsCoreRunning()) + if(DALI_LIKELY(EventThreadServices::IsCoreRunning())) { if(mNativeImage) { @@ -117,7 +117,12 @@ void Texture::Initialize() Texture::~Texture() { - if(EventThreadServices::IsCoreRunning() && mTextureKey) + if(DALI_UNLIKELY(!Dali::Stage::IsCoreThread())) + { + DALI_LOG_ERROR("~Texture[%p] called from non-UI thread! something unknown issue will be happened!\n", this); + } + + if(DALI_LIKELY(EventThreadServices::IsCoreRunning() && mTextureKey)) { RemoveTextureMessage(mEventThreadServices.GetUpdateManager(), mTextureKey); } @@ -170,7 +175,7 @@ bool Texture::UploadSubPixelData(PixelDataPtr pixelData, "Parameter value out of range"); bool result(false); - if(EventThreadServices::IsCoreRunning() && mTextureKey) + if(DALI_LIKELY(EventThreadServices::IsCoreRunning() && mTextureKey)) { if(mNativeImage) { @@ -246,16 +251,24 @@ bool Texture::UploadSubPixelData(PixelDataPtr pixelData, } } } + else + { + DALI_LOG_ERROR("Texture[%p] called Upload API from non-UI thread!\n", this); + } return result; } void Texture::GenerateMipmaps() { - if(EventThreadServices::IsCoreRunning() && mTextureKey) + if(DALI_LIKELY(EventThreadServices::IsCoreRunning() && mTextureKey)) { GenerateMipmapsMessage(mEventThreadServices.GetUpdateManager(), mTextureKey); } + else + { + DALI_LOG_ERROR("Texture[%p] called GenerateMipmaps API from non-UI thread!\n", this); + } } uint32_t Texture::GetWidth() const @@ -286,7 +299,7 @@ Dali::TextureType::Type Texture::GetTextureType() const void Texture::SetSize(const ImageDimensions& size) { mSize = size; - if(EventThreadServices::IsCoreRunning() && mTextureKey) + if(DALI_LIKELY(EventThreadServices::IsCoreRunning() && mTextureKey)) { SetTextureSizeMessage(mEventThreadServices.GetUpdateManager(), mTextureKey, mSize); } @@ -295,7 +308,7 @@ void Texture::SetSize(const ImageDimensions& size) void Texture::SetPixelFormat(Pixel::Format format) { mFormat = format; - if(EventThreadServices::IsCoreRunning() && mTextureKey) + if(DALI_LIKELY(EventThreadServices::IsCoreRunning() && mTextureKey)) { SetTextureFormatMessage(mEventThreadServices.GetUpdateManager(), mTextureKey, mFormat); } diff --git a/dali/internal/event/rendering/texture-set-impl.cpp b/dali/internal/event/rendering/texture-set-impl.cpp index 61db3dc..fc99607 100644 --- a/dali/internal/event/rendering/texture-set-impl.cpp +++ b/dali/internal/event/rendering/texture-set-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -187,7 +187,12 @@ void TextureSet::Initialize() TextureSet::~TextureSet() { - if(EventThreadServices::IsCoreRunning()) + if(DALI_UNLIKELY(!Dali::Stage::IsCoreThread())) + { + DALI_LOG_ERROR("~TextureSet[%p] called from non-UI thread! something unknown issue will be happened!\n", this); + } + + if(DALI_LIKELY(EventThreadServices::IsCoreRunning())) { SceneGraph::UpdateManager& updateManager = mEventThreadServices.GetUpdateManager(); RemoveTextureSetMessage(updateManager, *mSceneObject); diff --git a/dali/internal/event/rendering/vertex-buffer-impl.cpp b/dali/internal/event/rendering/vertex-buffer-impl.cpp index 73e67a5..28bcc79 100644 --- a/dali/internal/event/rendering/vertex-buffer-impl.cpp +++ b/dali/internal/event/rendering/vertex-buffer-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -215,7 +215,12 @@ const Render::VertexBuffer* VertexBuffer::GetRenderObject() const VertexBuffer::~VertexBuffer() { - if(EventThreadServices::IsCoreRunning() && mRenderObject) + if(DALI_UNLIKELY(!Dali::Stage::IsCoreThread())) + { + DALI_LOG_ERROR("~VertexBuffer[%p] called from non-UI thread! something unknown issue will be happened!\n", this); + } + + if(DALI_LIKELY(EventThreadServices::IsCoreRunning() && mRenderObject)) { SceneGraph::RemoveVertexBuffer(mEventThreadServices.GetUpdateManager(), *mRenderObject); } -- 2.7.4