!38158 组件截图:修复delegate为空应用无法捕获异常直接crash的问题,增加get接口维测日志

Merge pull request !38158 from 胡清云/componentSnapshot_0718
This commit is contained in:
openharmony_ci 2024-07-19 06:19:48 +00:00 committed by Gitee
commit 17417235fa
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 9 additions and 17 deletions

View File

@ -150,29 +150,18 @@ void ComponentSnapshot::Get(const std::string& componentId, JsCallback&& callbac
return;
}
auto rsNode = GetRsNode(node);
if (node->GetIsLayoutNode()) {
std::list<RefPtr<FrameNode>> children;
node->GetOneDepthVisibleFrame(children);
if (children.empty()) {
return;
}
auto rsNode = GetRsNode(children.front());
if (!rsNode) {
callback(nullptr, ERROR_CODE_INTERNAL_ERROR, nullptr);
TAG_LOGW(AceLogTag::ACE_COMPONENT_SNAPSHOT,
"RsNode is null from FrameNode(id=%{public}s)",
componentId.c_str());
return;
}
auto& rsInterface = Rosen::RSInterfaces::GetInstance();
rsInterface.TakeSurfaceCaptureForUI(
rsNode, std::make_shared<CustomizedCallback>(std::move(callback), nullptr),
options.scale, options.scale, options.waitUntilRenderFinished);
return;
node = children.front();
rsNode = GetRsNode(children.front());
}
auto rsNode = GetRsNode(node);
if (!rsNode) {
callback(nullptr, ERROR_CODE_INTERNAL_ERROR, nullptr);
TAG_LOGW(AceLogTag::ACE_COMPONENT_SNAPSHOT,
@ -180,6 +169,9 @@ void ComponentSnapshot::Get(const std::string& componentId, JsCallback&& callbac
componentId.c_str());
return;
}
TAG_LOGI(AceLogTag::ACE_COMPONENT_SNAPSHOT,
"Get ComponentSnapshot key=%{public}s Id=%{public}d Tag=%{public}s RsNodeId=%{public}" PRIu64 "",
componentId.c_str(), node->GetId(), node->GetTag().c_str(), rsNode->GetId());
auto& rsInterface = Rosen::RSInterfaces::GetInstance();
rsInterface.TakeSurfaceCaptureForUI(rsNode, std::make_shared<CustomizedCallback>(std::move(callback), nullptr),
options.scale, options.scale, options.waitUntilRenderFinished);

View File

@ -303,8 +303,8 @@ static napi_value JSSnapshotGet(napi_env env, napi_callback_info info)
TAG_LOGW(AceLogTag::ACE_COMPONENT_SNAPSHOT,
"Can'nt get delegate of ace_engine. param: %{public}s",
componentId.c_str());
NapiThrow(env, "ace engine delegate is null", ERROR_CODE_INTERNAL_ERROR);
napi_close_escapable_handle_scope(env, scope);
auto callback = helper.CreateCallback(&result);
callback(nullptr, ERROR_CODE_INTERNAL_ERROR, nullptr);
return result;
}