From ad8c6bf3625919b22cb30152f77cbde9d5732f6e Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Fri, 24 Feb 2023 12:51:46 +0100 Subject: [PATCH] - remove custom startup sequence of blazor (#82532) - remove legacy mono_load_runtime_and_bcl_args - unused MonoConfigError removal --- src/mono/wasm/runtime/dotnet-legacy.d.ts | 4 --- src/mono/wasm/runtime/net6-legacy/export-types.ts | 4 --- .../wasm/runtime/net6-legacy/exports-legacy.ts | 6 ++-- src/mono/wasm/runtime/startup.ts | 35 +++++++--------------- src/mono/wasm/runtime/types.ts | 6 ---- 5 files changed, 12 insertions(+), 43 deletions(-) diff --git a/src/mono/wasm/runtime/dotnet-legacy.d.ts b/src/mono/wasm/runtime/dotnet-legacy.d.ts index b0dfbc2..3dcc010 100644 --- a/src/mono/wasm/runtime/dotnet-legacy.d.ts +++ b/src/mono/wasm/runtime/dotnet-legacy.d.ts @@ -163,10 +163,6 @@ type MONOType = { */ mono_wasm_load_config: (configFilePath: string) => Promise; /** - * @deprecated Please use runMain instead - */ - mono_load_runtime_and_bcl_args: Function; - /** * @deprecated Please use [JSImportAttribute] or [JSExportAttribute] for interop instead. */ mono_wasm_new_root_buffer: (capacity: number, name?: string) => WasmRootBuffer; diff --git a/src/mono/wasm/runtime/net6-legacy/export-types.ts b/src/mono/wasm/runtime/net6-legacy/export-types.ts index 0a13bc1..2253784 100644 --- a/src/mono/wasm/runtime/net6-legacy/export-types.ts +++ b/src/mono/wasm/runtime/net6-legacy/export-types.ts @@ -111,10 +111,6 @@ export type MONOType = { */ mono_wasm_load_config: (configFilePath: string) => Promise; /** - * @deprecated Please use runMain instead - */ - mono_load_runtime_and_bcl_args: Function; - /** * @deprecated Please use [JSImportAttribute] or [JSExportAttribute] for interop instead. */ mono_wasm_new_root_buffer: (capacity: number, name?: string) => WasmRootBuffer; diff --git a/src/mono/wasm/runtime/net6-legacy/exports-legacy.ts b/src/mono/wasm/runtime/net6-legacy/exports-legacy.ts index 2758977..725d0c5 100644 --- a/src/mono/wasm/runtime/net6-legacy/exports-legacy.ts +++ b/src/mono/wasm/runtime/net6-legacy/exports-legacy.ts @@ -8,9 +8,8 @@ import { runtimeHelpers } from "../imports"; import { mono_wasm_load_bytes_into_heap, setB32, setI8, setI16, setI32, setI52, setU52, setI64Big, setU8, setU16, setU32, setF32, setF64, getB32, getI8, getI16, getI32, getI52, getU52, getI64Big, getU8, getU16, getU32, getF32, getF64 } from "../memory"; import { mono_wasm_new_root_buffer, mono_wasm_new_root, mono_wasm_new_external_root, mono_wasm_release_roots } from "../roots"; import { mono_run_main, mono_run_main_and_exit } from "../run"; -import { mono_wasm_setenv, mono_wasm_load_config, mono_load_runtime_and_bcl_args } from "../startup"; +import { mono_wasm_setenv, mono_wasm_load_config } from "../startup"; import { js_string_to_mono_string, conv_string, js_string_to_mono_string_root, conv_string_root } from "../strings"; -import { MonoConfig, MonoConfigError } from "../types"; import { mono_array_to_js_array, unbox_mono_obj, unbox_mono_obj_root, mono_array_root_to_js_array } from "./cs-to-js"; import { js_typed_array_to_array, js_to_mono_obj, js_typed_array_to_array_root, js_to_mono_obj_root } from "./js-to-cs"; import { mono_bind_static_method, mono_call_assembly_entry_point } from "./method-calls"; @@ -27,7 +26,6 @@ export function export_mono_api(): MONOType { mono_wasm_runtime_ready, mono_wasm_load_data_archive, mono_wasm_load_config, - mono_load_runtime_and_bcl_args, mono_wasm_new_root_buffer, mono_wasm_new_root, mono_wasm_new_external_root, @@ -39,7 +37,7 @@ export function export_mono_api(): MONOType { mono_wasm_add_assembly: null, mono_wasm_load_runtime, - config: runtimeHelpers.config, + config: runtimeHelpers.config, loaded_files: [], // memory accessors diff --git a/src/mono/wasm/runtime/startup.ts b/src/mono/wasm/runtime/startup.ts index 3fea127..5c96738 100644 --- a/src/mono/wasm/runtime/startup.ts +++ b/src/mono/wasm/runtime/startup.ts @@ -3,7 +3,7 @@ import BuildConfiguration from "consts:configuration"; import MonoWasmThreads from "consts:monoWasmThreads"; -import { CharPtrNull, DotnetModule, RuntimeAPI, MonoConfig, MonoConfigError, MonoConfigInternal } from "./types"; +import { CharPtrNull, DotnetModule, RuntimeAPI, MonoConfig, MonoConfigInternal } from "./types"; import { ENVIRONMENT_IS_NODE, ENVIRONMENT_IS_SHELL, INTERNAL, Module, runtimeHelpers } from "./imports"; import cwraps, { init_c_exports } from "./cwraps"; import { mono_wasm_raise_debug_event, mono_wasm_runtime_ready } from "./debug"; @@ -32,7 +32,6 @@ import { endMeasure, MeasuredBlock, startMeasure } from "./profiler"; let config: MonoConfigInternal = undefined as any; let configLoaded = false; -let isCustomStartup = false; export const dotnetReady = createPromiseController(); export const afterConfigLoaded = createPromiseController(); export const afterInstantiateWasm = createPromiseController(); @@ -58,8 +57,6 @@ export function configure_emscripten_startup(module: DotnetModule, exportedAPI: const userpostRun: (() => void)[] = !module.postRun ? [] : typeof module.postRun === "function" ? [module.postRun] : module.postRun as any; // eslint-disable-next-line @typescript-eslint/no-empty-function const userOnRuntimeInitialized: () => void = module.onRuntimeInitialized ? module.onRuntimeInitialized : () => { }; - // when assets don't contain DLLs it means this is Blazor or another custom startup - isCustomStartup = !module.configSrc && (!module.config || !module.config.assets || module.config.assets.findIndex(a => a.behavior === "assembly") == -1); // like blazor // execution order == [0] == // - default or user Module.instantiateWasm (will start downloading dotnet.wasm) @@ -156,11 +153,11 @@ function preInit(userPreInit: (() => void)[]) { (async () => { try { await mono_wasm_pre_init_essential_async(); - if (!isCustomStartup) { - // - download Module.config from configSrc - // - start download assets like DLLs - await mono_wasm_pre_init_full(); - } + + // - download Module.config from configSrc + // - start download assets like DLLs + await mono_wasm_pre_init_full(); + endMeasure(mark, MeasuredBlock.preInit); } catch (err) { abort_startup(err, true); @@ -234,11 +231,10 @@ async function onRuntimeInitializedAsync(userOnRuntimeInitialized: () => void) { // signal this stage, this will allow pending assets to allocate memory beforeOnRuntimeInitialized.promise_control.resolve(); try { - if (!isCustomStartup) { - await wait_for_all_assets(); - // load runtime - await mono_wasm_before_user_runtime_initialized(); - } + await wait_for_all_assets(); + // load runtime + await mono_wasm_before_user_runtime_initialized(); + if (config.runtimeOptions) { mono_wasm_set_runtime_options(config.runtimeOptions); } @@ -699,14 +695,3 @@ export async function mono_wasm_pthread_worker_init(module: DotnetModule, export await afterPreInit.promise; return exportedAPI.Module; } - -/** -* @deprecated -*/ -export async function mono_load_runtime_and_bcl_args(cfg?: MonoConfig | MonoConfigError | undefined): Promise { - config = Module.config = runtimeHelpers.config = Object.assign(runtimeHelpers.config || {}, cfg || {}) as any; - await mono_download_assets(); - if (!isCustomStartup) { - await wait_for_all_assets(); - } -} diff --git a/src/mono/wasm/runtime/types.ts b/src/mono/wasm/runtime/types.ts index 09b45d9..1de2fc6 100644 --- a/src/mono/wasm/runtime/types.ts +++ b/src/mono/wasm/runtime/types.ts @@ -140,12 +140,6 @@ export type RunArguments = { diagnosticTracing?: boolean, } -export type MonoConfigError = { - isError: true, - message: string, - error: any -} - export interface ResourceRequest { name: string, // the name of the asset, including extension. behavior: AssetBehaviours, // determines how the asset will be handled once loaded -- 2.7.4