[browser] disable enablePerfMeasure by default (#86237)
authorPavel Savara <pavel.savara@gmail.com>
Mon, 15 May 2023 17:01:21 +0000 (19:01 +0200)
committerGitHub <noreply@github.com>
Mon, 15 May 2023 17:01:21 +0000 (19:01 +0200)
* disable enablePerfMeasure by default
* fixed wrong order of config initialization

src/mono/wasm/runtime/globals.ts
src/mono/wasm/runtime/loader/config.ts
src/mono/wasm/runtime/loader/globals.ts
src/mono/wasm/runtime/loader/run.ts

index c3523c1..91b4248 100644 (file)
@@ -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<void>(),
         dotnetReady: createPromiseController<any>(),
         memorySnapshotSkippedOrDone: createPromiseController<void>(),
index af9d96c..7e6b21e 100644 (file)
@@ -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;
index f221d46..6cebb54 100644 (file)
@@ -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,
     });
index 5eebdee..3f49a8f 100644 (file)
@@ -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;