diff --git a/modules/ace_adapter/ace_adapter.cpp b/modules/ace_adapter/ace_adapter.cpp index 8aaa6468c7c0e335a5fae6ea7663ddb6accc34b0..30e875636950721768b907e1f4fa9351f7679f70 100644 --- a/modules/ace_adapter/ace_adapter.cpp +++ b/modules/ace_adapter/ace_adapter.cpp @@ -84,7 +84,7 @@ static int GetModuleSet(const cJSON *root, ParseJsonContext *context) static void PreloadModule(void) { OHOS::AbilityRuntime::Runtime::Options options; - options.lang = OHOS::AbilityRuntime::Runtime::Language::JS; + options.lang = {{OHOS::AbilityRuntime::Runtime::Language::JS, true}}; options.loadAce = true; options.preload = true; @@ -94,11 +94,19 @@ static void PreloadModule(void) return; } + options.lang = {{OHOS::AbilityRuntime::Runtime::Language::STS, true}}; + auto staticRuntime = OHOS::AbilityRuntime::Runtime::Create(options); + if (!staticRuntime) { + APPSPAWN_LOGE("LoadExtendLib: Failed to create static runtime"); + return; + } + ParseJsonContext context = {}; (void)ParseJsonConfig("etc/appspawn", PRELOAD_JSON_CONFIG.c_str(), GetModuleSet, &context); for (std::string moduleName : context.modules) { APPSPAWN_LOGI("moduleName %{public}s", moduleName.c_str()); runtime->PreloadSystemModule(moduleName); + staticRuntime->PreloadSystemModule(moduleName); } // Save preloaded runtime OHOS::AbilityRuntime::Runtime::SavePreloaded(std::move(runtime));