diff --git a/frameworks/native/ability/native/ability_runtime/js_ui_ability.cpp b/frameworks/native/ability/native/ability_runtime/js_ui_ability.cpp index 9a118d1843..5a48fd7472 100644 --- a/frameworks/native/ability/native/ability_runtime/js_ui_ability.cpp +++ b/frameworks/native/ability/native/ability_runtime/js_ui_ability.cpp @@ -823,6 +823,7 @@ void JsUIAbility::DoOnForeground(const Want &want) TAG_LOGD(AAFwkTag::UIABILITY, "move scene to foreground, sceneFlag_: %{public}d", UIAbility::sceneFlag_); AddLifecycleEventBeforeJSCall(FreezeUtil::TimeoutState::FOREGROUND, METHOD_NAME); + HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, "scene_->GoForeground"); scene_->GoForeground(UIAbility::sceneFlag_); TAG_LOGD(AAFwkTag::UIABILITY, "end"); } @@ -847,6 +848,7 @@ void JsUIAbility::DoOnForegroundForSceneIsNull(const Want &want) Rosen::WMError ret = Rosen::WMError::WM_OK; auto sessionToken = GetSessionToken(); auto identityToken = GetIdentityToken(); + HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, "scene_->Init"); if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled() && sessionToken != nullptr) { abilityContext_->SetWeakSessionToken(sessionToken); ret = scene_->Init(displayId, abilityContext_, sceneListener_, option, sessionToken, identityToken); diff --git a/frameworks/native/appkit/ability_runtime/app/js_ability_stage.cpp b/frameworks/native/appkit/ability_runtime/app/js_ability_stage.cpp index 4c72be2ee6..9e3295a9e4 100644 --- a/frameworks/native/appkit/ability_runtime/app/js_ability_stage.cpp +++ b/frameworks/native/appkit/ability_runtime/app/js_ability_stage.cpp @@ -27,6 +27,7 @@ #include "napi_common_want.h" #include "ohos_application.h" #include "startup_manager.h" +#include "hitrace_meter.h" #include #include #include @@ -195,6 +196,7 @@ void JsAbilityStage::OnCreate(const AAFwk::Want &want) const TAG_LOGE(AAFwkTag::APPKIT, "Failed to get 'onCreate' from AbilityStage object"); return; } + HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__); napi_call_function(env, obj, methodOnCreate, 0, nullptr, nullptr); auto delegator = AppExecFwk::AbilityDelegatorRegistry::GetAbilityDelegator(); @@ -634,6 +636,7 @@ napi_value JsAbilityStage::CallObjectMethod(const char* name, napi_value const * } napi_value result = nullptr; + HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__); napi_call_function(env, obj, method, argc, argv, &result); return result; } diff --git a/frameworks/native/runtime/js_runtime.cpp b/frameworks/native/runtime/js_runtime.cpp index bff65bfc14..9e5ebcfb55 100644 --- a/frameworks/native/runtime/js_runtime.cpp +++ b/frameworks/native/runtime/js_runtime.cpp @@ -150,6 +150,7 @@ napi_value CanIUse(napi_env env, napi_callback_info info) void InitSyscapModule(napi_env env, napi_value globalObject) { + HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__); const char *moduleName = "JsRuntime"; BindNativeFunction(env, globalObject, "canIUse", moduleName, CanIUse); } @@ -247,6 +248,7 @@ std::unique_ptr JsRuntime::Create(const Options& options) void JsRuntime::StartDebugMode(const DebugOption dOption) { + HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__); if (!system::GetBoolParameter(DEVELOPER_MODE_STATE, false)) { TAG_LOGE(AAFwkTag::JSRUNTIME, "Developer Mode is false."); return; @@ -318,6 +320,7 @@ void JsRuntime::StopDebugMode() void JsRuntime::InitConsoleModule() { + HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__); CHECK_POINTER(jsEnv_); jsEnv_->InitConsoleModule(); } @@ -389,6 +392,7 @@ int32_t JsRuntime::JsperfProfilerCommandParse(const std::string &command, int32_ void JsRuntime::StartProfiler(const DebugOption dOption) { + HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__); if (!system::GetBoolParameter(DEVELOPER_MODE_STATE, false)) { TAG_LOGE(AAFwkTag::JSRUNTIME, "Developer Mode is false."); return; @@ -664,6 +668,7 @@ void JsRuntime::FinishPreload() void JsRuntime::PostPreload(const Options& options) { + HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__); auto vm = GetEcmaVm(); CHECK_POINTER(vm); auto env = GetNapiEnv(); @@ -695,6 +700,7 @@ void JsRuntime::PostPreload(const Options& options) void JsRuntime::LoadAotFile(const Options& options) { + HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__); auto vm = GetEcmaVm(); CHECK_POINTER(vm); if (options.hapPath.empty()) { @@ -915,6 +921,7 @@ void JsRuntime::ReloadFormComponent() bool JsRuntime::InitLoop(bool isStage) { + HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__); CHECK_POINTER_AND_RETURN(jsEnv_, false); return jsEnv_->InitLoop(isStage); } @@ -941,6 +948,7 @@ void JsRuntime::SetAppLibPath(const AppLibPathMap& appLibPaths, const bool& isSy void JsRuntime::InitSourceMap(const std::shared_ptr operatorObj) { + HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__); CHECK_POINTER(jsEnv_); jsEnv_->InitSourceMap(operatorObj); JsEnv::SourceMap::RegisterReadSourceMapCallback(JsRuntime::ReadSourceMapData); @@ -1378,12 +1386,14 @@ void JsRuntime::UpdateModuleNameAndAssetPath(const std::string& moduleName) void JsRuntime::RegisterUncaughtExceptionHandler(const JsEnv::UncaughtExceptionInfo& uncaughtExceptionInfo) { + HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__); CHECK_POINTER(jsEnv_); jsEnv_->RegisterUncaughtExceptionHandler(uncaughtExceptionInfo); } void JsRuntime::RegisterQuickFixQueryFunc(const std::map& moduleAndPath) { + HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__); auto vm = GetEcmaVm(); CHECK_POINTER(vm); for (auto it = moduleAndPath.begin(); it != moduleAndPath.end(); it++) { @@ -1492,12 +1502,14 @@ void JsRuntime::FreeNativeReference(std::unique_ptr uniqueNativ void JsRuntime::InitTimerModule() { + HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__); CHECK_POINTER(jsEnv_); jsEnv_->InitTimerModule(); } void JsRuntime::InitWorkerModule(const Options& options) { + HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__); CHECK_POINTER(jsEnv_); std::shared_ptr workerInfo = std::make_shared(); workerInfo->codePath = options.codePath; @@ -1517,18 +1529,21 @@ void JsRuntime::InitWorkerModule(const Options& options) void JsRuntime::ReInitJsEnvImpl(const Options& options) { + HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__); CHECK_POINTER(jsEnv_); jsEnv_->ReInitJsEnvImpl(std::make_unique(options.eventRunner)); } void JsRuntime::SetModuleLoadChecker(const std::shared_ptr moduleCheckerDelegate) const { + HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__); CHECK_POINTER(jsEnv_); jsEnv_->SetModuleLoadChecker(moduleCheckerDelegate); } void JsRuntime::SetRequestAotCallback() { + HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__); CHECK_POINTER(jsEnv_); auto callback = [](const std::string& bundleName, const std::string& moduleName, int32_t triggerMode) -> int32_t { auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();