From 2c0d36520a464c9c0235fbb09a1b6f380a8b7d16 Mon Sep 17 00:00:00 2001 From: wanglei Date: Tue, 19 Aug 2025 03:08:18 +0000 Subject: [PATCH] remove preload arkweb so Signed-off-by: wanglei --- frameworks/native/appkit/app/main_thread.cpp | 50 -------------------- 1 file changed, 50 deletions(-) diff --git a/frameworks/native/appkit/app/main_thread.cpp b/frameworks/native/appkit/app/main_thread.cpp index 3703d54f455..cdf3c9b81e4 100644 --- a/frameworks/native/appkit/app/main_thread.cpp +++ b/frameworks/native/appkit/app/main_thread.cpp @@ -194,12 +194,6 @@ const char* PRELOAD_APP_STARTUP = "PreloadAppStartup"; const int32_t TYPE_RESERVE = 1; const int32_t TYPE_OTHERS = 2; -#if defined(NWEB) -constexpr int32_t PRELOAD_DELAY_TIME = 2000; //millisecond -constexpr int32_t CACHE_EFFECTIVE_RANGE = 60 * 60 * 24 * 3; // second -const std::string WEB_CACHE_DIR = "/web"; -#endif - #if defined(NWEB) && defined(NWEB_GRAPHIC) const std::string NWEB_SURFACE_NODE_NAME = "nwebPreloadSurface"; const std::string BLANK_URL = "about:blank"; @@ -1950,11 +1944,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(); @@ -2035,45 +2024,6 @@ void MainThread::InitUncatchableTask(JsEnv::UncatchableTask &uncatchableTask, co }; } -#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() { -- Gitee