From: Pavel Savara Date: Mon, 15 May 2023 17:01:21 +0000 (+0200) Subject: [browser] disable enablePerfMeasure by default (#86237) X-Git-Tag: accepted/tizen/unified/riscv/20231226.055536~2229 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1dff328151a06763d5db17e65f523573a4806e50;p=platform%2Fupstream%2Fdotnet%2Fruntime.git [browser] disable enablePerfMeasure by default (#86237) * disable enablePerfMeasure by default * fixed wrong order of config initialization --- diff --git a/src/mono/wasm/runtime/globals.ts b/src/mono/wasm/runtime/globals.ts index c3523c1..91b4248 100644 --- a/src/mono/wasm/runtime/globals.ts +++ b/src/mono/wasm/runtime/globals.ts @@ -32,6 +32,7 @@ export function passEmscriptenInternals(internals: EmscriptenInternals): void { runtimeHelpers.ExitStatus = internals.ExitStatus; } +// NOTE: this is called AFTER the config is loaded export function setRuntimeGlobals(globalObjects: GlobalObjects) { if (_runtimeModuleLoaded) { throw new Error("Runtime module already loaded"); @@ -44,9 +45,6 @@ export function setRuntimeGlobals(globalObjects: GlobalObjects) { exportedRuntimeAPI = globalObjects.api; Object.assign(runtimeHelpers, { - mono_wasm_bindings_is_ready: false, - javaScriptExports: {} as any, - enablePerfMeasure: true, allAssetsInMemory: createPromiseController(), dotnetReady: createPromiseController(), memorySnapshotSkippedOrDone: createPromiseController(), diff --git a/src/mono/wasm/runtime/loader/config.ts b/src/mono/wasm/runtime/loader/config.ts index af9d96c..7e6b21e 100644 --- a/src/mono/wasm/runtime/loader/config.ts +++ b/src/mono/wasm/runtime/loader/config.ts @@ -35,6 +35,7 @@ export function deep_merge_module(target: DotnetModuleInternal, source: DotnetMo return Object.assign(target, providedConfig); } +// NOTE: this is called before setRuntimeGlobals export function normalizeConfig() { // normalize const config = loaderHelpers.config; diff --git a/src/mono/wasm/runtime/loader/globals.ts b/src/mono/wasm/runtime/loader/globals.ts index f221d46..6cebb54 100644 --- a/src/mono/wasm/runtime/loader/globals.ts +++ b/src/mono/wasm/runtime/loader/globals.ts @@ -19,6 +19,18 @@ export let exportedRuntimeAPI: RuntimeAPI = null as any; export let INTERNAL: any; export let _loaderModuleLoaded = false; // please keep it in place also as rollup guard +export const globalObjectsRoot: GlobalObjects = { + mono: {}, + binding: {}, + internal: {}, + module: {}, + loaderHelpers: {}, + runtimeHelpers: {}, + api: {} +} as any; + +setLoaderGlobals(globalObjectsRoot); + export function setLoaderGlobals( globalObjects: GlobalObjects, ) { @@ -39,6 +51,8 @@ export function setLoaderGlobals( config: { environmentVariables: {} } }); Object.assign(runtimeHelpers, { + mono_wasm_bindings_is_ready: false, + javaScriptExports: {} as any, config: globalObjects.module.config, diagnosticTracing: false, }); diff --git a/src/mono/wasm/runtime/loader/run.ts b/src/mono/wasm/runtime/loader/run.ts index 5eebdee..3f49a8f 100644 --- a/src/mono/wasm/runtime/loader/run.ts +++ b/src/mono/wasm/runtime/loader/run.ts @@ -2,9 +2,9 @@ // The .NET Foundation licenses this file to you under the MIT license. import type { MonoConfig, DotnetHostBuilder, DotnetModuleConfig, RuntimeAPI, WebAssemblyStartOptions } from "../types"; -import type { MonoConfigInternal, GlobalObjects, EmscriptenModuleInternal, RuntimeModuleExportsInternal, NativeModuleExportsInternal, } from "../types/internal"; +import type { MonoConfigInternal, EmscriptenModuleInternal, RuntimeModuleExportsInternal, NativeModuleExportsInternal, } from "../types/internal"; -import { ENVIRONMENT_IS_NODE, ENVIRONMENT_IS_WEB, exportedRuntimeAPI, setLoaderGlobals } from "./globals"; +import { ENVIRONMENT_IS_NODE, ENVIRONMENT_IS_WEB, exportedRuntimeAPI, globalObjectsRoot } from "./globals"; import { deep_merge_config, deep_merge_module, mono_wasm_load_config } from "./config"; import { mono_exit } from "./exit"; import { setup_proxy_console } from "./logging"; @@ -15,17 +15,6 @@ import { init_globalization } from "./icu"; import { setupPreloadChannelToMainThread } from "./worker"; -export const globalObjectsRoot: GlobalObjects = { - mono: {}, - binding: {}, - internal: {}, - module: {}, - loaderHelpers: {}, - runtimeHelpers: {}, - api: {} -} as any; - -setLoaderGlobals(globalObjectsRoot); const module = globalObjectsRoot.module; const monoConfig = module.config as MonoConfigInternal;