From 2a46cc6bed769a2e466bf238b02fb2a22374b5fd Mon Sep 17 00:00:00 2001 From: TinyLight Date: Wed, 9 Jul 2025 08:11:07 +0000 Subject: [PATCH 1/6] =?UTF-8?q?update=20appspawn.gni.=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E9=A2=84=E5=8A=A0=E8=BD=BD=E9=85=8D=E7=BD=AE=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: TinyLight --- appspawn.gni | 1 + 1 file changed, 1 insertion(+) diff --git a/appspawn.gni b/appspawn.gni index cdc3fa62..b4d62329 100644 --- a/appspawn.gni +++ b/appspawn.gni @@ -40,6 +40,7 @@ declare_args() { appspawn_support_local_debugger = false appspawn_hitrace_option = true appspawn_napi_preload_path = "../appspawn_preload.json" + init_feature_arkweb_pre_load = false } if (!defined(global_parts_info) || -- Gitee From d3337c1e4a70e5540fbc2259740a0f687ed7f2df Mon Sep 17 00:00:00 2001 From: TinyLight Date: Wed, 9 Jul 2025 08:12:31 +0000 Subject: [PATCH 2/6] =?UTF-8?q?update=20modules/nweb=5Fadapter/BUILD.gn.?= =?UTF-8?q?=20=E9=A2=84=E5=8A=A0=E8=BD=BD=E9=85=8D=E7=BD=AE=E9=A1=B9-gn?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: TinyLight --- modules/nweb_adapter/BUILD.gn | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/nweb_adapter/BUILD.gn b/modules/nweb_adapter/BUILD.gn index acd15abe..5c0fb810 100644 --- a/modules/nweb_adapter/BUILD.gn +++ b/modules/nweb_adapter/BUILD.gn @@ -31,6 +31,9 @@ ohos_shared_library("appspawn_nweb") { if (target_cpu == "x86_64") { defines += [ "webview_x86_64" ] } + if (init_feature_arkweb_pre_load) { + defines += [ "pre_load_rk3568" ] + } external_deps = [ "c_utils:utils", -- Gitee From 12f95fe31494f7904128b3ac58481e878a7916dc Mon Sep 17 00:00:00 2001 From: TinyLight Date: Wed, 9 Jul 2025 08:28:42 +0000 Subject: [PATCH 3/6] =?UTF-8?q?1update=20modules/nweb=5Fadapter/nwebspawn?= =?UTF-8?q?=5Fadapter.cpp.=20=E6=8C=89=E6=9D=A1=E4=BB=B6=E6=89=93=E5=BC=80?= =?UTF-8?q?=E9=A2=84=E7=BD=AE=E9=A1=B9=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: TinyLight --- appspawn.gni | 2 +- bundle.json | 3 +- modules/nweb_adapter/BUILD.gn | 2 +- modules/nweb_adapter/nwebspawn_adapter.cpp | 47 +++++++++++++++++++++- 4 files changed, 49 insertions(+), 5 deletions(-) diff --git a/appspawn.gni b/appspawn.gni index b4d62329..e07ce679 100644 --- a/appspawn.gni +++ b/appspawn.gni @@ -40,7 +40,7 @@ declare_args() { appspawn_support_local_debugger = false appspawn_hitrace_option = true appspawn_napi_preload_path = "../appspawn_preload.json" - init_feature_arkweb_pre_load = false + appspawn_arkweb_pre_load = true } if (!defined(global_parts_info) || diff --git a/bundle.json b/bundle.json index 7b73228e..cb1e47c7 100644 --- a/bundle.json +++ b/bundle.json @@ -31,7 +31,8 @@ "appspawn_custom_sandbox", "appspawn_support_nosharefs", "appspawn_support_local_debugger", - "appspawn_napi_preload_path" + "appspawn_napi_preload_path", + "appspawn_arkweb_pre_load" ], "rom": "296KB", "ram": "13125KB", diff --git a/modules/nweb_adapter/BUILD.gn b/modules/nweb_adapter/BUILD.gn index 5c0fb810..a3c9a754 100644 --- a/modules/nweb_adapter/BUILD.gn +++ b/modules/nweb_adapter/BUILD.gn @@ -31,7 +31,7 @@ ohos_shared_library("appspawn_nweb") { if (target_cpu == "x86_64") { defines += [ "webview_x86_64" ] } - if (init_feature_arkweb_pre_load) { + if (appspawn_arkweb_pre_load) { defines += [ "pre_load_rk3568" ] } diff --git a/modules/nweb_adapter/nwebspawn_adapter.cpp b/modules/nweb_adapter/nwebspawn_adapter.cpp index c8562fa1..557327e7 100644 --- a/modules/nweb_adapter/nwebspawn_adapter.cpp +++ b/modules/nweb_adapter/nwebspawn_adapter.cpp @@ -55,6 +55,12 @@ namespace { const std::string OHOS_ADPT_GLUE_SRC_LIB_PATH = "/system/lib64/libohos_adapter_glue_source.z.so"; +#if defined(pre_load_rk3568) + const std::string ARKWEB_BUNDLE_NAME = "com.ohos.arkwebcore"; +#else + const std::string ARKWEB_BUNDLE_NAME = "com.huawei.hmos.arkwebcore"; +#endif + typedef enum { PRELOAD_NO = 0, // 不预加载 PRELOAD_PARTIAL = 1, // 只预加载libohos_adapter_glue_source.z.so @@ -160,12 +166,40 @@ APPSPAWN_STATIC int RunChildProcessor(AppSpawnContent *content, AppSpawnClient * return 0; } +static std::string GetOHOSAdptGlueSrcLibPath() +{ +#if defined(webview_arm64) + const std::string ARK_WEB_CORE_HAP_LIB_PATH = + "/system/lib64/libohos_adapter_glue_source.z.so"; +#else + const std::string ARK_WEB_CORE_HAP_LIB_PATH = + "/system/lib/libohos_adapter_glue_source.z.so"; +#endif + return ARK_WEB_CORE_HAP_LIB_PATH; +} + +static std::string GetArkWebEngineLibPath() +{ +#if defined(webview_arm64) + const std::string ARK_WEB_CORE_HAP_LIB_PATH = + "/data/app/el1/bundle/public/" + ARKWEB_BUNDLE_NAME + "/libs/arm64"; +#elif defined(webview_x86_64) + const std::string ARK_WEB_CORE_HAP_LIB_PATH = + "/data/app/el1/bundle/public/" + ARKWEB_BUNDLE_NAME + "/libs/x86_64"; +#else + const std::string ARK_WEB_CORE_HAP_LIB_PATH = + "/data/app/el1/bundle/public/" + ARKWEB_BUNDLE_NAME + "/libs/arm"; +#endif + return ARK_WEB_CORE_HAP_LIB_PATH; +} + static void PreLoadArkWebEngineLib() { Dl_namespace dlns; Dl_namespace ndkns; dlns_init(&dlns, "nweb_ns"); - dlns_create(&dlns, ARK_WEB_ENGINE_LIB_PRELOAD_PATH.c_str()); + const std::string engine_lib_path = GetArkWebEngineLibPath(); + dlns_create(&dlns, engine_lib_path.c_str()); dlns_get("ndk", &ndkns); dlns_inherit(&dlns, &ndkns, "allow_all_shared_libs"); void *webEngineHandle = dlopen_ns(&dlns, ARK_WEB_ENGINE_LIB_NAME.c_str(), RTLD_NOW | RTLD_GLOBAL); @@ -176,12 +210,16 @@ static void PreLoadArkWebEngineLib() static void PreLoadOHOSAdptGlueSrcLib() { - void *ohosAdptGlueSrcHandle = dlopen(OHOS_ADPT_GLUE_SRC_LIB_PATH.c_str(), RTLD_NOW | RTLD_GLOBAL); + const std::string glue_src_lib_path = GetOHOSAdptGlueSrcLibPath(); + void *ohosAdptGlueSrcHandle = dlopen(glue_src_lib_path.c_str(), RTLD_NOW | RTLD_GLOBAL); if (!ohosAdptGlueSrcHandle) { APPSPAWN_LOGE("Fail to dlopen libohos_adapter_glue_source.z.so, errno: %{public}d", errno); + } else { + APPSPAWN_LOGE("success to dlopen libohos_adapter_glue_source.z.so"); } } +#if !defined(pre_load_rk3568) static int GetSysParamPreLoadMode() { const int BUFFER_LEN = 8; @@ -190,6 +228,7 @@ static int GetSysParamPreLoadMode() int ret = std::atoi(preLoadMode); return ret; } +#endif static int PreLoadNwebSpawn(AppSpawnMgr *content) { @@ -201,7 +240,11 @@ static int PreLoadNwebSpawn(AppSpawnMgr *content) RegChildLooper(&content->content, RunChildProcessor); // preload render lib +#if defined(pre_load_rk3568) + int preloadMode = RenderPreLoadMode::PRELOAD_FULL; +#else int preloadMode = GetSysParamPreLoadMode(); +#endif APPSPAWN_LOGI("NwebSpawn preload render lib mode: %{public}d", preloadMode); if (preloadMode == PRELOAD_PARTIAL) { PreLoadOHOSAdptGlueSrcLib(); -- Gitee From bdcff1c6944a6fa11c7c2582b0ef4ec3560c84cb Mon Sep 17 00:00:00 2001 From: TinyLight Date: Sat, 12 Jul 2025 18:53:19 +0800 Subject: [PATCH 4/6] delay nwebspawn start timing Signed-off-by: TinyLight --- appspawn.gni | 2 +- bundle.json | 2 +- modules/nweb_adapter/BUILD.gn | 4 ++-- modules/nweb_adapter/nwebspawn_adapter.cpp | 16 +++++++--------- nwebspawn.cfg | 9 +++++++++ 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/appspawn.gni b/appspawn.gni index e07ce679..2f0fe1f0 100644 --- a/appspawn.gni +++ b/appspawn.gni @@ -40,7 +40,7 @@ declare_args() { appspawn_support_local_debugger = false appspawn_hitrace_option = true appspawn_napi_preload_path = "../appspawn_preload.json" - appspawn_arkweb_pre_load = true + appspawn_arkweb_preload = true } if (!defined(global_parts_info) || diff --git a/bundle.json b/bundle.json index cb1e47c7..6582a611 100644 --- a/bundle.json +++ b/bundle.json @@ -32,7 +32,7 @@ "appspawn_support_nosharefs", "appspawn_support_local_debugger", "appspawn_napi_preload_path", - "appspawn_arkweb_pre_load" + "appspawn_arkweb_preload" ], "rom": "296KB", "ram": "13125KB", diff --git a/modules/nweb_adapter/BUILD.gn b/modules/nweb_adapter/BUILD.gn index a3c9a754..35ea32b4 100644 --- a/modules/nweb_adapter/BUILD.gn +++ b/modules/nweb_adapter/BUILD.gn @@ -31,8 +31,8 @@ ohos_shared_library("appspawn_nweb") { if (target_cpu == "x86_64") { defines += [ "webview_x86_64" ] } - if (appspawn_arkweb_pre_load) { - defines += [ "pre_load_rk3568" ] + if (appspawn_arkweb_preload) { + defines += [ "preload_rk3568" ] } external_deps = [ diff --git a/modules/nweb_adapter/nwebspawn_adapter.cpp b/modules/nweb_adapter/nwebspawn_adapter.cpp index 557327e7..9bd890e8 100644 --- a/modules/nweb_adapter/nwebspawn_adapter.cpp +++ b/modules/nweb_adapter/nwebspawn_adapter.cpp @@ -55,7 +55,7 @@ namespace { const std::string OHOS_ADPT_GLUE_SRC_LIB_PATH = "/system/lib64/libohos_adapter_glue_source.z.so"; -#if defined(pre_load_rk3568) +#if defined(preload_rk3568) const std::string ARKWEB_BUNDLE_NAME = "com.ohos.arkwebcore"; #else const std::string ARKWEB_BUNDLE_NAME = "com.huawei.hmos.arkwebcore"; @@ -198,8 +198,8 @@ static void PreLoadArkWebEngineLib() Dl_namespace dlns; Dl_namespace ndkns; dlns_init(&dlns, "nweb_ns"); - const std::string engine_lib_path = GetArkWebEngineLibPath(); - dlns_create(&dlns, engine_lib_path.c_str()); + const std::string arkWebEngineLibPath = GetArkWebEngineLibPath(); + dlns_create(&dlns, arkWebEngineLibPath.c_str()); dlns_get("ndk", &ndkns); dlns_inherit(&dlns, &ndkns, "allow_all_shared_libs"); void *webEngineHandle = dlopen_ns(&dlns, ARK_WEB_ENGINE_LIB_NAME.c_str(), RTLD_NOW | RTLD_GLOBAL); @@ -210,16 +210,14 @@ static void PreLoadArkWebEngineLib() static void PreLoadOHOSAdptGlueSrcLib() { - const std::string glue_src_lib_path = GetOHOSAdptGlueSrcLibPath(); - void *ohosAdptGlueSrcHandle = dlopen(glue_src_lib_path.c_str(), RTLD_NOW | RTLD_GLOBAL); + const std::string ohosAdptGlueSrcLibPath = GetOHOSAdptGlueSrcLibPath(); + void *ohosAdptGlueSrcHandle = dlopen(ohosAdptGlueSrcLibPath.c_str(), RTLD_NOW | RTLD_GLOBAL); if (!ohosAdptGlueSrcHandle) { APPSPAWN_LOGE("Fail to dlopen libohos_adapter_glue_source.z.so, errno: %{public}d", errno); - } else { - APPSPAWN_LOGE("success to dlopen libohos_adapter_glue_source.z.so"); } } -#if !defined(pre_load_rk3568) +#if !defined(preload_rk3568) static int GetSysParamPreLoadMode() { const int BUFFER_LEN = 8; @@ -240,7 +238,7 @@ static int PreLoadNwebSpawn(AppSpawnMgr *content) RegChildLooper(&content->content, RunChildProcessor); // preload render lib -#if defined(pre_load_rk3568) +#if defined(preload_rk3568) int preloadMode = RenderPreLoadMode::PRELOAD_FULL; #else int preloadMode = GetSysParamPreLoadMode(); diff --git a/nwebspawn.cfg b/nwebspawn.cfg index f29e3c89..6777a5f0 100644 --- a/nwebspawn.cfg +++ b/nwebspawn.cfg @@ -1,4 +1,12 @@ { + "jobs" : [{ + "name" : "param:bootevent.boot.completed", + "condition" : "bootevent.boot.completed=true", + "cmds" : [ + "start nwebspawn" + ] + } + ], "services" : [{ "name" : "nwebspawn", "path" : ["/system/bin/nwebspawn", @@ -21,6 +29,7 @@ "option" : [ ] }], + "start_mode" : "condition", "sandbox" : 0, "secon" : "u:r:nwebspawn:s0" } -- Gitee From bb00f12c3cf338f0fd2c9528517a292eaa555a32 Mon Sep 17 00:00:00 2001 From: TinyLight Date: Mon, 14 Jul 2025 07:59:58 +0000 Subject: [PATCH 5/6] update nwebspawn.cfg. Signed-off-by: TinyLight --- modules/nweb_adapter/BUILD.gn | 2 +- modules/nweb_adapter/nwebspawn_adapter.cpp | 20 ++++++++++---------- nwebspawn.cfg | 7 +++---- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/modules/nweb_adapter/BUILD.gn b/modules/nweb_adapter/BUILD.gn index 35ea32b4..1b73d080 100644 --- a/modules/nweb_adapter/BUILD.gn +++ b/modules/nweb_adapter/BUILD.gn @@ -32,7 +32,7 @@ ohos_shared_library("appspawn_nweb") { defines += [ "webview_x86_64" ] } if (appspawn_arkweb_preload) { - defines += [ "preload_rk3568" ] + defines += [ "arkweb_preload" ] } external_deps = [ diff --git a/modules/nweb_adapter/nwebspawn_adapter.cpp b/modules/nweb_adapter/nwebspawn_adapter.cpp index 9bd890e8..a0e16f7d 100644 --- a/modules/nweb_adapter/nwebspawn_adapter.cpp +++ b/modules/nweb_adapter/nwebspawn_adapter.cpp @@ -36,10 +36,10 @@ #endif namespace { -#if defined(webview_arm64) +#ifdef webview_arm64 const std::string ARK_WEB_CORE_HAP_LIB_PATH = "/data/storage/el1/bundle/arkwebcore/libs/arm64"; -#elif defined(webview_x86_64) +#elif webview_x86_64 const std::string ARK_WEB_CORE_HAP_LIB_PATH = "/data/storage/el1/bundle/arkwebcore/libs/x86_64"; #else @@ -55,7 +55,7 @@ namespace { const std::string OHOS_ADPT_GLUE_SRC_LIB_PATH = "/system/lib64/libohos_adapter_glue_source.z.so"; -#if defined(preload_rk3568) +#ifdef arkweb_preload const std::string ARKWEB_BUNDLE_NAME = "com.ohos.arkwebcore"; #else const std::string ARKWEB_BUNDLE_NAME = "com.huawei.hmos.arkwebcore"; @@ -166,9 +166,9 @@ APPSPAWN_STATIC int RunChildProcessor(AppSpawnContent *content, AppSpawnClient * return 0; } -static std::string GetOHOSAdptGlueSrcLibPath() +static std::string GetOhosAdptGlueSrcLibPath() { -#if defined(webview_arm64) +#ifdef webview_arm64 const std::string ARK_WEB_CORE_HAP_LIB_PATH = "/system/lib64/libohos_adapter_glue_source.z.so"; #else @@ -180,10 +180,10 @@ static std::string GetOHOSAdptGlueSrcLibPath() static std::string GetArkWebEngineLibPath() { -#if defined(webview_arm64) +#ifdef webview_arm64 const std::string ARK_WEB_CORE_HAP_LIB_PATH = "/data/app/el1/bundle/public/" + ARKWEB_BUNDLE_NAME + "/libs/arm64"; -#elif defined(webview_x86_64) +#elif webview_x86_64 const std::string ARK_WEB_CORE_HAP_LIB_PATH = "/data/app/el1/bundle/public/" + ARKWEB_BUNDLE_NAME + "/libs/x86_64"; #else @@ -210,14 +210,14 @@ static void PreLoadArkWebEngineLib() static void PreLoadOHOSAdptGlueSrcLib() { - const std::string ohosAdptGlueSrcLibPath = GetOHOSAdptGlueSrcLibPath(); + const std::string ohosAdptGlueSrcLibPath = GetOhosAdptGlueSrcLibPath(); void *ohosAdptGlueSrcHandle = dlopen(ohosAdptGlueSrcLibPath.c_str(), RTLD_NOW | RTLD_GLOBAL); if (!ohosAdptGlueSrcHandle) { APPSPAWN_LOGE("Fail to dlopen libohos_adapter_glue_source.z.so, errno: %{public}d", errno); } } -#if !defined(preload_rk3568) +#ifndef arkweb_preload static int GetSysParamPreLoadMode() { const int BUFFER_LEN = 8; @@ -238,7 +238,7 @@ static int PreLoadNwebSpawn(AppSpawnMgr *content) RegChildLooper(&content->content, RunChildProcessor); // preload render lib -#if defined(preload_rk3568) +#ifdef arkweb_preload int preloadMode = RenderPreLoadMode::PRELOAD_FULL; #else int preloadMode = GetSysParamPreLoadMode(); diff --git a/nwebspawn.cfg b/nwebspawn.cfg index 6777a5f0..e6cc4dfb 100644 --- a/nwebspawn.cfg +++ b/nwebspawn.cfg @@ -1,12 +1,11 @@ { "jobs" : [{ - "name" : "param:bootevent.boot.completed", + "name" : "param:nwebspawnservicestart", "condition" : "bootevent.boot.completed=true", "cmds" : [ "start nwebspawn" ] - } - ], + }], "services" : [{ "name" : "nwebspawn", "path" : ["/system/bin/nwebspawn", @@ -29,7 +28,7 @@ "option" : [ ] }], - "start_mode" : "condition", + "start-mode" : "condition", "sandbox" : 0, "secon" : "u:r:nwebspawn:s0" } -- Gitee From 310da8444030a07c7499a712a18f23021d6b66ad Mon Sep 17 00:00:00 2001 From: TinyLight Date: Wed, 9 Jul 2025 08:11:07 +0000 Subject: [PATCH 6/6] 07-15 2203update nwebspawn.cfg. Signed-off-by: TinyLight --- appspawn.gni | 1 + bundle.json | 3 +- modules/nweb_adapter/BUILD.gn | 3 ++ modules/nweb_adapter/nwebspawn_adapter.cpp | 49 ++++++++++++++++++++-- nwebspawn.cfg | 8 ++++ 5 files changed, 59 insertions(+), 5 deletions(-) diff --git a/appspawn.gni b/appspawn.gni index cdc3fa62..2f0fe1f0 100644 --- a/appspawn.gni +++ b/appspawn.gni @@ -40,6 +40,7 @@ declare_args() { appspawn_support_local_debugger = false appspawn_hitrace_option = true appspawn_napi_preload_path = "../appspawn_preload.json" + appspawn_arkweb_preload = true } if (!defined(global_parts_info) || diff --git a/bundle.json b/bundle.json index 7b73228e..6582a611 100644 --- a/bundle.json +++ b/bundle.json @@ -31,7 +31,8 @@ "appspawn_custom_sandbox", "appspawn_support_nosharefs", "appspawn_support_local_debugger", - "appspawn_napi_preload_path" + "appspawn_napi_preload_path", + "appspawn_arkweb_preload" ], "rom": "296KB", "ram": "13125KB", diff --git a/modules/nweb_adapter/BUILD.gn b/modules/nweb_adapter/BUILD.gn index acd15abe..1b73d080 100644 --- a/modules/nweb_adapter/BUILD.gn +++ b/modules/nweb_adapter/BUILD.gn @@ -31,6 +31,9 @@ ohos_shared_library("appspawn_nweb") { if (target_cpu == "x86_64") { defines += [ "webview_x86_64" ] } + if (appspawn_arkweb_preload) { + defines += [ "arkweb_preload" ] + } external_deps = [ "c_utils:utils", diff --git a/modules/nweb_adapter/nwebspawn_adapter.cpp b/modules/nweb_adapter/nwebspawn_adapter.cpp index c8562fa1..a0e16f7d 100644 --- a/modules/nweb_adapter/nwebspawn_adapter.cpp +++ b/modules/nweb_adapter/nwebspawn_adapter.cpp @@ -36,10 +36,10 @@ #endif namespace { -#if defined(webview_arm64) +#ifdef webview_arm64 const std::string ARK_WEB_CORE_HAP_LIB_PATH = "/data/storage/el1/bundle/arkwebcore/libs/arm64"; -#elif defined(webview_x86_64) +#elif webview_x86_64 const std::string ARK_WEB_CORE_HAP_LIB_PATH = "/data/storage/el1/bundle/arkwebcore/libs/x86_64"; #else @@ -55,6 +55,12 @@ namespace { const std::string OHOS_ADPT_GLUE_SRC_LIB_PATH = "/system/lib64/libohos_adapter_glue_source.z.so"; +#ifdef arkweb_preload + const std::string ARKWEB_BUNDLE_NAME = "com.ohos.arkwebcore"; +#else + const std::string ARKWEB_BUNDLE_NAME = "com.huawei.hmos.arkwebcore"; +#endif + typedef enum { PRELOAD_NO = 0, // 不预加载 PRELOAD_PARTIAL = 1, // 只预加载libohos_adapter_glue_source.z.so @@ -160,12 +166,40 @@ APPSPAWN_STATIC int RunChildProcessor(AppSpawnContent *content, AppSpawnClient * return 0; } +static std::string GetOhosAdptGlueSrcLibPath() +{ +#ifdef webview_arm64 + const std::string ARK_WEB_CORE_HAP_LIB_PATH = + "/system/lib64/libohos_adapter_glue_source.z.so"; +#else + const std::string ARK_WEB_CORE_HAP_LIB_PATH = + "/system/lib/libohos_adapter_glue_source.z.so"; +#endif + return ARK_WEB_CORE_HAP_LIB_PATH; +} + +static std::string GetArkWebEngineLibPath() +{ +#ifdef webview_arm64 + const std::string ARK_WEB_CORE_HAP_LIB_PATH = + "/data/app/el1/bundle/public/" + ARKWEB_BUNDLE_NAME + "/libs/arm64"; +#elif webview_x86_64 + const std::string ARK_WEB_CORE_HAP_LIB_PATH = + "/data/app/el1/bundle/public/" + ARKWEB_BUNDLE_NAME + "/libs/x86_64"; +#else + const std::string ARK_WEB_CORE_HAP_LIB_PATH = + "/data/app/el1/bundle/public/" + ARKWEB_BUNDLE_NAME + "/libs/arm"; +#endif + return ARK_WEB_CORE_HAP_LIB_PATH; +} + static void PreLoadArkWebEngineLib() { Dl_namespace dlns; Dl_namespace ndkns; dlns_init(&dlns, "nweb_ns"); - dlns_create(&dlns, ARK_WEB_ENGINE_LIB_PRELOAD_PATH.c_str()); + const std::string arkWebEngineLibPath = GetArkWebEngineLibPath(); + dlns_create(&dlns, arkWebEngineLibPath.c_str()); dlns_get("ndk", &ndkns); dlns_inherit(&dlns, &ndkns, "allow_all_shared_libs"); void *webEngineHandle = dlopen_ns(&dlns, ARK_WEB_ENGINE_LIB_NAME.c_str(), RTLD_NOW | RTLD_GLOBAL); @@ -176,12 +210,14 @@ static void PreLoadArkWebEngineLib() static void PreLoadOHOSAdptGlueSrcLib() { - void *ohosAdptGlueSrcHandle = dlopen(OHOS_ADPT_GLUE_SRC_LIB_PATH.c_str(), RTLD_NOW | RTLD_GLOBAL); + const std::string ohosAdptGlueSrcLibPath = GetOhosAdptGlueSrcLibPath(); + void *ohosAdptGlueSrcHandle = dlopen(ohosAdptGlueSrcLibPath.c_str(), RTLD_NOW | RTLD_GLOBAL); if (!ohosAdptGlueSrcHandle) { APPSPAWN_LOGE("Fail to dlopen libohos_adapter_glue_source.z.so, errno: %{public}d", errno); } } +#ifndef arkweb_preload static int GetSysParamPreLoadMode() { const int BUFFER_LEN = 8; @@ -190,6 +226,7 @@ static int GetSysParamPreLoadMode() int ret = std::atoi(preLoadMode); return ret; } +#endif static int PreLoadNwebSpawn(AppSpawnMgr *content) { @@ -201,7 +238,11 @@ static int PreLoadNwebSpawn(AppSpawnMgr *content) RegChildLooper(&content->content, RunChildProcessor); // preload render lib +#ifdef arkweb_preload + int preloadMode = RenderPreLoadMode::PRELOAD_FULL; +#else int preloadMode = GetSysParamPreLoadMode(); +#endif APPSPAWN_LOGI("NwebSpawn preload render lib mode: %{public}d", preloadMode); if (preloadMode == PRELOAD_PARTIAL) { PreLoadOHOSAdptGlueSrcLib(); diff --git a/nwebspawn.cfg b/nwebspawn.cfg index f29e3c89..e6cc4dfb 100644 --- a/nwebspawn.cfg +++ b/nwebspawn.cfg @@ -1,4 +1,11 @@ { + "jobs" : [{ + "name" : "param:nwebspawnservicestart", + "condition" : "bootevent.boot.completed=true", + "cmds" : [ + "start nwebspawn" + ] + }], "services" : [{ "name" : "nwebspawn", "path" : ["/system/bin/nwebspawn", @@ -21,6 +28,7 @@ "option" : [ ] }], + "start-mode" : "condition", "sandbox" : 0, "secon" : "u:r:nwebspawn:s0" } -- Gitee