From ab608a906fbd156aa566c1452ef16b7bb4497006 Mon Sep 17 00:00:00 2001 From: Larry Ewing Date: Fri, 16 Aug 2024 17:49:36 -0500 Subject: [PATCH] Revert "[browser] Remove check for user agent when attaching debugger (#105559)" (#106426) This reverts commit 7fa25e86b3538225c53dff3905f87d7c579881ba. --- .../Runtime/InteropServices/JavaScript/JSImportTest.cs | 2 +- src/mono/browser/runtime/lazyLoading.ts | 2 +- src/mono/browser/runtime/loader/assets.ts | 2 +- src/mono/browser/runtime/loader/config.ts | 9 +++++++++ src/mono/browser/runtime/loader/globals.ts | 3 ++- src/mono/browser/runtime/startup.ts | 7 ++++--- src/mono/browser/runtime/types/internal.ts | 1 + 7 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/JSImportTest.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/JSImportTest.cs index 987bc6a2e7abb..f2d45a5112333 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/JSImportTest.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/JSImportTest.cs @@ -238,7 +238,7 @@ public unsafe void CreateFunctionString() [Fact] public unsafe void CreateFunctionInternal() { - Func internals = Utils.CreateFunctionBool("return true"); + Func internals = Utils.CreateFunctionBool("return INTERNAL.mono_wasm_runtime_is_ready"); Assert.True(internals()); } diff --git a/src/mono/browser/runtime/lazyLoading.ts b/src/mono/browser/runtime/lazyLoading.ts index f8c1a968dbf48..9787c18ac33ec 100644 --- a/src/mono/browser/runtime/lazyLoading.ts +++ b/src/mono/browser/runtime/lazyLoading.ts @@ -53,7 +53,7 @@ export async function loadLazyAssembly (assemblyNameToLoad: string): Promise { const defaultConfigSrc = loaderHelpers.locateFile(module.configSrc!); diff --git a/src/mono/browser/runtime/loader/globals.ts b/src/mono/browser/runtime/loader/globals.ts index 12a731aee780d..91e0a89f2c0f9 100644 --- a/src/mono/browser/runtime/loader/globals.ts +++ b/src/mono/browser/runtime/loader/globals.ts @@ -15,7 +15,7 @@ import { assertIsControllablePromise, createPromiseController, getPromiseControl import { mono_download_assets, resolve_single_asset_path, retrieve_asset_download } from "./assets"; import { mono_log_error, set_thread_prefix, setup_proxy_console } from "./logging"; import { invokeLibraryInitializers } from "./libraryInitializers"; -import { deep_merge_config } from "./config"; +import { deep_merge_config, isDebuggingSupported } from "./config"; import { logDownloadStatsToConsole, purgeUnusedCacheEntriesAsync } from "./assetsCache"; // if we are the first script loaded in the web worker, we are expected to become the sidecar @@ -128,6 +128,7 @@ export function setLoaderGlobals ( retrieve_asset_download, invokeLibraryInitializers, + isDebuggingSupported, // from wasm-feature-detect npm package exceptions, diff --git a/src/mono/browser/runtime/startup.ts b/src/mono/browser/runtime/startup.ts index b29bbbecf2a8d..4d07e712358b0 100644 --- a/src/mono/browser/runtime/startup.ts +++ b/src/mono/browser/runtime/startup.ts @@ -328,9 +328,7 @@ async function onRuntimeInitializedAsync (userOnRuntimeInitialized: () => void) runtimeList.registerRuntime(exportedRuntimeAPI); - if (loaderHelpers.config.debugLevel !== 0 && !runtimeHelpers.mono_wasm_runtime_is_ready) { - mono_wasm_runtime_ready(); - } + if (!runtimeHelpers.mono_wasm_runtime_is_ready) mono_wasm_runtime_ready(); if (loaderHelpers.config.debugLevel !== 0 && loaderHelpers.config.cacheBootResources) { loaderHelpers.logDownloadStatsToConsole(); @@ -602,6 +600,9 @@ export function mono_wasm_load_runtime (): void { debugLevel = 0 + debugLevel; } } + if (!loaderHelpers.isDebuggingSupported() || !runtimeHelpers.config.resources!.pdb) { + debugLevel = 0; + } cwraps.mono_wasm_load_runtime(debugLevel); endMeasure(mark, MeasuredBlock.loadRuntime); diff --git a/src/mono/browser/runtime/types/internal.ts b/src/mono/browser/runtime/types/internal.ts index 4ec8ced41c32a..0627543d1fb12 100644 --- a/src/mono/browser/runtime/types/internal.ts +++ b/src/mono/browser/runtime/types/internal.ts @@ -172,6 +172,7 @@ export type LoaderHelpers = { invokeLibraryInitializers: (functionName: string, args: any[]) => Promise, libraryInitializers?: { scriptName: string, exports: any }[]; + isDebuggingSupported(): boolean, isChromium: boolean, isFirefox: boolean