diff --git a/frameworks/core/components_ng/pattern/window_scene/BUILD.gn b/frameworks/core/components_ng/pattern/window_scene/BUILD.gn index 8bbc16c9468168dd1b1042c648be1c5b6c613edc..46d0414d641f2bc5f6dbfd63b8cecbee9ee8e6d9 100644 --- a/frameworks/core/components_ng/pattern/window_scene/BUILD.gn +++ b/frameworks/core/components_ng/pattern/window_scene/BUILD.gn @@ -31,6 +31,7 @@ build_component_ng("window_scene") { "helper/window_scene_helper.cpp", "root/root_scene_model.cpp", "scene/input_scene.cpp", + "scene/layout_manager_dfx.cpp", "scene/panel_scene.cpp", "scene/system_window_scene.cpp", "scene/transform_scene.cpp", diff --git a/frameworks/core/components_ng/pattern/window_scene/scene/layout_manager_dfx.cpp b/frameworks/core/components_ng/pattern/window_scene/scene/layout_manager_dfx.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d2d7849edd64a19bbc5f1ae92ec18a69c2fa2e7e --- /dev/null +++ b/frameworks/core/components_ng/pattern/window_scene/scene/layout_manager_dfx.cpp @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "layout_manager_dfx.h" +#include "core/pipeline_ng/pipeline_context.h" + +namespace { +constexpr int64_t LAYOUT_MANAGER_INTERVAL = 120; +} + +namespace OHOS::Ace::NG { +LayoutManagerDfx* LayoutManagerDfx::GetInstance() +{ + static LayoutManagerDfx instance; + return &instance; +} + +void LayoutManagerDfx::DumpFlushInfo(TraverseResult& res) +{ + TAG_LOGI(AceLogTag::ACE_WINDOW_PIPELINE, "DumpFlushInfo screenId:%{public}" PRIu64, res.screenId); + for (auto& [winId, uiParam] : res.uiParams) { + TAG_LOGI(AceLogTag::ACE_WINDOW_PIPELINE, "%{public}d|%{public}s|%{public}s|%{public}f|%{public}f|%{public}f|" + "%{public}f|%{public}d", winId, uiParam.sessionName_.c_str(), uiParams.rect_.ToString.c_str(), + uiParams.scaleX_, uiParam.scaleY_, uiParam.transX_, uiParams.transY_, uiParams.interactive_); + } +} + +void LayoutManagerDfx::PerformUIParams() +{ + if (curVsyncCnt_ < LAYOUT_MANAGER_INTERVAL) { + return; + } + std::queue recordQue = {}; + { + std::lock_guard lock(recordMutex_); + recordQue = recordRes_.que; + recordRes_.size = 0; + recordRes_.que = {}; + curVsyncCnt_ = 0; + } + + int32_t cnt = 0; + while (!recordQue.empty()) { + TAG_LOGI(AceLogTag::ACE_WINDOW_PIPELINE, "PerformUIParams cnt:%{public}d", cnt); + DumpFlushInfo(recordQue.front()); + recordQue.pop(); + cnt++; + } +} + +void LayoutManagerDfx::RecordUIParams(TraverseResult uiParams) +{ + std::lock_guard lock(recordMutex_); + if (recordRes_.size >= RECORD_LIST_MAX_CAPACITY) { + recordRes_.que.pop(); + recordRes_.size--; + } + recordRes_.que.push(uiParams); + recordRes_.size++; + curVsyncCnt_++; +} + +void LayoutManagerDfx::ExecuteRecordUIParams(TraverseResult& res) +{ + auto task = [this, res] { + RecordUIParams(res); + PerformUIParams(); + }; + auto pipelineContext = PipelineContext::GetCurrentContext(); + CHECK_NULL_VOID(pipelineContext); + pipelineContext->PostAsyncEvent( + std::move(task), "ExecuteRecordUIParams", TaskExecutor::TaskType::UI); +} +} // namespace OHOS::Ace::NG \ No newline at end of file diff --git a/frameworks/core/components_ng/pattern/window_scene/scene/layout_manager_dfx.h b/frameworks/core/components_ng/pattern/window_scene/scene/layout_manager_dfx.h new file mode 100644 index 0000000000000000000000000000000000000000..77fc8d20ddcd718f45aab9ecc52275b37090cf63 --- /dev/null +++ b/frameworks/core/components_ng/pattern/window_scene/scene/layout_manager_dfx.h @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_LAYOUT_MANAGER_DFX_H +#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_LAYOUT_MANAGER_DFX_H +#include +#include + +#include "core/components_ng/pattern/window_scene/scene/window_scene_layout_manager.h" +#include "session_manager/include/scene_session_manager.h" + +namespace OHOS::Rosen { +struct SessionUIParam; +} + +namespace OHOS::Ace::NG { +constexpr uint32_t RECORD_LIST_MAX_CAPACITY = 10; + +struct recordResult { + uint32_t size = 0; + std::queue que; +} + +class LayoutManagerDfx { +public: + static LayoutManagerDfx* GetInstance(); + void RecordUIParams(TraverseResult uiParams); + void ExecuteRecordUIParams(TraverseResult& res); + +private: + LayoutManagerDfx() = default; + ~LayoutManagerDfx() = default; + void DumpFlushInfo(TraverseResult& res); + void PerformUIParams(); + + std::mutex revordMutex_; + recordResult recordRes_; + int32_t curVsyncCnt_ = 0; +}; +} // namespace OHOS::Ace::NG +#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_LAYOUT_MANAGER_DFX_H \ No newline at end of file diff --git a/frameworks/core/components_ng/pattern/window_scene/scene/window_scene_layout_manager.cpp b/frameworks/core/components_ng/pattern/window_scene/scene/window_scene_layout_manager.cpp index a71dee8be34d66a49130aa1c9fcd06d32b07a079..faab614296b1ef0ad998aa98485a24ae05c87e0d 100644 --- a/frameworks/core/components_ng/pattern/window_scene/scene/window_scene_layout_manager.cpp +++ b/frameworks/core/components_ng/pattern/window_scene/scene/window_scene_layout_manager.cpp @@ -15,9 +15,10 @@ #include "window_scene_layout_manager.h" #include "core/components_ng/pattern/window_scene/helper/window_scene_helper.h" -#include "core/components_ng/pattern/window_scene/scene/window_scene.h" -#include "core/components_ng/pattern/window_scene/scene/panel_scene.h" #include "core/components_ng/pattern/window_scene/scene/input_scene.h" +#include "core/components_ng/pattern/window_scene/scene/layout_manager_dfx.h" +#include "core/components_ng/pattern/window_scene/scene/panel_scene.h" +#include "core/components_ng/pattern/window_scene/scene/window_scene.h" #include "core/components_ng/pattern/window_scene/screen/screen_pattern.h" #include "core/components_ng/render/adapter/rosen_render_context.h" #include "core/pipeline_ng/pipeline_context.h" @@ -280,8 +281,10 @@ void WindowSceneLayoutManager::FlushWindowPatternInfo(const RefPtr& s TAG_LOGI(AceLogTag::ACE_WINDOW_PIPELINE, "------------------- End FlushWindowPatternInfo ------------------"); } RemoveAbnormalId(); + auto recordRes = res; // cannot post ui task, since flush may not excute on next frame Rosen::SceneSessionManager::GetInstance().FlushUIParams(screenId, std::move(res.uiParams)); + Ace::NG::LayoutManagerDfx::GetInstance()->ExecuteRecordUIParams(recordRes); } bool WindowSceneLayoutManager::IsRecentContainerState(const RefPtr& node)