diff --git a/adapter/ohos/entrance/rs_adapter.cpp b/adapter/ohos/entrance/rs_adapter.cpp index dbbcf20decd6f7c789bcf7fbc1b6ee4cfe0702ea..3a2e675fc786c85288bca6ee474358b45c84dd42 100644 --- a/adapter/ohos/entrance/rs_adapter.cpp +++ b/adapter/ohos/entrance/rs_adapter.cpp @@ -44,7 +44,9 @@ void RsAdapter::RsUIDirectorInit( } rsUiDirector->SetRSSurfaceNode(window->GetSurfaceNode()); rsUiDirector->SetCacheDir(cacheDir); - rsUiDirector->Init(true, true); + if (!rsUiDirector->GetRSUIContext()) { + rsUiDirector->Init(true, true); + } } } @@ -65,7 +67,9 @@ void RsAdapter::RsFlushImplicitTransaction( if (!rsUiDirector) { rsUiDirector = Rosen::RSUIDirector::Create(); } - rsUiDirector->Init(true, true); + if (!rsUiDirector->GetRSUIContext()) { + rsUiDirector->Init(true, true); + } auto surfaceNode = dragWindow->GetSurfaceNode(); if (surfaceNode) { auto rsUiContext = surfaceNode->GetRSUIContext(); @@ -101,7 +105,9 @@ void RsAdapter::RsFlushImplicitTransactionWithRoot( if (!rsUiDirector) { rsUiDirector = Rosen::RSUIDirector::Create(); } - rsUiDirector->Init(true, true); + if (!rsUiDirector->GetRSUIContext()) { + rsUiDirector->Init(true, true); + } auto surfaceNode = dragWindow->GetSurfaceNode(); std::shared_ptr rsUiContext; if (surfaceNode) { diff --git a/adapter/ohos/entrance/subwindow/subwindow_ohos.cpp b/adapter/ohos/entrance/subwindow/subwindow_ohos.cpp index 8812df25bcac76dfab4df7abc231e012404f795f..fa504b6e4df29dd59861c46be7c2d2ddd1a3ddf7 100644 --- a/adapter/ohos/entrance/subwindow/subwindow_ohos.cpp +++ b/adapter/ohos/entrance/subwindow/subwindow_ohos.cpp @@ -250,7 +250,17 @@ void SubwindowOhos::InitWindowRSUIDirector(const RefPtr& if (context != nullptr) { context->SetRSUIDirector(rsUiDirector); } - rsUiDirector->Init(true, true); + if (!rsUiDirector->GetRSUIContext()) { + rsUiDirector->Init(true, true); + } + auto id = container->GetInstanceId(); + rsUiDirector->SetUITaskRunner( + [taskExecutor = container->GetTaskExecutor(), id]( + const std::function& task, uint32_t delay) { + ContainerScope scope(id); + taskExecutor->PostDelayedTask( + task, TaskExecutor::TaskType::UI, delay, "ArkUIRenderServiceTask", PriorityType::HIGH); + }, 0, true); TAG_LOGI(AceLogTag::ACE_SUB_WINDOW, "UIContent Init Rosen Backend"); } #endif @@ -1528,7 +1538,17 @@ void SubwindowOhos::InitDialogWindowRSUIDirector(const RefPtrSetRSUIDirector(rsUiDirector); } - rsUiDirector->Init(true, true); + if (!rsUiDirector->GetRSUIContext()) { + rsUiDirector->Init(true, true); + } + auto id = container->GetInstanceId(); + rsUiDirector->SetUITaskRunner( + [taskExecutor = container->GetTaskExecutor(), id]( + const std::function& task, uint32_t delay) { + ContainerScope scope(id); + taskExecutor->PostDelayedTask( + task, TaskExecutor::TaskType::UI, delay, "ArkUIRenderServiceTask", PriorityType::HIGH); + }, 0, true); } #endif } diff --git a/adapter/ohos/osal/system_properties.cpp b/adapter/ohos/osal/system_properties.cpp index 9617b85dae554fc11b73c8ad926ba3bc4bb631ca..8c873636228183971996b62e400dbbc2c6c52a1c 100644 --- a/adapter/ohos/osal/system_properties.cpp +++ b/adapter/ohos/osal/system_properties.cpp @@ -284,7 +284,7 @@ bool IsContainerDeleteFlag() bool IsMultiInstanceEnabled() { - return (system::GetParameter("persist.rosen.rsclientmultiinstance.enabled", "0") != "0"); + return (system::GetParameter("persist.rosen.rsclientmultiinstance.enabled", "1") != "0"); } bool IsLayoutDetectEnabled() @@ -926,6 +926,9 @@ ACE_WEAK_SYM bool SystemProperties::GetDebugEnabled() ACE_WEAK_SYM bool SystemProperties::GetLayoutDetectEnabled() { + if (GetDeviceType() != DeviceType::PHONE) { + return false; + } return layoutDetectEnabled_; } diff --git a/frameworks/core/components_ng/render/adapter/rosen_animation_utils.cpp b/frameworks/core/components_ng/render/adapter/rosen_animation_utils.cpp index cd4c3b890d5abfc6dee665ee89c45792263432fd..eb6ba124ad69e94f3d26de6c10b73fae9eed7e79 100644 --- a/frameworks/core/components_ng/render/adapter/rosen_animation_utils.cpp +++ b/frameworks/core/components_ng/render/adapter/rosen_animation_utils.cpp @@ -330,8 +330,10 @@ std::shared_ptr AnimationUtils::CreateInte auto wrappedOnFinish = GetWrappedCallback(callback); Rosen::RSAnimationTimingProtocol timingProtocol; Rosen::RSAnimationTimingCurve curve; + auto context = PipelineBase::GetCurrentContext(); + auto rsUIContext = GetRSUIContext(context); interactiveAnimation->interactiveAnimation_ = - Rosen::RSInteractiveImplictAnimator::Create(timingProtocol, curve); + Rosen::RSInteractiveImplictAnimator::Create(rsUIContext, timingProtocol, curve); CHECK_NULL_RETURN(interactiveAnimation->interactiveAnimation_, nullptr); if (addCallback) { interactiveAnimation->interactiveAnimation_->AddAnimation(addCallback); diff --git a/frameworks/core/components_ng/render/adapter/rosen_render_context.cpp b/frameworks/core/components_ng/render/adapter/rosen_render_context.cpp index ca26542a8b8d6a3382992920ebf4a0edbeebc35a..d7da197594f1e03dec1bef9a8aa3afb3c2bf999e 100755 --- a/frameworks/core/components_ng/render/adapter/rosen_render_context.cpp +++ b/frameworks/core/components_ng/render/adapter/rosen_render_context.cpp @@ -7431,7 +7431,7 @@ void RosenRenderContext::UpdateWindowBlur() CHECK_NULL_VOID(rsWindow); auto surfaceNode = rsWindow->GetSurfaceNode(); CHECK_NULL_VOID(surfaceNode); - auto rsUIContext = rsNode_->GetRSUIContext(); + auto rsUIContext = surfaceNode->GetRSUIContext(); auto rsNodeTmp = rsUIContext ? rsUIContext->GetNodeMap().GetNode(surfaceNode->GetId()) : Rosen::RSNodeMap::Instance().GetNode(surfaceNode->GetId()); AnimationOption option; @@ -7444,7 +7444,7 @@ void RosenRenderContext::UpdateWindowBlur() windowBlurModifier_->SetBehindWindowFilterSaturation(blurParam->saturation); windowBlurModifier_->SetBehindWindowFilterBrightness(blurParam->brightness); windowBlurModifier_->SetBehindWindowFilterMaskColor(Rosen::RSColor(rgbaColor)); - if (needAddModifier) { + if (needAddModifier && rsNodeTmp) { rsNodeTmp->AddModifier(windowBlurModifier_); } #else diff --git a/frameworks/core/components_ng/render/adapter/rosen_window.cpp b/frameworks/core/components_ng/render/adapter/rosen_window.cpp index 861601771abb75b604ed3a4dfd473af22b470e38..d643d543c5f639e5aca20bfd948c64bc5d138204 100644 --- a/frameworks/core/components_ng/render/adapter/rosen_window.cpp +++ b/frameworks/core/components_ng/render/adapter/rosen_window.cpp @@ -97,6 +97,14 @@ RosenWindow::RosenWindow(const OHOS::sptr& window, RefPtrSetCacheDir(AceApplicationInfo::GetInstance().GetDataFileDirPath()); rsUIDirector_->Init(); + rsUIDirector_->SetUITaskRunner( + [taskExecutor, id](const std::function& task, uint32_t delay) { + ContainerScope scope(id); + CHECK_NULL_VOID(taskExecutor); + taskExecutor->PostDelayedTask( + task, TaskExecutor::TaskType::UI, delay, "ArkUIRosenWindowRenderServiceTask", PriorityType::HIGH); + }, + id); } else { auto rsUIDirector = window->GetRSUIDirector(); if (rsUIDirector) { @@ -112,17 +120,18 @@ RosenWindow::RosenWindow(const OHOS::sptr& window, RefPtr(surfaceNode->GetId())); } rsUIDirector_->SetCacheDir(AceApplicationInfo::GetInstance().GetDataFileDirPath()); - rsUIDirector_->Init(true, true); + if (!rsUIDirector_->GetRSUIContext()) { + rsUIDirector_->Init(true, true); + } + rsUIDirector_->SetUITaskRunner( + [taskExecutor, id](const std::function& task, uint32_t delay) { + ContainerScope scope(id); + CHECK_NULL_VOID(taskExecutor); + taskExecutor->PostDelayedTask( + task, TaskExecutor::TaskType::UI, delay, "ArkUIRosenWindowRenderServiceTask", PriorityType::HIGH); + }, + 0, true); } - - rsUIDirector_->SetUITaskRunner( - [taskExecutor, id](const std::function& task, uint32_t delay) { - ContainerScope scope(id); - CHECK_NULL_VOID(taskExecutor); - taskExecutor->PostDelayedTask( - task, TaskExecutor::TaskType::UI, delay, "ArkUIRosenWindowRenderServiceTask", PriorityType::HIGH); - }, - id); } void RosenWindow::Init() diff --git a/test/unittest/core/base/frame_node_test_ng.cpp b/test/unittest/core/base/frame_node_test_ng.cpp index 7fbc8f01b91900101bb9d670ce4521e079db51d0..cc2c8bc615269b8a22f1996e50d3d89c32a830a2 100644 --- a/test/unittest/core/base/frame_node_test_ng.cpp +++ b/test/unittest/core/base/frame_node_test_ng.cpp @@ -2814,4 +2814,25 @@ HWTEST_F(FrameNodeTestNg, FrameNodeTestNg312, TestSize.Level1) */ EXPECT_EQ(frameNode->CallAIFunction("OTHERFunction", "params1: 1"), AI_CALL_FUNCNAME_INVALID); } + +/** + * @tc.name: AttachContext001 + * @tc.desc: Test frame node method + * @tc.type: FUNC + */ +HWTEST_F(FrameNodeTestNg, AttachContext001, TestSize.Level1) +{ + auto context = PipelineContext::GetCurrentContext(); + ASSERT_NE(context, nullptr); + auto node = FrameNode::CreateFrameNode("main", 1, AceType::MakeRefPtr(), true); + ASSERT_NE(node, nullptr); + node->GetOrCreateGestureEventHub(); + SystemProperties::multiInstanceEnabled_ = true; + node->AttachContext(AceType::RawPtr(context)); + auto mockRenderContext = AceType::MakeRefPtr(); + node->renderContext_ = mockRenderContext; + EXPECT_EQ(node->context_, AceType::RawPtr(context)); + node->DetachContext(true); + EXPECT_EQ(node->context_, nullptr); +} } // namespace OHOS::Ace::NG