Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "[browser] Remove check for user agent when attaching debugger" #106426

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public unsafe void CreateFunctionString()
[Fact]
public unsafe void CreateFunctionInternal()
{
Func<bool> internals = Utils.CreateFunctionBool("return true");
Func<bool> internals = Utils.CreateFunctionBool("return INTERNAL.mono_wasm_runtime_is_ready");
Assert.True(internals());
}

Expand Down
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/lazyLoading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export async function loadLazyAssembly (assemblyNameToLoad: string): Promise<boo

let pdbNameToLoad = assemblyNameWithoutExtension + ".pdb";
let shouldLoadPdb = false;
if (loaderHelpers.config.debugLevel != 0) {
if (loaderHelpers.config.debugLevel != 0 && loaderHelpers.isDebuggingSupported()) {
shouldLoadPdb = Object.prototype.hasOwnProperty.call(lazyAssemblies, pdbNameToLoad);
if (loaderHelpers.config.resources!.fingerprinting) {
const map = loaderHelpers.config.resources!.fingerprinting;
Expand Down
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/loader/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ export function prepareAssets () {
}


if (config.debugLevel != 0) {
if (config.debugLevel != 0 && loaderHelpers.isDebuggingSupported()) {
if (resources.corePdb) {
for (const name in resources.corePdb) {
addAsset({
Expand Down
9 changes: 9 additions & 0 deletions src/mono/browser/runtime/loader/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,15 @@ export async function mono_wasm_load_config (module: DotnetModuleInternal): Prom
}
}

export function isDebuggingSupported (): boolean {
// Copied from blazor MonoDebugger.ts/attachDebuggerHotkey
if (!globalThis.navigator) {
return false;
}

return loaderHelpers.isChromium || loaderHelpers.isFirefox;
}

async function loadBootConfig (module: DotnetModuleInternal): Promise<void> {
const defaultConfigSrc = loaderHelpers.locateFile(module.configSrc!);

Expand Down
3 changes: 2 additions & 1 deletion src/mono/browser/runtime/loader/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -128,6 +128,7 @@ export function setLoaderGlobals (

retrieve_asset_download,
invokeLibraryInitializers,
isDebuggingSupported,

// from wasm-feature-detect npm package
exceptions,
Expand Down
7 changes: 4 additions & 3 deletions src/mono/browser/runtime/startup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions src/mono/browser/runtime/types/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ export type LoaderHelpers = {
invokeLibraryInitializers: (functionName: string, args: any[]) => Promise<void>,
libraryInitializers?: { scriptName: string, exports: any }[];

isDebuggingSupported(): boolean,
isChromium: boolean,
isFirefox: boolean

Expand Down
Loading