From 59d2510654c86c353f1bfec1275358901aa24dae Mon Sep 17 00:00:00 2001 From: wanglei Date: Mon, 19 May 2025 09:13:54 +0000 Subject: [PATCH] Do not dlopen arkweb so in main thread any more Signed-off-by: wanglei --- frameworks/native/appkit/app/main_thread.cpp | 44 ------------------- .../kits/native/appkit/app/main_thread.h | 4 -- 2 files changed, 48 deletions(-) diff --git a/frameworks/native/appkit/app/main_thread.cpp b/frameworks/native/appkit/app/main_thread.cpp index 529647299a7..bc01de4c71e 100644 --- a/frameworks/native/appkit/app/main_thread.cpp +++ b/frameworks/native/appkit/app/main_thread.cpp @@ -1844,11 +1844,6 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con TAG_LOGE(AAFwkTag::APPKIT, "null pAppEvnIml"); } -#if defined(NWEB) - if (!isSystemApp) { - PreLoadWebLib(); - } -#endif #if defined(NWEB) && defined(NWEB_GRAPHIC) if (appLaunchData.IsAllowedNWebPreload()) { HandleNWebPreload(); @@ -1859,45 +1854,6 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con } } -#if defined(NWEB) -void MainThread::PreLoadWebLib() -{ - auto task = [this]() { - std::weak_ptr weakApp = application_; - std::thread([weakApp] { - auto app = weakApp.lock(); - if (app == nullptr) { - TAG_LOGW(AAFwkTag::APPKIT, "null app"); - return; - } - - if (prctl(PR_SET_NAME, "preStartNWeb") < 0) { - TAG_LOGW(AAFwkTag::APPKIT, "Set thread name failed with %{public}d", errno); - } - - std::string nwebPath = app->GetAppContext()->GetCacheDir() + WEB_CACHE_DIR; - struct stat file_stat; - if (stat(nwebPath.c_str(), &file_stat) == -1) { - TAG_LOGW(AAFwkTag::APPKIT, "can not get file_stat"); - return; - } - - time_t current_time = time(nullptr); - double time_difference = difftime(current_time, file_stat.st_mtime); - if (time_difference > CACHE_EFFECTIVE_RANGE) { - TAG_LOGW(AAFwkTag::APPKIT, "web page started more than %{public}d seconds", CACHE_EFFECTIVE_RANGE); - return; - } - - bool isFirstStartUpWeb = (access(nwebPath.c_str(), F_OK) != 0); - TAG_LOGD(AAFwkTag::APPKIT, "TryPreReadLib pre dlopen web so"); - OHOS::NWeb::NWebHelper::TryPreReadLib(isFirstStartUpWeb, app->GetAppContext()->GetBundleCodeDir()); - }).detach(); - }; - mainHandler_->PostTask(task, "MainThread::NWEB_PRELOAD_SO", PRELOAD_DELAY_TIME); -} -#endif - #if defined(NWEB) && defined(NWEB_GRAPHIC) void MainThread::HandleNWebPreload() { diff --git a/interfaces/kits/native/appkit/app/main_thread.h b/interfaces/kits/native/appkit/app/main_thread.h index 773da48fc7c..74c3fea9c20 100644 --- a/interfaces/kits/native/appkit/app/main_thread.h +++ b/interfaces/kits/native/appkit/app/main_thread.h @@ -658,10 +658,6 @@ private: void HandleNWebPreload(); #endif -#if defined(NWEB) - void PreLoadWebLib(); -#endif - class MainHandler : public EventHandler { public: MainHandler(const std::shared_ptr &runner, const sptr &thread); -- Gitee