Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6d25912
Update debug level logic
maraf Jan 19, 2024
64708fe
WBT 1
maraf Jan 19, 2024
7bb059f
Fix build
maraf Jan 19, 2024
89f9dd8
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Jan 24, 2024
9871731
Build project. Register tests
maraf Jan 24, 2024
2639ec8
Remove default to -1 from common props. Use separate build and publis…
maraf Jan 24, 2024
ff8622b
Switching between build and publish for run
maraf Jan 25, 2024
30595a7
More tests
maraf Jan 25, 2024
3affa88
Remove WasmDebugLevel defaults from WasmApp.Common.targets. Create si…
maraf Jan 25, 2024
0ffcdfe
Add configuration to generated project name
maraf Jan 26, 2024
39191f6
Expect relinked files when doing publish in Release
maraf Jan 26, 2024
310f641
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Feb 7, 2024
fa5c5b1
Auto relink only in publish
maraf Feb 7, 2024
550df31
Switch between dotnet run and webserver for hosting Blazor WBT
maraf Feb 7, 2024
f15dc21
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Feb 7, 2024
f5645d6
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Feb 8, 2024
78f5403
Fix using run for build in SatelliteLoadingTests
maraf Feb 8, 2024
2dcf713
Explicitly set debug level to 0 to trigger tiering
maraf Feb 8, 2024
713719f
Explicitly set debug level to 0 to trigger tiering (put debug level i…
maraf Feb 9, 2024
9d27cf4
Be sure not to fail download twice for the same asset
maraf Feb 9, 2024
ec563c0
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Feb 9, 2024
2f8c92b
Don't let missing debugger support override debug level used for logging
maraf Feb 9, 2024
bb28720
Fallback to count of pdbs
maraf Feb 9, 2024
9401db8
Update src/mono/wasi/build/WasiApp.targets
maraf Feb 10, 2024
67c562e
Feedback
maraf Feb 12, 2024
300d782
Feedback
maraf Feb 12, 2024
8e8d100
Fix build
maraf Feb 12, 2024
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
1 change: 1 addition & 0 deletions eng/testing/scenarios/BuildWasmAppsJobsList.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -44,3 +44,4 @@ Wasm.Build.Tests.WasmTemplateTests
Wasm.Build.Tests.WorkloadTests
Wasm.Build.Tests.TestAppScenarios.DownloadResourceProgressTests
Wasm.Build.Tests.MT.Blazor.SimpleMultiThreadedTests
Wasm.Build.Tests.TestAppScenarios.DebugLevelTests
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/cwraps.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -166,7 +166,7 @@ export interface t_Cwraps {
mono_wasm_load_icu_data(offset: VoidPtr): number;
mono_wasm_add_assembly(name: string, data: VoidPtr, size: number): number;
mono_wasm_add_satellite_assembly(name: string, culture: string, data: VoidPtr, size: number): void;
mono_wasm_load_runtime(unused: string, debugLevel: number): void;
mono_wasm_load_runtime(debugLevel: number): void;
mono_wasm_change_debugger_log_level(value: number): void;

mono_wasm_assembly_load(name: string): MonoAssembly;
Expand Down
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/driver.c
Original file line numberDiff line numberDiff line change
Expand Up@@ -181,7 +181,7 @@ cleanup_runtime_config (MonovmRuntimeConfigArguments *args, void *user_data)
}

EMSCRIPTEN_KEEPALIVE void
mono_wasm_load_runtime (const char *unused, int debug_level)
mono_wasm_load_runtime (int debug_level)
{
const char *interp_opts = "";

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

const pdbNameToLoad = changeExtension(dllAsset.name, ".pdb");
const shouldLoadPdb = loaderHelpers.hasDebuggingEnabled(loaderHelpers.config) && Object.prototype.hasOwnProperty.call(lazyAssemblies, pdbNameToLoad);
const shouldLoadPdb = loaderHelpers.config.debugLevel != 0 && loaderHelpers.isDebuggingSupported() && Object.prototype.hasOwnProperty.call(lazyAssemblies, pdbNameToLoad);

const dllBytesPromise = loaderHelpers.retrieve_asset_download(dllAsset);

Expand Down
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/loader/assets.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -266,7 +266,7 @@ export function prepareAssets() {
}
}

if (config.debugLevel != 0 && resources.pdb) {
if (config.debugLevel != 0 && loaderHelpers.isDebuggingSupported() && resources.pdb) {
for (const name in resources.pdb) {
assetsToLoad.push({
name,
Expand Down
12 changes: 2 additions & 10 deletions src/mono/browser/runtime/loader/config.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -197,13 +197,6 @@ export function normalizeConfig() {
config.environmentVariables["MONO_SLEEP_ABORT_LIMIT"] = "5000";
}

// Default values (when WasmDebugLevel is not set)
// - Build (debug) => debugBuild=true & debugLevel=-1 => -1
// - Build (release) => debugBuild=true & debugLevel=0 => 0
// - Publish (debug) => debugBuild=false & debugLevel=-1 => 0
// - Publish (release) => debugBuild=false & debugLevel=0 => 0
config.debugLevel = hasDebuggingEnabled(config) ? config.debugLevel : 0;

if (BuildConfiguration === "Debug" && config.diagnosticTracing === undefined) {
config.diagnosticTracing = true;
}
Expand DownExpand Up@@ -264,14 +257,13 @@ export async function mono_wasm_load_config(module: DotnetModuleInternal): Promi
}
}

export function hasDebuggingEnabled(config: MonoConfigInternal): boolean {
export function isDebuggingSupported(): boolean {
Comment thread
maraf marked this conversation as resolved.
// Copied from blazor MonoDebugger.ts/attachDebuggerHotkey
if (!globalThis.navigator) {
return false;
}

const hasReferencedPdbs = !!config.resources!.pdb;
Comment thread
maraf marked this conversation as resolved.
return (hasReferencedPdbs || config.debugLevel != 0) && (loaderHelpers.isChromium || loaderHelpers.isFirefox);
return loaderHelpers.isChromium || loaderHelpers.isFirefox;
}

async function loadBootConfig(module: DotnetModuleInternal): Promise<void> {
Expand Down
4 changes: 2 additions & 2 deletions src/mono/browser/runtime/loader/globals.ts
Original file line numberDiff line numberDiff 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, hasDebuggingEnabled } 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 DownExpand Up@@ -118,9 +118,9 @@ export function setLoaderGlobals(
purgeUnusedCacheEntriesAsync,
installUnhandledErrorHandler,

hasDebuggingEnabled,
retrieve_asset_download,
invokeLibraryInitializers,
isDebuggingSupported,

// from wasm-feature-detect npm package
exceptions,
Expand Down
10 changes: 7 additions & 3 deletions src/mono/browser/runtime/startup.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -515,7 +515,7 @@ async function start_runtime() {
if (runtimeHelpers.config.browserProfilerOptions)
mono_wasm_init_browser_profiler(runtimeHelpers.config.browserProfilerOptions);

mono_wasm_load_runtime("unused", runtimeHelpers.config.debugLevel);
mono_wasm_load_runtime();

if (runtimeHelpers.config.interpreterPgo)
setTimeout(maybeSaveInterpPgoTable, (runtimeHelpers.config.interpreterPgoSaveDelay || 15) * 1000);
Expand All@@ -534,17 +534,21 @@ async function maybeSaveInterpPgoTable() {
await interp_pgo_save_data();
}

export function mono_wasm_load_runtime(unused?: string, debugLevel?: number): void {
export function mono_wasm_load_runtime(): void {
mono_log_debug("mono_wasm_load_runtime");
try {
const mark = startMeasure();
let debugLevel = runtimeHelpers.config.debugLevel;
if (debugLevel == undefined) {
debugLevel = 0;
if (runtimeHelpers.config.debugLevel) {
debugLevel = 0 + debugLevel;
}
}
cwraps.mono_wasm_load_runtime(unused || "unused", debugLevel);
if (!loaderHelpers.isDebuggingSupported() || !runtimeHelpers.config.resources!.pdb) {
debugLevel = 0;
}
cwraps.mono_wasm_load_runtime(debugLevel);
endMeasure(mark, MeasuredBlock.loadRuntime);

} catch (err: any) {
Expand Down
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/types/internal.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -155,7 +155,6 @@ export type LoaderHelpers = {
out(message: string): void;
err(message: string): void;

hasDebuggingEnabled(config: MonoConfig): boolean,
retrieve_asset_download(asset: AssetEntry): Promise<ArrayBuffer>;
onDownloadResourceProgress?: (resourcesLoaded: number, totalResources: number) => void;
logDownloadStatsToConsole: () => void;
Expand All@@ -166,6 +165,7 @@ export type LoaderHelpers = {
invokeLibraryInitializers: (functionName: string, args: any[]) => Promise<void>,
libraryInitializers?: { scriptName: string, exports: any }[];

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

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -203,9 +203,6 @@ Copyright (c) .NET Foundation. All rights reserved.
<_BlazorWebAssemblyStartupMemoryCache>$(BlazorWebAssemblyStartupMemoryCache)</_BlazorWebAssemblyStartupMemoryCache>
<_BlazorWebAssemblyJiterpreter>$(BlazorWebAssemblyJiterpreter)</_BlazorWebAssemblyJiterpreter>
<_BlazorWebAssemblyRuntimeOptions>$(BlazorWebAssemblyRuntimeOptions)</_BlazorWebAssemblyRuntimeOptions>
<_WasmDebugLevel>$(WasmDebugLevel)</_WasmDebugLevel>
<_WasmDebugLevel Condition="'$(_WasmDebugLevel)' == ''">0</_WasmDebugLevel>
<_WasmDebugLevel Condition="'$(_WasmDebugLevel)' == '0' and ('$(DebuggerSupport)' == 'true' or '$(Configuration)' == 'Debug')">-1</_WasmDebugLevel>

<!-- Workaround for https://github.com/dotnet/sdk/issues/12114-->
<PublishDir Condition="'$(AppendRuntimeIdentifierToOutputPath)' != 'true' AND '$(PublishDir)' == '$(OutputPath)$(RuntimeIdentifier)\$(PublishDirName)\'">$(OutputPath)$(PublishDirName)\</PublishDir>
Expand DownExpand Up@@ -364,7 +361,7 @@ Copyright (c) .NET Foundation. All rights reserved.
AssemblyPath="@(IntermediateAssembly)"
Resources="@(_WasmOutputWithHash)"
DebugBuild="true"
DebugLevel="$(_WasmDebugLevel)"
DebugLevel="$(WasmDebugLevel)"
LinkerEnabled="false"
CacheBootResources="$(BlazorCacheBootResources)"
OutputPath="$(_WasmBuildBootJsonPath)"
Expand All@@ -380,7 +377,8 @@ Copyright (c) .NET Foundation. All rights reserved.
Extensions="@(WasmBootConfigExtension)"
TargetFrameworkVersion="$(TargetFrameworkVersion)"
ModuleAfterConfigLoaded="@(WasmModuleAfterConfigLoaded)"
ModuleAfterRuntimeReady="@(WasmModuleAfterRuntimeReady)" />
ModuleAfterRuntimeReady="@(WasmModuleAfterRuntimeReady)"
IsPublish="false" />

<ItemGroup>
<FileWrites Include="$(_WasmBuildBootJsonPath)" />
Expand DownExpand Up@@ -533,7 +531,6 @@ Copyright (c) .NET Foundation. All rights reserved.
</Target>

<Target Name="GeneratePublishWasmBootJson" DependsOnTargets="$(GeneratePublishWasmBootJsonDependsOn)">

<ItemGroup>
<_WasmPublishAsset
Include="@(StaticWebAsset)"
Expand All@@ -549,7 +546,6 @@ Copyright (c) .NET Foundation. All rights reserved.

<!-- We remove the extensions since they are added to the list of static web assets but we need to compute the target path for them -->
<_WasmPublishAsset Remove="@(_BlazorExtensionsCandidatesForPublish)" />

</ItemGroup>

<ComputeStaticWebAssetsTargetPaths
Expand All@@ -568,7 +564,7 @@ Copyright (c) .NET Foundation. All rights reserved.
AssemblyPath="@(IntermediateAssembly)"
Resources="@(_WasmPublishBootResourceWithHash)"
DebugBuild="false"
DebugLevel="$(_WasmDebugLevel)"
DebugLevel="$(WasmDebugLevel)"
LinkerEnabled="$(PublishTrimmed)"
CacheBootResources="$(BlazorCacheBootResources)"
OutputPath="$(IntermediateOutputPath)blazor.publish.boot.json"
Expand All@@ -584,7 +580,8 @@ Copyright (c) .NET Foundation. All rights reserved.
Extensions="@(WasmBootConfigExtension)"
TargetFrameworkVersion="$(TargetFrameworkVersion)"
ModuleAfterConfigLoaded="@(WasmModuleAfterConfigLoaded)"
ModuleAfterRuntimeReady="@(WasmModuleAfterRuntimeReady)" />
ModuleAfterRuntimeReady="@(WasmModuleAfterRuntimeReady)"
IsPublish="true" />

<ItemGroup>
<FileWrites Include="$(IntermediateOutputPath)blazor.publish.boot.json" />
Expand Down
7 changes: 6 additions & 1 deletion src/mono/wasi/build/WasiApp.targets
Original file line numberDiff line numberDiff line change
Expand Up@@ -66,6 +66,11 @@
Outputs="$(WasmAppDir)\.stamp"
Condition="'$(WasmGenerateAppBundle)' == 'true'">

<PropertyGroup>
<_WasmOutputSymbolsToAppBundle Condition="'$(CopyOutputSymbolsToPublishDirectory)' == 'true' and '$(_IsPublishing)' == 'true'">true</_WasmOutputSymbolsToAppBundle>
<_WasmOutputSymbolsToAppBundle Condition="'$(_WasmOutputSymbolsToAppBundle)' == ''">false</_WasmOutputSymbolsToAppBundle>
</PropertyGroup>

<WasiAppBuilder
AppDir="$(WasmAppDir)"
Assemblies="@(_WasmAssembliesInternal)"
Expand All@@ -80,7 +85,7 @@
FilesToIncludeInFileSystem="@(WasmFilesToIncludeInFileSystem)"
ExtraFilesToDeploy="@(WasmExtraFilesToDeploy)"
NativeAssets="@(WasmNativeAsset)"
DebugLevel="$(WasmDebugLevel)"
OutputSymbolsToAppBundle="$(_WasmOutputSymbolsToAppBundle)"
RuntimeConfigJsonPath="$(_WasmRuntimeConfigFilePath)"
/>
</Target>
Expand Down
6 changes: 6 additions & 0 deletions src/mono/wasm/Wasm.Build.Tests/Blazor/BlazorWasmTestBase.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -63,7 +63,9 @@ public string CreateBlazorWasmTemplateProject(string id)
(CommandResult res, string logPath) = BlazorBuildInternal(options.Id, options.Config, publish: false, setWasmDevel: false, expectSuccess: options.ExpectSuccess, extraArgs);

if (options.ExpectSuccess && options.AssertAppBundle)
{
AssertBundle(res.Output, options with { IsPublish = false });
}

return (res, logPath);
}
Expand All@@ -77,6 +79,10 @@ public string CreateBlazorWasmTemplateProject(string id)

if (options.ExpectSuccess && options.AssertAppBundle)
{
// Because we do relink in Release publish by default
if (options.Config == "Release")
options = options with { ExpectedFileType = NativeFilesType.Relinked };

AssertBundle(res.Output, options with { IsPublish = true });
}

Expand Down
3 changes: 2 additions & 1 deletion src/mono/wasm/Wasm.Build.Tests/Templates/InterpPgoTests.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,7 +34,7 @@ public async Task FirstRunGeneratesTableAndSecondRunLoadsIt(string config)

string id = $"browser_{config}_{GetRandomId()}";
_testOutput.WriteLine("/// Creating project");
string projectFile = CreateWasmTemplateProject(id, "wasmbrowser");
string projectFile = CreateWasmTemplateProject(id, "wasmbrowser", extraProperties: "<WasmDebugLevel>0</WasmDebugLevel>");

_testOutput.WriteLine("/// Updating JS");
UpdateBrowserMainJs((js) => {
Expand All@@ -53,6 +53,7 @@ public async Task FirstRunGeneratesTableAndSecondRunLoadsIt(string config)
// then call INTERNAL.interp_pgo_save_data() to save the interp PGO table
js = js.Replace(
"const text = exports.MyClass.Greeting();",
"console.log(`WASM debug level ${getConfig().debugLevel}`);\n" +
"let text = '';\n" +
$"for (let i = 0; i < {iterationCount}; i++) {{ text = exports.MyClass.Greeting(); }};\n" +
"await INTERNAL.interp_pgo_save_data();"
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,7 +28,7 @@ public async Task LoadAppSettingsBasedOnApplicationEnvironment(string applicatio
CopyTestAsset("WasmBasicTestApp", "AppSettingsTests");
PublishProject("Debug");

var result = await RunSdkStyleApp(new(
var result = await RunSdkStyleAppForPublish(new(
Configuration: "Debug",
TestScenario: "AppSettingsTest",
BrowserQueryString: new Dictionary<string, string> { ["applicationEnvironment"] = applicationEnvironment }
Expand Down
21 changes: 14 additions & 7 deletions src/mono/wasm/Wasm.Build.Tests/TestAppScenarios/AppTestBase.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,23 +36,29 @@ protected void CopyTestAsset(string assetName, string generatedProjectNamePrefix
_projectDir = Path.Combine(_projectDir!, "App");
}

protected void BuildProject(string configuration)
protected void BuildProject(string configuration, params string[] extraArgs)
{
(CommandResult result, _) = BlazorBuild(new BlazorBuildOptions(Id, configuration));
(CommandResult result, _) = BlazorBuild(new BlazorBuildOptions(Id, configuration), extraArgs);
result.EnsureSuccessful();
}

protected void PublishProject(string configuration)
protected void PublishProject(string configuration, params string[] extraArgs)
{
(CommandResult result, _) = BlazorPublish(new BlazorBuildOptions(Id, configuration));
(CommandResult result, _) = BlazorPublish(new BlazorBuildOptions(Id, configuration), extraArgs);
result.EnsureSuccessful();
}

protected ToolCommand CreateDotNetCommand() => new DotNetCommand(s_buildEnv, _testOutput)
.WithWorkingDirectory(_projectDir!)
.WithEnvironmentVariable("NUGET_PACKAGES", _nugetPackagesDir);

protected async Task<RunResult> RunSdkStyleApp(RunOptions options)
protected Task<RunResult> RunSdkStyleAppForBuild(RunOptions options)
=> RunSdkStyleApp(options, BlazorRunHost.DotnetRun);

protected Task<RunResult> RunSdkStyleAppForPublish(RunOptions options)
=> RunSdkStyleApp(options, BlazorRunHost.WebServer);

private async Task<RunResult> RunSdkStyleApp(RunOptions options, BlazorRunHost host = BlazorRunHost.DotnetRun)
{
string queryString = "?test=" + options.TestScenario;
if (options.BrowserQueryString != null)
Expand All@@ -67,9 +73,10 @@ protected async Task<RunResult> RunSdkStyleApp(RunOptions options)
CheckCounter: false,
Config: options.Configuration,
OnConsoleMessage: OnConsoleMessage,
QueryString: queryString);
QueryString: queryString,
Host: host);

await BlazorRunForBuildWithDotnetRun(blazorRunOptions);
await BlazorRunTest(blazorRunOptions);

void OnConsoleMessage(IConsoleMessage msg)
{
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6d25912
Update debug level logic
maraf Jan 19, 2024
64708fe
WBT 1
maraf Jan 19, 2024
7bb059f
Fix build
maraf Jan 19, 2024
89f9dd8
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Jan 24, 2024
9871731
Build project. Register tests
maraf Jan 24, 2024
2639ec8
Remove default to -1 from common props. Use separate build and publis…
maraf Jan 24, 2024
ff8622b
Switching between build and publish for run
maraf Jan 25, 2024
30595a7
More tests
maraf Jan 25, 2024
3affa88
Remove WasmDebugLevel defaults from WasmApp.Common.targets. Create si…
maraf Jan 25, 2024
0ffcdfe
Add configuration to generated project name
maraf Jan 26, 2024
39191f6
Expect relinked files when doing publish in Release
maraf Jan 26, 2024
310f641
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Feb 7, 2024
fa5c5b1
Auto relink only in publish
maraf Feb 7, 2024
550df31
Switch between dotnet run and webserver for hosting Blazor WBT
maraf Feb 7, 2024
f15dc21
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Feb 7, 2024
f5645d6
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Feb 8, 2024
78f5403
Fix using run for build in SatelliteLoadingTests
maraf Feb 8, 2024
2dcf713
Explicitly set debug level to 0 to trigger tiering
maraf Feb 8, 2024
713719f
Explicitly set debug level to 0 to trigger tiering (put debug level i…
maraf Feb 9, 2024
9d27cf4
Be sure not to fail download twice for the same asset
maraf Feb 9, 2024
ec563c0
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Feb 9, 2024
2f8c92b
Don't let missing debugger support override debug level used for logging
maraf Feb 9, 2024
bb28720
Fallback to count of pdbs
maraf Feb 9, 2024
9401db8
Update src/mono/wasi/build/WasiApp.targets
maraf Feb 10, 2024
67c562e
Feedback
maraf Feb 12, 2024
300d782
Feedback
maraf Feb 12, 2024
8e8d100
Fix build
maraf Feb 12, 2024
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
1 change: 1 addition & 0 deletions eng/testing/scenarios/BuildWasmAppsJobsList.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -44,3 +44,4 @@ Wasm.Build.Tests.WasmTemplateTests
Wasm.Build.Tests.WorkloadTests
Wasm.Build.Tests.TestAppScenarios.DownloadResourceProgressTests
Wasm.Build.Tests.MT.Blazor.SimpleMultiThreadedTests
Wasm.Build.Tests.TestAppScenarios.DebugLevelTests
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/cwraps.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -166,7 +166,7 @@ export interface t_Cwraps {
mono_wasm_load_icu_data(offset: VoidPtr): number;
mono_wasm_add_assembly(name: string, data: VoidPtr, size: number): number;
mono_wasm_add_satellite_assembly(name: string, culture: string, data: VoidPtr, size: number): void;
mono_wasm_load_runtime(unused: string, debugLevel: number): void;
mono_wasm_load_runtime(debugLevel: number): void;
mono_wasm_change_debugger_log_level(value: number): void;

mono_wasm_assembly_load(name: string): MonoAssembly;
Expand Down
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/driver.c
Original file line numberDiff line numberDiff line change
Expand Up@@ -181,7 +181,7 @@ cleanup_runtime_config (MonovmRuntimeConfigArguments *args, void *user_data)
}

EMSCRIPTEN_KEEPALIVE void
mono_wasm_load_runtime (const char *unused, int debug_level)
mono_wasm_load_runtime (int debug_level)
{
const char *interp_opts = "";

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

const pdbNameToLoad = changeExtension(dllAsset.name, ".pdb");
const shouldLoadPdb = loaderHelpers.hasDebuggingEnabled(loaderHelpers.config) && Object.prototype.hasOwnProperty.call(lazyAssemblies, pdbNameToLoad);
const shouldLoadPdb = loaderHelpers.config.debugLevel != 0 && loaderHelpers.isDebuggingSupported() && Object.prototype.hasOwnProperty.call(lazyAssemblies, pdbNameToLoad);

const dllBytesPromise = loaderHelpers.retrieve_asset_download(dllAsset);

Expand Down
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/loader/assets.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -266,7 +266,7 @@ export function prepareAssets() {
}
}

if (config.debugLevel != 0 && resources.pdb) {
if (config.debugLevel != 0 && loaderHelpers.isDebuggingSupported() && resources.pdb) {
for (const name in resources.pdb) {
assetsToLoad.push({
name,
Expand Down
12 changes: 2 additions & 10 deletions src/mono/browser/runtime/loader/config.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -197,13 +197,6 @@ export function normalizeConfig() {
config.environmentVariables["MONO_SLEEP_ABORT_LIMIT"] = "5000";
}

// Default values (when WasmDebugLevel is not set)
// - Build (debug) => debugBuild=true & debugLevel=-1 => -1
// - Build (release) => debugBuild=true & debugLevel=0 => 0
// - Publish (debug) => debugBuild=false & debugLevel=-1 => 0
// - Publish (release) => debugBuild=false & debugLevel=0 => 0
config.debugLevel = hasDebuggingEnabled(config) ? config.debugLevel : 0;

if (BuildConfiguration === "Debug" && config.diagnosticTracing === undefined) {
config.diagnosticTracing = true;
}
Expand DownExpand Up@@ -264,14 +257,13 @@ export async function mono_wasm_load_config(module: DotnetModuleInternal): Promi
}
}

export function hasDebuggingEnabled(config: MonoConfigInternal): boolean {
export function isDebuggingSupported(): boolean {
Comment thread
maraf marked this conversation as resolved.
// Copied from blazor MonoDebugger.ts/attachDebuggerHotkey
if (!globalThis.navigator) {
return false;
}

const hasReferencedPdbs = !!config.resources!.pdb;
Comment thread
maraf marked this conversation as resolved.
return (hasReferencedPdbs || config.debugLevel != 0) && (loaderHelpers.isChromium || loaderHelpers.isFirefox);
return loaderHelpers.isChromium || loaderHelpers.isFirefox;
}

async function loadBootConfig(module: DotnetModuleInternal): Promise<void> {
Expand Down
4 changes: 2 additions & 2 deletions src/mono/browser/runtime/loader/globals.ts
Original file line numberDiff line numberDiff 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, hasDebuggingEnabled } 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 DownExpand Up@@ -118,9 +118,9 @@ export function setLoaderGlobals(
purgeUnusedCacheEntriesAsync,
installUnhandledErrorHandler,

hasDebuggingEnabled,
retrieve_asset_download,
invokeLibraryInitializers,
isDebuggingSupported,

// from wasm-feature-detect npm package
exceptions,
Expand Down
10 changes: 7 additions & 3 deletions src/mono/browser/runtime/startup.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -515,7 +515,7 @@ async function start_runtime() {
if (runtimeHelpers.config.browserProfilerOptions)
mono_wasm_init_browser_profiler(runtimeHelpers.config.browserProfilerOptions);

mono_wasm_load_runtime("unused", runtimeHelpers.config.debugLevel);
mono_wasm_load_runtime();

if (runtimeHelpers.config.interpreterPgo)
setTimeout(maybeSaveInterpPgoTable, (runtimeHelpers.config.interpreterPgoSaveDelay || 15) * 1000);
Expand All@@ -534,17 +534,21 @@ async function maybeSaveInterpPgoTable() {
await interp_pgo_save_data();
}

export function mono_wasm_load_runtime(unused?: string, debugLevel?: number): void {
export function mono_wasm_load_runtime(): void {
mono_log_debug("mono_wasm_load_runtime");
try {
const mark = startMeasure();
let debugLevel = runtimeHelpers.config.debugLevel;
if (debugLevel == undefined) {
debugLevel = 0;
if (runtimeHelpers.config.debugLevel) {
debugLevel = 0 + debugLevel;
}
}
cwraps.mono_wasm_load_runtime(unused || "unused", debugLevel);
if (!loaderHelpers.isDebuggingSupported() || !runtimeHelpers.config.resources!.pdb) {
debugLevel = 0;
}
cwraps.mono_wasm_load_runtime(debugLevel);
endMeasure(mark, MeasuredBlock.loadRuntime);

} catch (err: any) {
Expand Down
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/types/internal.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -155,7 +155,6 @@ export type LoaderHelpers = {
out(message: string): void;
err(message: string): void;

hasDebuggingEnabled(config: MonoConfig): boolean,
retrieve_asset_download(asset: AssetEntry): Promise<ArrayBuffer>;
onDownloadResourceProgress?: (resourcesLoaded: number, totalResources: number) => void;
logDownloadStatsToConsole: () => void;
Expand All@@ -166,6 +165,7 @@ export type LoaderHelpers = {
invokeLibraryInitializers: (functionName: string, args: any[]) => Promise<void>,
libraryInitializers?: { scriptName: string, exports: any }[];

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

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -203,9 +203,6 @@ Copyright (c) .NET Foundation. All rights reserved.
<_BlazorWebAssemblyStartupMemoryCache>$(BlazorWebAssemblyStartupMemoryCache)</_BlazorWebAssemblyStartupMemoryCache>
<_BlazorWebAssemblyJiterpreter>$(BlazorWebAssemblyJiterpreter)</_BlazorWebAssemblyJiterpreter>
<_BlazorWebAssemblyRuntimeOptions>$(BlazorWebAssemblyRuntimeOptions)</_BlazorWebAssemblyRuntimeOptions>
<_WasmDebugLevel>$(WasmDebugLevel)</_WasmDebugLevel>
<_WasmDebugLevel Condition="'$(_WasmDebugLevel)' == ''">0</_WasmDebugLevel>
<_WasmDebugLevel Condition="'$(_WasmDebugLevel)' == '0' and ('$(DebuggerSupport)' == 'true' or '$(Configuration)' == 'Debug')">-1</_WasmDebugLevel>

<!-- Workaround for https://github.com/dotnet/sdk/issues/12114-->
<PublishDir Condition="'$(AppendRuntimeIdentifierToOutputPath)' != 'true' AND '$(PublishDir)' == '$(OutputPath)$(RuntimeIdentifier)\$(PublishDirName)\'">$(OutputPath)$(PublishDirName)\</PublishDir>
Expand DownExpand Up@@ -364,7 +361,7 @@ Copyright (c) .NET Foundation. All rights reserved.
AssemblyPath="@(IntermediateAssembly)"
Resources="@(_WasmOutputWithHash)"
DebugBuild="true"
DebugLevel="$(_WasmDebugLevel)"
DebugLevel="$(WasmDebugLevel)"
LinkerEnabled="false"
CacheBootResources="$(BlazorCacheBootResources)"
OutputPath="$(_WasmBuildBootJsonPath)"
Expand All@@ -380,7 +377,8 @@ Copyright (c) .NET Foundation. All rights reserved.
Extensions="@(WasmBootConfigExtension)"
TargetFrameworkVersion="$(TargetFrameworkVersion)"
ModuleAfterConfigLoaded="@(WasmModuleAfterConfigLoaded)"
ModuleAfterRuntimeReady="@(WasmModuleAfterRuntimeReady)" />
ModuleAfterRuntimeReady="@(WasmModuleAfterRuntimeReady)"
IsPublish="false" />

<ItemGroup>
<FileWrites Include="$(_WasmBuildBootJsonPath)" />
Expand DownExpand Up@@ -533,7 +531,6 @@ Copyright (c) .NET Foundation. All rights reserved.
</Target>

<Target Name="GeneratePublishWasmBootJson" DependsOnTargets="$(GeneratePublishWasmBootJsonDependsOn)">

<ItemGroup>
<_WasmPublishAsset
Include="@(StaticWebAsset)"
Expand All@@ -549,7 +546,6 @@ Copyright (c) .NET Foundation. All rights reserved.

<!-- We remove the extensions since they are added to the list of static web assets but we need to compute the target path for them -->
<_WasmPublishAsset Remove="@(_BlazorExtensionsCandidatesForPublish)" />

</ItemGroup>

<ComputeStaticWebAssetsTargetPaths
Expand All@@ -568,7 +564,7 @@ Copyright (c) .NET Foundation. All rights reserved.
AssemblyPath="@(IntermediateAssembly)"
Resources="@(_WasmPublishBootResourceWithHash)"
DebugBuild="false"
DebugLevel="$(_WasmDebugLevel)"
DebugLevel="$(WasmDebugLevel)"
LinkerEnabled="$(PublishTrimmed)"
CacheBootResources="$(BlazorCacheBootResources)"
OutputPath="$(IntermediateOutputPath)blazor.publish.boot.json"
Expand All@@ -584,7 +580,8 @@ Copyright (c) .NET Foundation. All rights reserved.
Extensions="@(WasmBootConfigExtension)"
TargetFrameworkVersion="$(TargetFrameworkVersion)"
ModuleAfterConfigLoaded="@(WasmModuleAfterConfigLoaded)"
ModuleAfterRuntimeReady="@(WasmModuleAfterRuntimeReady)" />
ModuleAfterRuntimeReady="@(WasmModuleAfterRuntimeReady)"
IsPublish="true" />

<ItemGroup>
<FileWrites Include="$(IntermediateOutputPath)blazor.publish.boot.json" />
Expand Down
7 changes: 6 additions & 1 deletion src/mono/wasi/build/WasiApp.targets
Original file line numberDiff line numberDiff line change
Expand Up@@ -66,6 +66,11 @@
Outputs="$(WasmAppDir)\.stamp"
Condition="'$(WasmGenerateAppBundle)' == 'true'">

<PropertyGroup>
<_WasmOutputSymbolsToAppBundle Condition="'$(CopyOutputSymbolsToPublishDirectory)' == 'true' and '$(_IsPublishing)' == 'true'">true</_WasmOutputSymbolsToAppBundle>
<_WasmOutputSymbolsToAppBundle Condition="'$(_WasmOutputSymbolsToAppBundle)' == ''">false</_WasmOutputSymbolsToAppBundle>
</PropertyGroup>

<WasiAppBuilder
AppDir="$(WasmAppDir)"
Assemblies="@(_WasmAssembliesInternal)"
Expand All@@ -80,7 +85,7 @@
FilesToIncludeInFileSystem="@(WasmFilesToIncludeInFileSystem)"
ExtraFilesToDeploy="@(WasmExtraFilesToDeploy)"
NativeAssets="@(WasmNativeAsset)"
DebugLevel="$(WasmDebugLevel)"
OutputSymbolsToAppBundle="$(_WasmOutputSymbolsToAppBundle)"
RuntimeConfigJsonPath="$(_WasmRuntimeConfigFilePath)"
/>
</Target>
Expand Down
6 changes: 6 additions & 0 deletions src/mono/wasm/Wasm.Build.Tests/Blazor/BlazorWasmTestBase.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -63,7 +63,9 @@ public string CreateBlazorWasmTemplateProject(string id)
(CommandResult res, string logPath) = BlazorBuildInternal(options.Id, options.Config, publish: false, setWasmDevel: false, expectSuccess: options.ExpectSuccess, extraArgs);

if (options.ExpectSuccess && options.AssertAppBundle)
{
AssertBundle(res.Output, options with { IsPublish = false });
}

return (res, logPath);
}
Expand All@@ -77,6 +79,10 @@ public string CreateBlazorWasmTemplateProject(string id)

if (options.ExpectSuccess && options.AssertAppBundle)
{
// Because we do relink in Release publish by default
if (options.Config == "Release")
options = options with { ExpectedFileType = NativeFilesType.Relinked };

AssertBundle(res.Output, options with { IsPublish = true });
}

Expand Down
3 changes: 2 additions & 1 deletion src/mono/wasm/Wasm.Build.Tests/Templates/InterpPgoTests.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,7 +34,7 @@ public async Task FirstRunGeneratesTableAndSecondRunLoadsIt(string config)

string id = $"browser_{config}_{GetRandomId()}";
_testOutput.WriteLine("/// Creating project");
string projectFile = CreateWasmTemplateProject(id, "wasmbrowser");
string projectFile = CreateWasmTemplateProject(id, "wasmbrowser", extraProperties: "<WasmDebugLevel>0</WasmDebugLevel>");

_testOutput.WriteLine("/// Updating JS");
UpdateBrowserMainJs((js) => {
Expand All@@ -53,6 +53,7 @@ public async Task FirstRunGeneratesTableAndSecondRunLoadsIt(string config)
// then call INTERNAL.interp_pgo_save_data() to save the interp PGO table
js = js.Replace(
"const text = exports.MyClass.Greeting();",
"console.log(`WASM debug level ${getConfig().debugLevel}`);\n" +
"let text = '';\n" +
$"for (let i = 0; i < {iterationCount}; i++) {{ text = exports.MyClass.Greeting(); }};\n" +
"await INTERNAL.interp_pgo_save_data();"
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,7 +28,7 @@ public async Task LoadAppSettingsBasedOnApplicationEnvironment(string applicatio
CopyTestAsset("WasmBasicTestApp", "AppSettingsTests");
PublishProject("Debug");

var result = await RunSdkStyleApp(new(
var result = await RunSdkStyleAppForPublish(new(
Configuration: "Debug",
TestScenario: "AppSettingsTest",
BrowserQueryString: new Dictionary<string, string> { ["applicationEnvironment"] = applicationEnvironment }
Expand Down
21 changes: 14 additions & 7 deletions src/mono/wasm/Wasm.Build.Tests/TestAppScenarios/AppTestBase.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,23 +36,29 @@ protected void CopyTestAsset(string assetName, string generatedProjectNamePrefix
_projectDir = Path.Combine(_projectDir!, "App");
}

protected void BuildProject(string configuration)
protected void BuildProject(string configuration, params string[] extraArgs)
{
(CommandResult result, _) = BlazorBuild(new BlazorBuildOptions(Id, configuration));
(CommandResult result, _) = BlazorBuild(new BlazorBuildOptions(Id, configuration), extraArgs);
result.EnsureSuccessful();
}

protected void PublishProject(string configuration)
protected void PublishProject(string configuration, params string[] extraArgs)
{
(CommandResult result, _) = BlazorPublish(new BlazorBuildOptions(Id, configuration));
(CommandResult result, _) = BlazorPublish(new BlazorBuildOptions(Id, configuration), extraArgs);
result.EnsureSuccessful();
}

protected ToolCommand CreateDotNetCommand() => new DotNetCommand(s_buildEnv, _testOutput)
.WithWorkingDirectory(_projectDir!)
.WithEnvironmentVariable("NUGET_PACKAGES", _nugetPackagesDir);

protected async Task<RunResult> RunSdkStyleApp(RunOptions options)
protected Task<RunResult> RunSdkStyleAppForBuild(RunOptions options)
=> RunSdkStyleApp(options, BlazorRunHost.DotnetRun);

protected Task<RunResult> RunSdkStyleAppForPublish(RunOptions options)
=> RunSdkStyleApp(options, BlazorRunHost.WebServer);

private async Task<RunResult> RunSdkStyleApp(RunOptions options, BlazorRunHost host = BlazorRunHost.DotnetRun)
{
string queryString = "?test=" + options.TestScenario;
if (options.BrowserQueryString != null)
Expand All@@ -67,9 +73,10 @@ protected async Task<RunResult> RunSdkStyleApp(RunOptions options)
CheckCounter: false,
Config: options.Configuration,
OnConsoleMessage: OnConsoleMessage,
QueryString: queryString);
QueryString: queryString,
Host: host);

await BlazorRunForBuildWithDotnetRun(blazorRunOptions);
await BlazorRunTest(blazorRunOptions);

void OnConsoleMessage(IConsoleMessage msg)
{
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6d25912
Update debug level logic
maraf Jan 19, 2024
64708fe
WBT 1
maraf Jan 19, 2024
7bb059f
Fix build
maraf Jan 19, 2024
89f9dd8
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Jan 24, 2024
9871731
Build project. Register tests
maraf Jan 24, 2024
2639ec8
Remove default to -1 from common props. Use separate build and publis…
maraf Jan 24, 2024
ff8622b
Switching between build and publish for run
maraf Jan 25, 2024
30595a7
More tests
maraf Jan 25, 2024
3affa88
Remove WasmDebugLevel defaults from WasmApp.Common.targets. Create si…
maraf Jan 25, 2024
0ffcdfe
Add configuration to generated project name
maraf Jan 26, 2024
39191f6
Expect relinked files when doing publish in Release
maraf Jan 26, 2024
310f641
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Feb 7, 2024
fa5c5b1
Auto relink only in publish
maraf Feb 7, 2024
550df31
Switch between dotnet run and webserver for hosting Blazor WBT
maraf Feb 7, 2024
f15dc21
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Feb 7, 2024
f5645d6
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Feb 8, 2024
78f5403
Fix using run for build in SatelliteLoadingTests
maraf Feb 8, 2024
2dcf713
Explicitly set debug level to 0 to trigger tiering
maraf Feb 8, 2024
713719f
Explicitly set debug level to 0 to trigger tiering (put debug level i…
maraf Feb 9, 2024
9d27cf4
Be sure not to fail download twice for the same asset
maraf Feb 9, 2024
ec563c0
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Feb 9, 2024
2f8c92b
Don't let missing debugger support override debug level used for logging
maraf Feb 9, 2024
bb28720
Fallback to count of pdbs
maraf Feb 9, 2024
9401db8
Update src/mono/wasi/build/WasiApp.targets
maraf Feb 10, 2024
67c562e
Feedback
maraf Feb 12, 2024
300d782
Feedback
maraf Feb 12, 2024
8e8d100
Fix build
maraf Feb 12, 2024
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
1 change: 1 addition & 0 deletions eng/testing/scenarios/BuildWasmAppsJobsList.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -44,3 +44,4 @@ Wasm.Build.Tests.WasmTemplateTests
Wasm.Build.Tests.WorkloadTests
Wasm.Build.Tests.TestAppScenarios.DownloadResourceProgressTests
Wasm.Build.Tests.MT.Blazor.SimpleMultiThreadedTests
Wasm.Build.Tests.TestAppScenarios.DebugLevelTests
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/cwraps.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -166,7 +166,7 @@ export interface t_Cwraps {
mono_wasm_load_icu_data(offset: VoidPtr): number;
mono_wasm_add_assembly(name: string, data: VoidPtr, size: number): number;
mono_wasm_add_satellite_assembly(name: string, culture: string, data: VoidPtr, size: number): void;
mono_wasm_load_runtime(unused: string, debugLevel: number): void;
mono_wasm_load_runtime(debugLevel: number): void;
mono_wasm_change_debugger_log_level(value: number): void;

mono_wasm_assembly_load(name: string): MonoAssembly;
Expand Down
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/driver.c
Original file line numberDiff line numberDiff line change
Expand Up@@ -181,7 +181,7 @@ cleanup_runtime_config (MonovmRuntimeConfigArguments *args, void *user_data)
}

EMSCRIPTEN_KEEPALIVE void
mono_wasm_load_runtime (const char *unused, int debug_level)
mono_wasm_load_runtime (int debug_level)
{
const char *interp_opts = "";

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

const pdbNameToLoad = changeExtension(dllAsset.name, ".pdb");
const shouldLoadPdb = loaderHelpers.hasDebuggingEnabled(loaderHelpers.config) && Object.prototype.hasOwnProperty.call(lazyAssemblies, pdbNameToLoad);
const shouldLoadPdb = loaderHelpers.config.debugLevel != 0 && loaderHelpers.isDebuggingSupported() && Object.prototype.hasOwnProperty.call(lazyAssemblies, pdbNameToLoad);

const dllBytesPromise = loaderHelpers.retrieve_asset_download(dllAsset);

Expand Down
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/loader/assets.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -266,7 +266,7 @@ export function prepareAssets() {
}
}

if (config.debugLevel != 0 && resources.pdb) {
if (config.debugLevel != 0 && loaderHelpers.isDebuggingSupported() && resources.pdb) {
for (const name in resources.pdb) {
assetsToLoad.push({
name,
Expand Down
12 changes: 2 additions & 10 deletions src/mono/browser/runtime/loader/config.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -197,13 +197,6 @@ export function normalizeConfig() {
config.environmentVariables["MONO_SLEEP_ABORT_LIMIT"] = "5000";
}

// Default values (when WasmDebugLevel is not set)
// - Build (debug) => debugBuild=true & debugLevel=-1 => -1
// - Build (release) => debugBuild=true & debugLevel=0 => 0
// - Publish (debug) => debugBuild=false & debugLevel=-1 => 0
// - Publish (release) => debugBuild=false & debugLevel=0 => 0
config.debugLevel = hasDebuggingEnabled(config) ? config.debugLevel : 0;

if (BuildConfiguration === "Debug" && config.diagnosticTracing === undefined) {
config.diagnosticTracing = true;
}
Expand DownExpand Up@@ -264,14 +257,13 @@ export async function mono_wasm_load_config(module: DotnetModuleInternal): Promi
}
}

export function hasDebuggingEnabled(config: MonoConfigInternal): boolean {
export function isDebuggingSupported(): boolean {
Comment thread
maraf marked this conversation as resolved.
// Copied from blazor MonoDebugger.ts/attachDebuggerHotkey
if (!globalThis.navigator) {
return false;
}

const hasReferencedPdbs = !!config.resources!.pdb;
Comment thread
maraf marked this conversation as resolved.
return (hasReferencedPdbs || config.debugLevel != 0) && (loaderHelpers.isChromium || loaderHelpers.isFirefox);
return loaderHelpers.isChromium || loaderHelpers.isFirefox;
}

async function loadBootConfig(module: DotnetModuleInternal): Promise<void> {
Expand Down
4 changes: 2 additions & 2 deletions src/mono/browser/runtime/loader/globals.ts
Original file line numberDiff line numberDiff 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, hasDebuggingEnabled } 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 DownExpand Up@@ -118,9 +118,9 @@ export function setLoaderGlobals(
purgeUnusedCacheEntriesAsync,
installUnhandledErrorHandler,

hasDebuggingEnabled,
retrieve_asset_download,
invokeLibraryInitializers,
isDebuggingSupported,

// from wasm-feature-detect npm package
exceptions,
Expand Down
10 changes: 7 additions & 3 deletions src/mono/browser/runtime/startup.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -515,7 +515,7 @@ async function start_runtime() {
if (runtimeHelpers.config.browserProfilerOptions)
mono_wasm_init_browser_profiler(runtimeHelpers.config.browserProfilerOptions);

mono_wasm_load_runtime("unused", runtimeHelpers.config.debugLevel);
mono_wasm_load_runtime();

if (runtimeHelpers.config.interpreterPgo)
setTimeout(maybeSaveInterpPgoTable, (runtimeHelpers.config.interpreterPgoSaveDelay || 15) * 1000);
Expand All@@ -534,17 +534,21 @@ async function maybeSaveInterpPgoTable() {
await interp_pgo_save_data();
}

export function mono_wasm_load_runtime(unused?: string, debugLevel?: number): void {
export function mono_wasm_load_runtime(): void {
mono_log_debug("mono_wasm_load_runtime");
try {
const mark = startMeasure();
let debugLevel = runtimeHelpers.config.debugLevel;
if (debugLevel == undefined) {
debugLevel = 0;
if (runtimeHelpers.config.debugLevel) {
debugLevel = 0 + debugLevel;
}
}
cwraps.mono_wasm_load_runtime(unused || "unused", debugLevel);
if (!loaderHelpers.isDebuggingSupported() || !runtimeHelpers.config.resources!.pdb) {
debugLevel = 0;
}
cwraps.mono_wasm_load_runtime(debugLevel);
endMeasure(mark, MeasuredBlock.loadRuntime);

} catch (err: any) {
Expand Down
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/types/internal.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -155,7 +155,6 @@ export type LoaderHelpers = {
out(message: string): void;
err(message: string): void;

hasDebuggingEnabled(config: MonoConfig): boolean,
retrieve_asset_download(asset: AssetEntry): Promise<ArrayBuffer>;
onDownloadResourceProgress?: (resourcesLoaded: number, totalResources: number) => void;
logDownloadStatsToConsole: () => void;
Expand All@@ -166,6 +165,7 @@ export type LoaderHelpers = {
invokeLibraryInitializers: (functionName: string, args: any[]) => Promise<void>,
libraryInitializers?: { scriptName: string, exports: any }[];

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

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -203,9 +203,6 @@ Copyright (c) .NET Foundation. All rights reserved.
<_BlazorWebAssemblyStartupMemoryCache>$(BlazorWebAssemblyStartupMemoryCache)</_BlazorWebAssemblyStartupMemoryCache>
<_BlazorWebAssemblyJiterpreter>$(BlazorWebAssemblyJiterpreter)</_BlazorWebAssemblyJiterpreter>
<_BlazorWebAssemblyRuntimeOptions>$(BlazorWebAssemblyRuntimeOptions)</_BlazorWebAssemblyRuntimeOptions>
<_WasmDebugLevel>$(WasmDebugLevel)</_WasmDebugLevel>
<_WasmDebugLevel Condition="'$(_WasmDebugLevel)' == ''">0</_WasmDebugLevel>
<_WasmDebugLevel Condition="'$(_WasmDebugLevel)' == '0' and ('$(DebuggerSupport)' == 'true' or '$(Configuration)' == 'Debug')">-1</_WasmDebugLevel>

<!-- Workaround for https://github.com/dotnet/sdk/issues/12114-->
<PublishDir Condition="'$(AppendRuntimeIdentifierToOutputPath)' != 'true' AND '$(PublishDir)' == '$(OutputPath)$(RuntimeIdentifier)\$(PublishDirName)\'">$(OutputPath)$(PublishDirName)\</PublishDir>
Expand DownExpand Up@@ -364,7 +361,7 @@ Copyright (c) .NET Foundation. All rights reserved.
AssemblyPath="@(IntermediateAssembly)"
Resources="@(_WasmOutputWithHash)"
DebugBuild="true"
DebugLevel="$(_WasmDebugLevel)"
DebugLevel="$(WasmDebugLevel)"
LinkerEnabled="false"
CacheBootResources="$(BlazorCacheBootResources)"
OutputPath="$(_WasmBuildBootJsonPath)"
Expand All@@ -380,7 +377,8 @@ Copyright (c) .NET Foundation. All rights reserved.
Extensions="@(WasmBootConfigExtension)"
TargetFrameworkVersion="$(TargetFrameworkVersion)"
ModuleAfterConfigLoaded="@(WasmModuleAfterConfigLoaded)"
ModuleAfterRuntimeReady="@(WasmModuleAfterRuntimeReady)" />
ModuleAfterRuntimeReady="@(WasmModuleAfterRuntimeReady)"
IsPublish="false" />

<ItemGroup>
<FileWrites Include="$(_WasmBuildBootJsonPath)" />
Expand DownExpand Up@@ -533,7 +531,6 @@ Copyright (c) .NET Foundation. All rights reserved.
</Target>

<Target Name="GeneratePublishWasmBootJson" DependsOnTargets="$(GeneratePublishWasmBootJsonDependsOn)">

<ItemGroup>
<_WasmPublishAsset
Include="@(StaticWebAsset)"
Expand All@@ -549,7 +546,6 @@ Copyright (c) .NET Foundation. All rights reserved.

<!-- We remove the extensions since they are added to the list of static web assets but we need to compute the target path for them -->
<_WasmPublishAsset Remove="@(_BlazorExtensionsCandidatesForPublish)" />

</ItemGroup>

<ComputeStaticWebAssetsTargetPaths
Expand All@@ -568,7 +564,7 @@ Copyright (c) .NET Foundation. All rights reserved.
AssemblyPath="@(IntermediateAssembly)"
Resources="@(_WasmPublishBootResourceWithHash)"
DebugBuild="false"
DebugLevel="$(_WasmDebugLevel)"
DebugLevel="$(WasmDebugLevel)"
LinkerEnabled="$(PublishTrimmed)"
CacheBootResources="$(BlazorCacheBootResources)"
OutputPath="$(IntermediateOutputPath)blazor.publish.boot.json"
Expand All@@ -584,7 +580,8 @@ Copyright (c) .NET Foundation. All rights reserved.
Extensions="@(WasmBootConfigExtension)"
TargetFrameworkVersion="$(TargetFrameworkVersion)"
ModuleAfterConfigLoaded="@(WasmModuleAfterConfigLoaded)"
ModuleAfterRuntimeReady="@(WasmModuleAfterRuntimeReady)" />
ModuleAfterRuntimeReady="@(WasmModuleAfterRuntimeReady)"
IsPublish="true" />

<ItemGroup>
<FileWrites Include="$(IntermediateOutputPath)blazor.publish.boot.json" />
Expand Down
7 changes: 6 additions & 1 deletion src/mono/wasi/build/WasiApp.targets
Original file line numberDiff line numberDiff line change
Expand Up@@ -66,6 +66,11 @@
Outputs="$(WasmAppDir)\.stamp"
Condition="'$(WasmGenerateAppBundle)' == 'true'">

<PropertyGroup>
<_WasmOutputSymbolsToAppBundle Condition="'$(CopyOutputSymbolsToPublishDirectory)' == 'true' and '$(_IsPublishing)' == 'true'">true</_WasmOutputSymbolsToAppBundle>
<_WasmOutputSymbolsToAppBundle Condition="'$(_WasmOutputSymbolsToAppBundle)' == ''">false</_WasmOutputSymbolsToAppBundle>
</PropertyGroup>

<WasiAppBuilder
AppDir="$(WasmAppDir)"
Assemblies="@(_WasmAssembliesInternal)"
Expand All@@ -80,7 +85,7 @@
FilesToIncludeInFileSystem="@(WasmFilesToIncludeInFileSystem)"
ExtraFilesToDeploy="@(WasmExtraFilesToDeploy)"
NativeAssets="@(WasmNativeAsset)"
DebugLevel="$(WasmDebugLevel)"
OutputSymbolsToAppBundle="$(_WasmOutputSymbolsToAppBundle)"
RuntimeConfigJsonPath="$(_WasmRuntimeConfigFilePath)"
/>
</Target>
Expand Down
6 changes: 6 additions & 0 deletions src/mono/wasm/Wasm.Build.Tests/Blazor/BlazorWasmTestBase.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -63,7 +63,9 @@ public string CreateBlazorWasmTemplateProject(string id)
(CommandResult res, string logPath) = BlazorBuildInternal(options.Id, options.Config, publish: false, setWasmDevel: false, expectSuccess: options.ExpectSuccess, extraArgs);

if (options.ExpectSuccess && options.AssertAppBundle)
{
AssertBundle(res.Output, options with { IsPublish = false });
}

return (res, logPath);
}
Expand All@@ -77,6 +79,10 @@ public string CreateBlazorWasmTemplateProject(string id)

if (options.ExpectSuccess && options.AssertAppBundle)
{
// Because we do relink in Release publish by default
if (options.Config == "Release")
options = options with { ExpectedFileType = NativeFilesType.Relinked };

AssertBundle(res.Output, options with { IsPublish = true });
}

Expand Down
3 changes: 2 additions & 1 deletion src/mono/wasm/Wasm.Build.Tests/Templates/InterpPgoTests.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,7 +34,7 @@ public async Task FirstRunGeneratesTableAndSecondRunLoadsIt(string config)

string id = $"browser_{config}_{GetRandomId()}";
_testOutput.WriteLine("/// Creating project");
string projectFile = CreateWasmTemplateProject(id, "wasmbrowser");
string projectFile = CreateWasmTemplateProject(id, "wasmbrowser", extraProperties: "<WasmDebugLevel>0</WasmDebugLevel>");

_testOutput.WriteLine("/// Updating JS");
UpdateBrowserMainJs((js) => {
Expand All@@ -53,6 +53,7 @@ public async Task FirstRunGeneratesTableAndSecondRunLoadsIt(string config)
// then call INTERNAL.interp_pgo_save_data() to save the interp PGO table
js = js.Replace(
"const text = exports.MyClass.Greeting();",
"console.log(`WASM debug level ${getConfig().debugLevel}`);\n" +
"let text = '';\n" +
$"for (let i = 0; i < {iterationCount}; i++) {{ text = exports.MyClass.Greeting(); }};\n" +
"await INTERNAL.interp_pgo_save_data();"
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,7 +28,7 @@ public async Task LoadAppSettingsBasedOnApplicationEnvironment(string applicatio
CopyTestAsset("WasmBasicTestApp", "AppSettingsTests");
PublishProject("Debug");

var result = await RunSdkStyleApp(new(
var result = await RunSdkStyleAppForPublish(new(
Configuration: "Debug",
TestScenario: "AppSettingsTest",
BrowserQueryString: new Dictionary<string, string> { ["applicationEnvironment"] = applicationEnvironment }
Expand Down
21 changes: 14 additions & 7 deletions src/mono/wasm/Wasm.Build.Tests/TestAppScenarios/AppTestBase.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,23 +36,29 @@ protected void CopyTestAsset(string assetName, string generatedProjectNamePrefix
_projectDir = Path.Combine(_projectDir!, "App");
}

protected void BuildProject(string configuration)
protected void BuildProject(string configuration, params string[] extraArgs)
{
(CommandResult result, _) = BlazorBuild(new BlazorBuildOptions(Id, configuration));
(CommandResult result, _) = BlazorBuild(new BlazorBuildOptions(Id, configuration), extraArgs);
result.EnsureSuccessful();
}

protected void PublishProject(string configuration)
protected void PublishProject(string configuration, params string[] extraArgs)
{
(CommandResult result, _) = BlazorPublish(new BlazorBuildOptions(Id, configuration));
(CommandResult result, _) = BlazorPublish(new BlazorBuildOptions(Id, configuration), extraArgs);
result.EnsureSuccessful();
}

protected ToolCommand CreateDotNetCommand() => new DotNetCommand(s_buildEnv, _testOutput)
.WithWorkingDirectory(_projectDir!)
.WithEnvironmentVariable("NUGET_PACKAGES", _nugetPackagesDir);

protected async Task<RunResult> RunSdkStyleApp(RunOptions options)
protected Task<RunResult> RunSdkStyleAppForBuild(RunOptions options)
=> RunSdkStyleApp(options, BlazorRunHost.DotnetRun);

protected Task<RunResult> RunSdkStyleAppForPublish(RunOptions options)
=> RunSdkStyleApp(options, BlazorRunHost.WebServer);

private async Task<RunResult> RunSdkStyleApp(RunOptions options, BlazorRunHost host = BlazorRunHost.DotnetRun)
{
string queryString = "?test=" + options.TestScenario;
if (options.BrowserQueryString != null)
Expand All@@ -67,9 +73,10 @@ protected async Task<RunResult> RunSdkStyleApp(RunOptions options)
CheckCounter: false,
Config: options.Configuration,
OnConsoleMessage: OnConsoleMessage,
QueryString: queryString);
QueryString: queryString,
Host: host);

await BlazorRunForBuildWithDotnetRun(blazorRunOptions);
await BlazorRunTest(blazorRunOptions);

void OnConsoleMessage(IConsoleMessage msg)
{
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6d25912
Update debug level logic
maraf Jan 19, 2024
64708fe
WBT 1
maraf Jan 19, 2024
7bb059f
Fix build
maraf Jan 19, 2024
89f9dd8
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Jan 24, 2024
9871731
Build project. Register tests
maraf Jan 24, 2024
2639ec8
Remove default to -1 from common props. Use separate build and publis…
maraf Jan 24, 2024
ff8622b
Switching between build and publish for run
maraf Jan 25, 2024
30595a7
More tests
maraf Jan 25, 2024
3affa88
Remove WasmDebugLevel defaults from WasmApp.Common.targets. Create si…
maraf Jan 25, 2024
0ffcdfe
Add configuration to generated project name
maraf Jan 26, 2024
39191f6
Expect relinked files when doing publish in Release
maraf Jan 26, 2024
310f641
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Feb 7, 2024
fa5c5b1
Auto relink only in publish
maraf Feb 7, 2024
550df31
Switch between dotnet run and webserver for hosting Blazor WBT
maraf Feb 7, 2024
f15dc21
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Feb 7, 2024
f5645d6
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Feb 8, 2024
78f5403
Fix using run for build in SatelliteLoadingTests
maraf Feb 8, 2024
2dcf713
Explicitly set debug level to 0 to trigger tiering
maraf Feb 8, 2024
713719f
Explicitly set debug level to 0 to trigger tiering (put debug level i…
maraf Feb 9, 2024
9d27cf4
Be sure not to fail download twice for the same asset
maraf Feb 9, 2024
ec563c0
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Feb 9, 2024
2f8c92b
Don't let missing debugger support override debug level used for logging
maraf Feb 9, 2024
bb28720
Fallback to count of pdbs
maraf Feb 9, 2024
9401db8
Update src/mono/wasi/build/WasiApp.targets
maraf Feb 10, 2024
67c562e
Feedback
maraf Feb 12, 2024
300d782
Feedback
maraf Feb 12, 2024
8e8d100
Fix build
maraf Feb 12, 2024
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
1 change: 1 addition & 0 deletions eng/testing/scenarios/BuildWasmAppsJobsList.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -44,3 +44,4 @@ Wasm.Build.Tests.WasmTemplateTests
Wasm.Build.Tests.WorkloadTests
Wasm.Build.Tests.TestAppScenarios.DownloadResourceProgressTests
Wasm.Build.Tests.MT.Blazor.SimpleMultiThreadedTests
Wasm.Build.Tests.TestAppScenarios.DebugLevelTests
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/cwraps.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -166,7 +166,7 @@ export interface t_Cwraps {
mono_wasm_load_icu_data(offset: VoidPtr): number;
mono_wasm_add_assembly(name: string, data: VoidPtr, size: number): number;
mono_wasm_add_satellite_assembly(name: string, culture: string, data: VoidPtr, size: number): void;
mono_wasm_load_runtime(unused: string, debugLevel: number): void;
mono_wasm_load_runtime(debugLevel: number): void;
mono_wasm_change_debugger_log_level(value: number): void;

mono_wasm_assembly_load(name: string): MonoAssembly;
Expand Down
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/driver.c
Original file line numberDiff line numberDiff line change
Expand Up@@ -181,7 +181,7 @@ cleanup_runtime_config (MonovmRuntimeConfigArguments *args, void *user_data)
}

EMSCRIPTEN_KEEPALIVE void
mono_wasm_load_runtime (const char *unused, int debug_level)
mono_wasm_load_runtime (int debug_level)
{
const char *interp_opts = "";

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

const pdbNameToLoad = changeExtension(dllAsset.name, ".pdb");
const shouldLoadPdb = loaderHelpers.hasDebuggingEnabled(loaderHelpers.config) && Object.prototype.hasOwnProperty.call(lazyAssemblies, pdbNameToLoad);
const shouldLoadPdb = loaderHelpers.config.debugLevel != 0 && loaderHelpers.isDebuggingSupported() && Object.prototype.hasOwnProperty.call(lazyAssemblies, pdbNameToLoad);

const dllBytesPromise = loaderHelpers.retrieve_asset_download(dllAsset);

Expand Down
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/loader/assets.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -266,7 +266,7 @@ export function prepareAssets() {
}
}

if (config.debugLevel != 0 && resources.pdb) {
if (config.debugLevel != 0 && loaderHelpers.isDebuggingSupported() && resources.pdb) {
for (const name in resources.pdb) {
assetsToLoad.push({
name,
Expand Down
12 changes: 2 additions & 10 deletions src/mono/browser/runtime/loader/config.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -197,13 +197,6 @@ export function normalizeConfig() {
config.environmentVariables["MONO_SLEEP_ABORT_LIMIT"] = "5000";
}

// Default values (when WasmDebugLevel is not set)
// - Build (debug) => debugBuild=true & debugLevel=-1 => -1
// - Build (release) => debugBuild=true & debugLevel=0 => 0
// - Publish (debug) => debugBuild=false & debugLevel=-1 => 0
// - Publish (release) => debugBuild=false & debugLevel=0 => 0
config.debugLevel = hasDebuggingEnabled(config) ? config.debugLevel : 0;

if (BuildConfiguration === "Debug" && config.diagnosticTracing === undefined) {
config.diagnosticTracing = true;
}
Expand DownExpand Up@@ -264,14 +257,13 @@ export async function mono_wasm_load_config(module: DotnetModuleInternal): Promi
}
}

export function hasDebuggingEnabled(config: MonoConfigInternal): boolean {
export function isDebuggingSupported(): boolean {
Comment thread
maraf marked this conversation as resolved.
// Copied from blazor MonoDebugger.ts/attachDebuggerHotkey
if (!globalThis.navigator) {
return false;
}

const hasReferencedPdbs = !!config.resources!.pdb;
Comment thread
maraf marked this conversation as resolved.
return (hasReferencedPdbs || config.debugLevel != 0) && (loaderHelpers.isChromium || loaderHelpers.isFirefox);
return loaderHelpers.isChromium || loaderHelpers.isFirefox;
}

async function loadBootConfig(module: DotnetModuleInternal): Promise<void> {
Expand Down
4 changes: 2 additions & 2 deletions src/mono/browser/runtime/loader/globals.ts
Original file line numberDiff line numberDiff 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, hasDebuggingEnabled } 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 DownExpand Up@@ -118,9 +118,9 @@ export function setLoaderGlobals(
purgeUnusedCacheEntriesAsync,
installUnhandledErrorHandler,

hasDebuggingEnabled,
retrieve_asset_download,
invokeLibraryInitializers,
isDebuggingSupported,

// from wasm-feature-detect npm package
exceptions,
Expand Down
10 changes: 7 additions & 3 deletions src/mono/browser/runtime/startup.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -515,7 +515,7 @@ async function start_runtime() {
if (runtimeHelpers.config.browserProfilerOptions)
mono_wasm_init_browser_profiler(runtimeHelpers.config.browserProfilerOptions);

mono_wasm_load_runtime("unused", runtimeHelpers.config.debugLevel);
mono_wasm_load_runtime();

if (runtimeHelpers.config.interpreterPgo)
setTimeout(maybeSaveInterpPgoTable, (runtimeHelpers.config.interpreterPgoSaveDelay || 15) * 1000);
Expand All@@ -534,17 +534,21 @@ async function maybeSaveInterpPgoTable() {
await interp_pgo_save_data();
}

export function mono_wasm_load_runtime(unused?: string, debugLevel?: number): void {
export function mono_wasm_load_runtime(): void {
mono_log_debug("mono_wasm_load_runtime");
try {
const mark = startMeasure();
let debugLevel = runtimeHelpers.config.debugLevel;
if (debugLevel == undefined) {
debugLevel = 0;
if (runtimeHelpers.config.debugLevel) {
debugLevel = 0 + debugLevel;
}
}
cwraps.mono_wasm_load_runtime(unused || "unused", debugLevel);
if (!loaderHelpers.isDebuggingSupported() || !runtimeHelpers.config.resources!.pdb) {
debugLevel = 0;
}
cwraps.mono_wasm_load_runtime(debugLevel);
endMeasure(mark, MeasuredBlock.loadRuntime);

} catch (err: any) {
Expand Down
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/types/internal.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -155,7 +155,6 @@ export type LoaderHelpers = {
out(message: string): void;
err(message: string): void;

hasDebuggingEnabled(config: MonoConfig): boolean,
retrieve_asset_download(asset: AssetEntry): Promise<ArrayBuffer>;
onDownloadResourceProgress?: (resourcesLoaded: number, totalResources: number) => void;
logDownloadStatsToConsole: () => void;
Expand All@@ -166,6 +165,7 @@ export type LoaderHelpers = {
invokeLibraryInitializers: (functionName: string, args: any[]) => Promise<void>,
libraryInitializers?: { scriptName: string, exports: any }[];

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

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -203,9 +203,6 @@ Copyright (c) .NET Foundation. All rights reserved.
<_BlazorWebAssemblyStartupMemoryCache>$(BlazorWebAssemblyStartupMemoryCache)</_BlazorWebAssemblyStartupMemoryCache>
<_BlazorWebAssemblyJiterpreter>$(BlazorWebAssemblyJiterpreter)</_BlazorWebAssemblyJiterpreter>
<_BlazorWebAssemblyRuntimeOptions>$(BlazorWebAssemblyRuntimeOptions)</_BlazorWebAssemblyRuntimeOptions>
<_WasmDebugLevel>$(WasmDebugLevel)</_WasmDebugLevel>
<_WasmDebugLevel Condition="'$(_WasmDebugLevel)' == ''">0</_WasmDebugLevel>
<_WasmDebugLevel Condition="'$(_WasmDebugLevel)' == '0' and ('$(DebuggerSupport)' == 'true' or '$(Configuration)' == 'Debug')">-1</_WasmDebugLevel>

<!-- Workaround for https://github.com/dotnet/sdk/issues/12114-->
<PublishDir Condition="'$(AppendRuntimeIdentifierToOutputPath)' != 'true' AND '$(PublishDir)' == '$(OutputPath)$(RuntimeIdentifier)\$(PublishDirName)\'">$(OutputPath)$(PublishDirName)\</PublishDir>
Expand DownExpand Up@@ -364,7 +361,7 @@ Copyright (c) .NET Foundation. All rights reserved.
AssemblyPath="@(IntermediateAssembly)"
Resources="@(_WasmOutputWithHash)"
DebugBuild="true"
DebugLevel="$(_WasmDebugLevel)"
DebugLevel="$(WasmDebugLevel)"
LinkerEnabled="false"
CacheBootResources="$(BlazorCacheBootResources)"
OutputPath="$(_WasmBuildBootJsonPath)"
Expand All@@ -380,7 +377,8 @@ Copyright (c) .NET Foundation. All rights reserved.
Extensions="@(WasmBootConfigExtension)"
TargetFrameworkVersion="$(TargetFrameworkVersion)"
ModuleAfterConfigLoaded="@(WasmModuleAfterConfigLoaded)"
ModuleAfterRuntimeReady="@(WasmModuleAfterRuntimeReady)" />
ModuleAfterRuntimeReady="@(WasmModuleAfterRuntimeReady)"
IsPublish="false" />

<ItemGroup>
<FileWrites Include="$(_WasmBuildBootJsonPath)" />
Expand DownExpand Up@@ -533,7 +531,6 @@ Copyright (c) .NET Foundation. All rights reserved.
</Target>

<Target Name="GeneratePublishWasmBootJson" DependsOnTargets="$(GeneratePublishWasmBootJsonDependsOn)">

<ItemGroup>
<_WasmPublishAsset
Include="@(StaticWebAsset)"
Expand All@@ -549,7 +546,6 @@ Copyright (c) .NET Foundation. All rights reserved.

<!-- We remove the extensions since they are added to the list of static web assets but we need to compute the target path for them -->
<_WasmPublishAsset Remove="@(_BlazorExtensionsCandidatesForPublish)" />

</ItemGroup>

<ComputeStaticWebAssetsTargetPaths
Expand All@@ -568,7 +564,7 @@ Copyright (c) .NET Foundation. All rights reserved.
AssemblyPath="@(IntermediateAssembly)"
Resources="@(_WasmPublishBootResourceWithHash)"
DebugBuild="false"
DebugLevel="$(_WasmDebugLevel)"
DebugLevel="$(WasmDebugLevel)"
LinkerEnabled="$(PublishTrimmed)"
CacheBootResources="$(BlazorCacheBootResources)"
OutputPath="$(IntermediateOutputPath)blazor.publish.boot.json"
Expand All@@ -584,7 +580,8 @@ Copyright (c) .NET Foundation. All rights reserved.
Extensions="@(WasmBootConfigExtension)"
TargetFrameworkVersion="$(TargetFrameworkVersion)"
ModuleAfterConfigLoaded="@(WasmModuleAfterConfigLoaded)"
ModuleAfterRuntimeReady="@(WasmModuleAfterRuntimeReady)" />
ModuleAfterRuntimeReady="@(WasmModuleAfterRuntimeReady)"
IsPublish="true" />

<ItemGroup>
<FileWrites Include="$(IntermediateOutputPath)blazor.publish.boot.json" />
Expand Down
7 changes: 6 additions & 1 deletion src/mono/wasi/build/WasiApp.targets
Original file line numberDiff line numberDiff line change
Expand Up@@ -66,6 +66,11 @@
Outputs="$(WasmAppDir)\.stamp"
Condition="'$(WasmGenerateAppBundle)' == 'true'">

<PropertyGroup>
<_WasmOutputSymbolsToAppBundle Condition="'$(CopyOutputSymbolsToPublishDirectory)' == 'true' and '$(_IsPublishing)' == 'true'">true</_WasmOutputSymbolsToAppBundle>
<_WasmOutputSymbolsToAppBundle Condition="'$(_WasmOutputSymbolsToAppBundle)' == ''">false</_WasmOutputSymbolsToAppBundle>
</PropertyGroup>

<WasiAppBuilder
AppDir="$(WasmAppDir)"
Assemblies="@(_WasmAssembliesInternal)"
Expand All@@ -80,7 +85,7 @@
FilesToIncludeInFileSystem="@(WasmFilesToIncludeInFileSystem)"
ExtraFilesToDeploy="@(WasmExtraFilesToDeploy)"
NativeAssets="@(WasmNativeAsset)"
DebugLevel="$(WasmDebugLevel)"
OutputSymbolsToAppBundle="$(_WasmOutputSymbolsToAppBundle)"
RuntimeConfigJsonPath="$(_WasmRuntimeConfigFilePath)"
/>
</Target>
Expand Down
6 changes: 6 additions & 0 deletions src/mono/wasm/Wasm.Build.Tests/Blazor/BlazorWasmTestBase.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -63,7 +63,9 @@ public string CreateBlazorWasmTemplateProject(string id)
(CommandResult res, string logPath) = BlazorBuildInternal(options.Id, options.Config, publish: false, setWasmDevel: false, expectSuccess: options.ExpectSuccess, extraArgs);

if (options.ExpectSuccess && options.AssertAppBundle)
{
AssertBundle(res.Output, options with { IsPublish = false });
}

return (res, logPath);
}
Expand All@@ -77,6 +79,10 @@ public string CreateBlazorWasmTemplateProject(string id)

if (options.ExpectSuccess && options.AssertAppBundle)
{
// Because we do relink in Release publish by default
if (options.Config == "Release")
options = options with { ExpectedFileType = NativeFilesType.Relinked };

AssertBundle(res.Output, options with { IsPublish = true });
}

Expand Down
3 changes: 2 additions & 1 deletion src/mono/wasm/Wasm.Build.Tests/Templates/InterpPgoTests.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,7 +34,7 @@ public async Task FirstRunGeneratesTableAndSecondRunLoadsIt(string config)

string id = $"browser_{config}_{GetRandomId()}";
_testOutput.WriteLine("/// Creating project");
string projectFile = CreateWasmTemplateProject(id, "wasmbrowser");
string projectFile = CreateWasmTemplateProject(id, "wasmbrowser", extraProperties: "<WasmDebugLevel>0</WasmDebugLevel>");

_testOutput.WriteLine("/// Updating JS");
UpdateBrowserMainJs((js) => {
Expand All@@ -53,6 +53,7 @@ public async Task FirstRunGeneratesTableAndSecondRunLoadsIt(string config)
// then call INTERNAL.interp_pgo_save_data() to save the interp PGO table
js = js.Replace(
"const text = exports.MyClass.Greeting();",
"console.log(`WASM debug level ${getConfig().debugLevel}`);\n" +
"let text = '';\n" +
$"for (let i = 0; i < {iterationCount}; i++) {{ text = exports.MyClass.Greeting(); }};\n" +
"await INTERNAL.interp_pgo_save_data();"
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,7 +28,7 @@ public async Task LoadAppSettingsBasedOnApplicationEnvironment(string applicatio
CopyTestAsset("WasmBasicTestApp", "AppSettingsTests");
PublishProject("Debug");

var result = await RunSdkStyleApp(new(
var result = await RunSdkStyleAppForPublish(new(
Configuration: "Debug",
TestScenario: "AppSettingsTest",
BrowserQueryString: new Dictionary<string, string> { ["applicationEnvironment"] = applicationEnvironment }
Expand Down
21 changes: 14 additions & 7 deletions src/mono/wasm/Wasm.Build.Tests/TestAppScenarios/AppTestBase.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,23 +36,29 @@ protected void CopyTestAsset(string assetName, string generatedProjectNamePrefix
_projectDir = Path.Combine(_projectDir!, "App");
}

protected void BuildProject(string configuration)
protected void BuildProject(string configuration, params string[] extraArgs)
{
(CommandResult result, _) = BlazorBuild(new BlazorBuildOptions(Id, configuration));
(CommandResult result, _) = BlazorBuild(new BlazorBuildOptions(Id, configuration), extraArgs);
result.EnsureSuccessful();
}

protected void PublishProject(string configuration)
protected void PublishProject(string configuration, params string[] extraArgs)
{
(CommandResult result, _) = BlazorPublish(new BlazorBuildOptions(Id, configuration));
(CommandResult result, _) = BlazorPublish(new BlazorBuildOptions(Id, configuration), extraArgs);
result.EnsureSuccessful();
}

protected ToolCommand CreateDotNetCommand() => new DotNetCommand(s_buildEnv, _testOutput)
.WithWorkingDirectory(_projectDir!)
.WithEnvironmentVariable("NUGET_PACKAGES", _nugetPackagesDir);

protected async Task<RunResult> RunSdkStyleApp(RunOptions options)
protected Task<RunResult> RunSdkStyleAppForBuild(RunOptions options)
=> RunSdkStyleApp(options, BlazorRunHost.DotnetRun);

protected Task<RunResult> RunSdkStyleAppForPublish(RunOptions options)
=> RunSdkStyleApp(options, BlazorRunHost.WebServer);

private async Task<RunResult> RunSdkStyleApp(RunOptions options, BlazorRunHost host = BlazorRunHost.DotnetRun)
{
string queryString = "?test=" + options.TestScenario;
if (options.BrowserQueryString != null)
Expand All@@ -67,9 +73,10 @@ protected async Task<RunResult> RunSdkStyleApp(RunOptions options)
CheckCounter: false,
Config: options.Configuration,
OnConsoleMessage: OnConsoleMessage,
QueryString: queryString);
QueryString: queryString,
Host: host);

await BlazorRunForBuildWithDotnetRun(blazorRunOptions);
await BlazorRunTest(blazorRunOptions);

void OnConsoleMessage(IConsoleMessage msg)
{
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6d25912
Update debug level logic
maraf Jan 19, 2024
64708fe
WBT 1
maraf Jan 19, 2024
7bb059f
Fix build
maraf Jan 19, 2024
89f9dd8
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Jan 24, 2024
9871731
Build project. Register tests
maraf Jan 24, 2024
2639ec8
Remove default to -1 from common props. Use separate build and publis…
maraf Jan 24, 2024
ff8622b
Switching between build and publish for run
maraf Jan 25, 2024
30595a7
More tests
maraf Jan 25, 2024
3affa88
Remove WasmDebugLevel defaults from WasmApp.Common.targets. Create si…
maraf Jan 25, 2024
0ffcdfe
Add configuration to generated project name
maraf Jan 26, 2024
39191f6
Expect relinked files when doing publish in Release
maraf Jan 26, 2024
310f641
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Feb 7, 2024
fa5c5b1
Auto relink only in publish
maraf Feb 7, 2024
550df31
Switch between dotnet run and webserver for hosting Blazor WBT
maraf Feb 7, 2024
f15dc21
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Feb 7, 2024
f5645d6
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Feb 8, 2024
78f5403
Fix using run for build in SatelliteLoadingTests
maraf Feb 8, 2024
2dcf713
Explicitly set debug level to 0 to trigger tiering
maraf Feb 8, 2024
713719f
Explicitly set debug level to 0 to trigger tiering (put debug level i…
maraf Feb 9, 2024
9d27cf4
Be sure not to fail download twice for the same asset
maraf Feb 9, 2024
ec563c0
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Feb 9, 2024
2f8c92b
Don't let missing debugger support override debug level used for logging
maraf Feb 9, 2024
bb28720
Fallback to count of pdbs
maraf Feb 9, 2024
9401db8
Update src/mono/wasi/build/WasiApp.targets
maraf Feb 10, 2024
67c562e
Feedback
maraf Feb 12, 2024
300d782
Feedback
maraf Feb 12, 2024
8e8d100
Fix build
maraf Feb 12, 2024
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
1 change: 1 addition & 0 deletions eng/testing/scenarios/BuildWasmAppsJobsList.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -44,3 +44,4 @@ Wasm.Build.Tests.WasmTemplateTests
Wasm.Build.Tests.WorkloadTests
Wasm.Build.Tests.TestAppScenarios.DownloadResourceProgressTests
Wasm.Build.Tests.MT.Blazor.SimpleMultiThreadedTests
Wasm.Build.Tests.TestAppScenarios.DebugLevelTests
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/cwraps.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -166,7 +166,7 @@ export interface t_Cwraps {
mono_wasm_load_icu_data(offset: VoidPtr): number;
mono_wasm_add_assembly(name: string, data: VoidPtr, size: number): number;
mono_wasm_add_satellite_assembly(name: string, culture: string, data: VoidPtr, size: number): void;
mono_wasm_load_runtime(unused: string, debugLevel: number): void;
mono_wasm_load_runtime(debugLevel: number): void;
mono_wasm_change_debugger_log_level(value: number): void;

mono_wasm_assembly_load(name: string): MonoAssembly;
Expand Down
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/driver.c
Original file line numberDiff line numberDiff line change
Expand Up@@ -181,7 +181,7 @@ cleanup_runtime_config (MonovmRuntimeConfigArguments *args, void *user_data)
}

EMSCRIPTEN_KEEPALIVE void
mono_wasm_load_runtime (const char *unused, int debug_level)
mono_wasm_load_runtime (int debug_level)
{
const char *interp_opts = "";

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

const pdbNameToLoad = changeExtension(dllAsset.name, ".pdb");
const shouldLoadPdb = loaderHelpers.hasDebuggingEnabled(loaderHelpers.config) && Object.prototype.hasOwnProperty.call(lazyAssemblies, pdbNameToLoad);
const shouldLoadPdb = loaderHelpers.config.debugLevel != 0 && loaderHelpers.isDebuggingSupported() && Object.prototype.hasOwnProperty.call(lazyAssemblies, pdbNameToLoad);

const dllBytesPromise = loaderHelpers.retrieve_asset_download(dllAsset);

Expand Down
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/loader/assets.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -266,7 +266,7 @@ export function prepareAssets() {
}
}

if (config.debugLevel != 0 && resources.pdb) {
if (config.debugLevel != 0 && loaderHelpers.isDebuggingSupported() && resources.pdb) {
for (const name in resources.pdb) {
assetsToLoad.push({
name,
Expand Down
12 changes: 2 additions & 10 deletions src/mono/browser/runtime/loader/config.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -197,13 +197,6 @@ export function normalizeConfig() {
config.environmentVariables["MONO_SLEEP_ABORT_LIMIT"] = "5000";
}

// Default values (when WasmDebugLevel is not set)
// - Build (debug) => debugBuild=true & debugLevel=-1 => -1
// - Build (release) => debugBuild=true & debugLevel=0 => 0
// - Publish (debug) => debugBuild=false & debugLevel=-1 => 0
// - Publish (release) => debugBuild=false & debugLevel=0 => 0
config.debugLevel = hasDebuggingEnabled(config) ? config.debugLevel : 0;

if (BuildConfiguration === "Debug" && config.diagnosticTracing === undefined) {
config.diagnosticTracing = true;
}
Expand DownExpand Up@@ -264,14 +257,13 @@ export async function mono_wasm_load_config(module: DotnetModuleInternal): Promi
}
}

export function hasDebuggingEnabled(config: MonoConfigInternal): boolean {
export function isDebuggingSupported(): boolean {
Comment thread
maraf marked this conversation as resolved.
// Copied from blazor MonoDebugger.ts/attachDebuggerHotkey
if (!globalThis.navigator) {
return false;
}

const hasReferencedPdbs = !!config.resources!.pdb;
Comment thread
maraf marked this conversation as resolved.
return (hasReferencedPdbs || config.debugLevel != 0) && (loaderHelpers.isChromium || loaderHelpers.isFirefox);
return loaderHelpers.isChromium || loaderHelpers.isFirefox;
}

async function loadBootConfig(module: DotnetModuleInternal): Promise<void> {
Expand Down
4 changes: 2 additions & 2 deletions src/mono/browser/runtime/loader/globals.ts
Original file line numberDiff line numberDiff 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, hasDebuggingEnabled } 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 DownExpand Up@@ -118,9 +118,9 @@ export function setLoaderGlobals(
purgeUnusedCacheEntriesAsync,
installUnhandledErrorHandler,

hasDebuggingEnabled,
retrieve_asset_download,
invokeLibraryInitializers,
isDebuggingSupported,

// from wasm-feature-detect npm package
exceptions,
Expand Down
10 changes: 7 additions & 3 deletions src/mono/browser/runtime/startup.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -515,7 +515,7 @@ async function start_runtime() {
if (runtimeHelpers.config.browserProfilerOptions)
mono_wasm_init_browser_profiler(runtimeHelpers.config.browserProfilerOptions);

mono_wasm_load_runtime("unused", runtimeHelpers.config.debugLevel);
mono_wasm_load_runtime();

if (runtimeHelpers.config.interpreterPgo)
setTimeout(maybeSaveInterpPgoTable, (runtimeHelpers.config.interpreterPgoSaveDelay || 15) * 1000);
Expand All@@ -534,17 +534,21 @@ async function maybeSaveInterpPgoTable() {
await interp_pgo_save_data();
}

export function mono_wasm_load_runtime(unused?: string, debugLevel?: number): void {
export function mono_wasm_load_runtime(): void {
mono_log_debug("mono_wasm_load_runtime");
try {
const mark = startMeasure();
let debugLevel = runtimeHelpers.config.debugLevel;
if (debugLevel == undefined) {
debugLevel = 0;
if (runtimeHelpers.config.debugLevel) {
debugLevel = 0 + debugLevel;
}
}
cwraps.mono_wasm_load_runtime(unused || "unused", debugLevel);
if (!loaderHelpers.isDebuggingSupported() || !runtimeHelpers.config.resources!.pdb) {
debugLevel = 0;
}
cwraps.mono_wasm_load_runtime(debugLevel);
endMeasure(mark, MeasuredBlock.loadRuntime);

} catch (err: any) {
Expand Down
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/types/internal.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -155,7 +155,6 @@ export type LoaderHelpers = {
out(message: string): void;
err(message: string): void;

hasDebuggingEnabled(config: MonoConfig): boolean,
retrieve_asset_download(asset: AssetEntry): Promise<ArrayBuffer>;
onDownloadResourceProgress?: (resourcesLoaded: number, totalResources: number) => void;
logDownloadStatsToConsole: () => void;
Expand All@@ -166,6 +165,7 @@ export type LoaderHelpers = {
invokeLibraryInitializers: (functionName: string, args: any[]) => Promise<void>,
libraryInitializers?: { scriptName: string, exports: any }[];

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

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -203,9 +203,6 @@ Copyright (c) .NET Foundation. All rights reserved.
<_BlazorWebAssemblyStartupMemoryCache>$(BlazorWebAssemblyStartupMemoryCache)</_BlazorWebAssemblyStartupMemoryCache>
<_BlazorWebAssemblyJiterpreter>$(BlazorWebAssemblyJiterpreter)</_BlazorWebAssemblyJiterpreter>
<_BlazorWebAssemblyRuntimeOptions>$(BlazorWebAssemblyRuntimeOptions)</_BlazorWebAssemblyRuntimeOptions>
<_WasmDebugLevel>$(WasmDebugLevel)</_WasmDebugLevel>
<_WasmDebugLevel Condition="'$(_WasmDebugLevel)' == ''">0</_WasmDebugLevel>
<_WasmDebugLevel Condition="'$(_WasmDebugLevel)' == '0' and ('$(DebuggerSupport)' == 'true' or '$(Configuration)' == 'Debug')">-1</_WasmDebugLevel>

<!-- Workaround for https://github.com/dotnet/sdk/issues/12114-->
<PublishDir Condition="'$(AppendRuntimeIdentifierToOutputPath)' != 'true' AND '$(PublishDir)' == '$(OutputPath)$(RuntimeIdentifier)\$(PublishDirName)\'">$(OutputPath)$(PublishDirName)\</PublishDir>
Expand DownExpand Up@@ -364,7 +361,7 @@ Copyright (c) .NET Foundation. All rights reserved.
AssemblyPath="@(IntermediateAssembly)"
Resources="@(_WasmOutputWithHash)"
DebugBuild="true"
DebugLevel="$(_WasmDebugLevel)"
DebugLevel="$(WasmDebugLevel)"
LinkerEnabled="false"
CacheBootResources="$(BlazorCacheBootResources)"
OutputPath="$(_WasmBuildBootJsonPath)"
Expand All@@ -380,7 +377,8 @@ Copyright (c) .NET Foundation. All rights reserved.
Extensions="@(WasmBootConfigExtension)"
TargetFrameworkVersion="$(TargetFrameworkVersion)"
ModuleAfterConfigLoaded="@(WasmModuleAfterConfigLoaded)"
ModuleAfterRuntimeReady="@(WasmModuleAfterRuntimeReady)" />
ModuleAfterRuntimeReady="@(WasmModuleAfterRuntimeReady)"
IsPublish="false" />

<ItemGroup>
<FileWrites Include="$(_WasmBuildBootJsonPath)" />
Expand DownExpand Up@@ -533,7 +531,6 @@ Copyright (c) .NET Foundation. All rights reserved.
</Target>

<Target Name="GeneratePublishWasmBootJson" DependsOnTargets="$(GeneratePublishWasmBootJsonDependsOn)">

<ItemGroup>
<_WasmPublishAsset
Include="@(StaticWebAsset)"
Expand All@@ -549,7 +546,6 @@ Copyright (c) .NET Foundation. All rights reserved.

<!-- We remove the extensions since they are added to the list of static web assets but we need to compute the target path for them -->
<_WasmPublishAsset Remove="@(_BlazorExtensionsCandidatesForPublish)" />

</ItemGroup>

<ComputeStaticWebAssetsTargetPaths
Expand All@@ -568,7 +564,7 @@ Copyright (c) .NET Foundation. All rights reserved.
AssemblyPath="@(IntermediateAssembly)"
Resources="@(_WasmPublishBootResourceWithHash)"
DebugBuild="false"
DebugLevel="$(_WasmDebugLevel)"
DebugLevel="$(WasmDebugLevel)"
LinkerEnabled="$(PublishTrimmed)"
CacheBootResources="$(BlazorCacheBootResources)"
OutputPath="$(IntermediateOutputPath)blazor.publish.boot.json"
Expand All@@ -584,7 +580,8 @@ Copyright (c) .NET Foundation. All rights reserved.
Extensions="@(WasmBootConfigExtension)"
TargetFrameworkVersion="$(TargetFrameworkVersion)"
ModuleAfterConfigLoaded="@(WasmModuleAfterConfigLoaded)"
ModuleAfterRuntimeReady="@(WasmModuleAfterRuntimeReady)" />
ModuleAfterRuntimeReady="@(WasmModuleAfterRuntimeReady)"
IsPublish="true" />

<ItemGroup>
<FileWrites Include="$(IntermediateOutputPath)blazor.publish.boot.json" />
Expand Down
7 changes: 6 additions & 1 deletion src/mono/wasi/build/WasiApp.targets
Original file line numberDiff line numberDiff line change
Expand Up@@ -66,6 +66,11 @@
Outputs="$(WasmAppDir)\.stamp"
Condition="'$(WasmGenerateAppBundle)' == 'true'">

<PropertyGroup>
<_WasmOutputSymbolsToAppBundle Condition="'$(CopyOutputSymbolsToPublishDirectory)' == 'true' and '$(_IsPublishing)' == 'true'">true</_WasmOutputSymbolsToAppBundle>
<_WasmOutputSymbolsToAppBundle Condition="'$(_WasmOutputSymbolsToAppBundle)' == ''">false</_WasmOutputSymbolsToAppBundle>
</PropertyGroup>

<WasiAppBuilder
AppDir="$(WasmAppDir)"
Assemblies="@(_WasmAssembliesInternal)"
Expand All@@ -80,7 +85,7 @@
FilesToIncludeInFileSystem="@(WasmFilesToIncludeInFileSystem)"
ExtraFilesToDeploy="@(WasmExtraFilesToDeploy)"
NativeAssets="@(WasmNativeAsset)"
DebugLevel="$(WasmDebugLevel)"
OutputSymbolsToAppBundle="$(_WasmOutputSymbolsToAppBundle)"
RuntimeConfigJsonPath="$(_WasmRuntimeConfigFilePath)"
/>
</Target>
Expand Down
6 changes: 6 additions & 0 deletions src/mono/wasm/Wasm.Build.Tests/Blazor/BlazorWasmTestBase.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -63,7 +63,9 @@ public string CreateBlazorWasmTemplateProject(string id)
(CommandResult res, string logPath) = BlazorBuildInternal(options.Id, options.Config, publish: false, setWasmDevel: false, expectSuccess: options.ExpectSuccess, extraArgs);

if (options.ExpectSuccess && options.AssertAppBundle)
{
AssertBundle(res.Output, options with { IsPublish = false });
}

return (res, logPath);
}
Expand All@@ -77,6 +79,10 @@ public string CreateBlazorWasmTemplateProject(string id)

if (options.ExpectSuccess && options.AssertAppBundle)
{
// Because we do relink in Release publish by default
if (options.Config == "Release")
options = options with { ExpectedFileType = NativeFilesType.Relinked };

AssertBundle(res.Output, options with { IsPublish = true });
}

Expand Down
3 changes: 2 additions & 1 deletion src/mono/wasm/Wasm.Build.Tests/Templates/InterpPgoTests.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,7 +34,7 @@ public async Task FirstRunGeneratesTableAndSecondRunLoadsIt(string config)

string id = $"browser_{config}_{GetRandomId()}";
_testOutput.WriteLine("/// Creating project");
string projectFile = CreateWasmTemplateProject(id, "wasmbrowser");
string projectFile = CreateWasmTemplateProject(id, "wasmbrowser", extraProperties: "<WasmDebugLevel>0</WasmDebugLevel>");

_testOutput.WriteLine("/// Updating JS");
UpdateBrowserMainJs((js) => {
Expand All@@ -53,6 +53,7 @@ public async Task FirstRunGeneratesTableAndSecondRunLoadsIt(string config)
// then call INTERNAL.interp_pgo_save_data() to save the interp PGO table
js = js.Replace(
"const text = exports.MyClass.Greeting();",
"console.log(`WASM debug level ${getConfig().debugLevel}`);\n" +
"let text = '';\n" +
$"for (let i = 0; i < {iterationCount}; i++) {{ text = exports.MyClass.Greeting(); }};\n" +
"await INTERNAL.interp_pgo_save_data();"
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,7 +28,7 @@ public async Task LoadAppSettingsBasedOnApplicationEnvironment(string applicatio
CopyTestAsset("WasmBasicTestApp", "AppSettingsTests");
PublishProject("Debug");

var result = await RunSdkStyleApp(new(
var result = await RunSdkStyleAppForPublish(new(
Configuration: "Debug",
TestScenario: "AppSettingsTest",
BrowserQueryString: new Dictionary<string, string> { ["applicationEnvironment"] = applicationEnvironment }
Expand Down
21 changes: 14 additions & 7 deletions src/mono/wasm/Wasm.Build.Tests/TestAppScenarios/AppTestBase.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,23 +36,29 @@ protected void CopyTestAsset(string assetName, string generatedProjectNamePrefix
_projectDir = Path.Combine(_projectDir!, "App");
}

protected void BuildProject(string configuration)
protected void BuildProject(string configuration, params string[] extraArgs)
{
(CommandResult result, _) = BlazorBuild(new BlazorBuildOptions(Id, configuration));
(CommandResult result, _) = BlazorBuild(new BlazorBuildOptions(Id, configuration), extraArgs);
result.EnsureSuccessful();
}

protected void PublishProject(string configuration)
protected void PublishProject(string configuration, params string[] extraArgs)
{
(CommandResult result, _) = BlazorPublish(new BlazorBuildOptions(Id, configuration));
(CommandResult result, _) = BlazorPublish(new BlazorBuildOptions(Id, configuration), extraArgs);
result.EnsureSuccessful();
}

protected ToolCommand CreateDotNetCommand() => new DotNetCommand(s_buildEnv, _testOutput)
.WithWorkingDirectory(_projectDir!)
.WithEnvironmentVariable("NUGET_PACKAGES", _nugetPackagesDir);

protected async Task<RunResult> RunSdkStyleApp(RunOptions options)
protected Task<RunResult> RunSdkStyleAppForBuild(RunOptions options)
=> RunSdkStyleApp(options, BlazorRunHost.DotnetRun);

protected Task<RunResult> RunSdkStyleAppForPublish(RunOptions options)
=> RunSdkStyleApp(options, BlazorRunHost.WebServer);

private async Task<RunResult> RunSdkStyleApp(RunOptions options, BlazorRunHost host = BlazorRunHost.DotnetRun)
{
string queryString = "?test=" + options.TestScenario;
if (options.BrowserQueryString != null)
Expand All@@ -67,9 +73,10 @@ protected async Task<RunResult> RunSdkStyleApp(RunOptions options)
CheckCounter: false,
Config: options.Configuration,
OnConsoleMessage: OnConsoleMessage,
QueryString: queryString);
QueryString: queryString,
Host: host);

await BlazorRunForBuildWithDotnetRun(blazorRunOptions);
await BlazorRunTest(blazorRunOptions);

void OnConsoleMessage(IConsoleMessage msg)
{
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6d25912
Update debug level logic
maraf Jan 19, 2024
64708fe
WBT 1
maraf Jan 19, 2024
7bb059f
Fix build
maraf Jan 19, 2024
89f9dd8
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Jan 24, 2024
9871731
Build project. Register tests
maraf Jan 24, 2024
2639ec8
Remove default to -1 from common props. Use separate build and publis…
maraf Jan 24, 2024
ff8622b
Switching between build and publish for run
maraf Jan 25, 2024
30595a7
More tests
maraf Jan 25, 2024
3affa88
Remove WasmDebugLevel defaults from WasmApp.Common.targets. Create si…
maraf Jan 25, 2024
0ffcdfe
Add configuration to generated project name
maraf Jan 26, 2024
39191f6
Expect relinked files when doing publish in Release
maraf Jan 26, 2024
310f641
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Feb 7, 2024
fa5c5b1
Auto relink only in publish
maraf Feb 7, 2024
550df31
Switch between dotnet run and webserver for hosting Blazor WBT
maraf Feb 7, 2024
f15dc21
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Feb 7, 2024
f5645d6
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Feb 8, 2024
78f5403
Fix using run for build in SatelliteLoadingTests
maraf Feb 8, 2024
2dcf713
Explicitly set debug level to 0 to trigger tiering
maraf Feb 8, 2024
713719f
Explicitly set debug level to 0 to trigger tiering (put debug level i…
maraf Feb 9, 2024
9d27cf4
Be sure not to fail download twice for the same asset
maraf Feb 9, 2024
ec563c0
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Feb 9, 2024
2f8c92b
Don't let missing debugger support override debug level used for logging
maraf Feb 9, 2024
bb28720
Fallback to count of pdbs
maraf Feb 9, 2024
9401db8
Update src/mono/wasi/build/WasiApp.targets
maraf Feb 10, 2024
67c562e
Feedback
maraf Feb 12, 2024
300d782
Feedback
maraf Feb 12, 2024
8e8d100
Fix build
maraf Feb 12, 2024
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
1 change: 1 addition & 0 deletions eng/testing/scenarios/BuildWasmAppsJobsList.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -44,3 +44,4 @@ Wasm.Build.Tests.WasmTemplateTests
Wasm.Build.Tests.WorkloadTests
Wasm.Build.Tests.TestAppScenarios.DownloadResourceProgressTests
Wasm.Build.Tests.MT.Blazor.SimpleMultiThreadedTests
Wasm.Build.Tests.TestAppScenarios.DebugLevelTests
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/cwraps.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -166,7 +166,7 @@ export interface t_Cwraps {
mono_wasm_load_icu_data(offset: VoidPtr): number;
mono_wasm_add_assembly(name: string, data: VoidPtr, size: number): number;
mono_wasm_add_satellite_assembly(name: string, culture: string, data: VoidPtr, size: number): void;
mono_wasm_load_runtime(unused: string, debugLevel: number): void;
mono_wasm_load_runtime(debugLevel: number): void;
mono_wasm_change_debugger_log_level(value: number): void;

mono_wasm_assembly_load(name: string): MonoAssembly;
Expand Down
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/driver.c
Original file line numberDiff line numberDiff line change
Expand Up@@ -181,7 +181,7 @@ cleanup_runtime_config (MonovmRuntimeConfigArguments *args, void *user_data)
}

EMSCRIPTEN_KEEPALIVE void
mono_wasm_load_runtime (const char *unused, int debug_level)
mono_wasm_load_runtime (int debug_level)
{
const char *interp_opts = "";

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

const pdbNameToLoad = changeExtension(dllAsset.name, ".pdb");
const shouldLoadPdb = loaderHelpers.hasDebuggingEnabled(loaderHelpers.config) && Object.prototype.hasOwnProperty.call(lazyAssemblies, pdbNameToLoad);
const shouldLoadPdb = loaderHelpers.config.debugLevel != 0 && loaderHelpers.isDebuggingSupported() && Object.prototype.hasOwnProperty.call(lazyAssemblies, pdbNameToLoad);

const dllBytesPromise = loaderHelpers.retrieve_asset_download(dllAsset);

Expand Down
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/loader/assets.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -266,7 +266,7 @@ export function prepareAssets() {
}
}

if (config.debugLevel != 0 && resources.pdb) {
if (config.debugLevel != 0 && loaderHelpers.isDebuggingSupported() && resources.pdb) {
for (const name in resources.pdb) {
assetsToLoad.push({
name,
Expand Down
12 changes: 2 additions & 10 deletions src/mono/browser/runtime/loader/config.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -197,13 +197,6 @@ export function normalizeConfig() {
config.environmentVariables["MONO_SLEEP_ABORT_LIMIT"] = "5000";
}

// Default values (when WasmDebugLevel is not set)
// - Build (debug) => debugBuild=true & debugLevel=-1 => -1
// - Build (release) => debugBuild=true & debugLevel=0 => 0
// - Publish (debug) => debugBuild=false & debugLevel=-1 => 0
// - Publish (release) => debugBuild=false & debugLevel=0 => 0
config.debugLevel = hasDebuggingEnabled(config) ? config.debugLevel : 0;

if (BuildConfiguration === "Debug" && config.diagnosticTracing === undefined) {
config.diagnosticTracing = true;
}
Expand DownExpand Up@@ -264,14 +257,13 @@ export async function mono_wasm_load_config(module: DotnetModuleInternal): Promi
}
}

export function hasDebuggingEnabled(config: MonoConfigInternal): boolean {
export function isDebuggingSupported(): boolean {
Comment thread
maraf marked this conversation as resolved.
// Copied from blazor MonoDebugger.ts/attachDebuggerHotkey
if (!globalThis.navigator) {
return false;
}

const hasReferencedPdbs = !!config.resources!.pdb;
Comment thread
maraf marked this conversation as resolved.
return (hasReferencedPdbs || config.debugLevel != 0) && (loaderHelpers.isChromium || loaderHelpers.isFirefox);
return loaderHelpers.isChromium || loaderHelpers.isFirefox;
}

async function loadBootConfig(module: DotnetModuleInternal): Promise<void> {
Expand Down
4 changes: 2 additions & 2 deletions src/mono/browser/runtime/loader/globals.ts
Original file line numberDiff line numberDiff 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, hasDebuggingEnabled } 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 DownExpand Up@@ -118,9 +118,9 @@ export function setLoaderGlobals(
purgeUnusedCacheEntriesAsync,
installUnhandledErrorHandler,

hasDebuggingEnabled,
retrieve_asset_download,
invokeLibraryInitializers,
isDebuggingSupported,

// from wasm-feature-detect npm package
exceptions,
Expand Down
10 changes: 7 additions & 3 deletions src/mono/browser/runtime/startup.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -515,7 +515,7 @@ async function start_runtime() {
if (runtimeHelpers.config.browserProfilerOptions)
mono_wasm_init_browser_profiler(runtimeHelpers.config.browserProfilerOptions);

mono_wasm_load_runtime("unused", runtimeHelpers.config.debugLevel);
mono_wasm_load_runtime();

if (runtimeHelpers.config.interpreterPgo)
setTimeout(maybeSaveInterpPgoTable, (runtimeHelpers.config.interpreterPgoSaveDelay || 15) * 1000);
Expand All@@ -534,17 +534,21 @@ async function maybeSaveInterpPgoTable() {
await interp_pgo_save_data();
}

export function mono_wasm_load_runtime(unused?: string, debugLevel?: number): void {
export function mono_wasm_load_runtime(): void {
mono_log_debug("mono_wasm_load_runtime");
try {
const mark = startMeasure();
let debugLevel = runtimeHelpers.config.debugLevel;
if (debugLevel == undefined) {
debugLevel = 0;
if (runtimeHelpers.config.debugLevel) {
debugLevel = 0 + debugLevel;
}
}
cwraps.mono_wasm_load_runtime(unused || "unused", debugLevel);
if (!loaderHelpers.isDebuggingSupported() || !runtimeHelpers.config.resources!.pdb) {
debugLevel = 0;
}
cwraps.mono_wasm_load_runtime(debugLevel);
endMeasure(mark, MeasuredBlock.loadRuntime);

} catch (err: any) {
Expand Down
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/types/internal.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -155,7 +155,6 @@ export type LoaderHelpers = {
out(message: string): void;
err(message: string): void;

hasDebuggingEnabled(config: MonoConfig): boolean,
retrieve_asset_download(asset: AssetEntry): Promise<ArrayBuffer>;
onDownloadResourceProgress?: (resourcesLoaded: number, totalResources: number) => void;
logDownloadStatsToConsole: () => void;
Expand All@@ -166,6 +165,7 @@ export type LoaderHelpers = {
invokeLibraryInitializers: (functionName: string, args: any[]) => Promise<void>,
libraryInitializers?: { scriptName: string, exports: any }[];

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

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -203,9 +203,6 @@ Copyright (c) .NET Foundation. All rights reserved.
<_BlazorWebAssemblyStartupMemoryCache>$(BlazorWebAssemblyStartupMemoryCache)</_BlazorWebAssemblyStartupMemoryCache>
<_BlazorWebAssemblyJiterpreter>$(BlazorWebAssemblyJiterpreter)</_BlazorWebAssemblyJiterpreter>
<_BlazorWebAssemblyRuntimeOptions>$(BlazorWebAssemblyRuntimeOptions)</_BlazorWebAssemblyRuntimeOptions>
<_WasmDebugLevel>$(WasmDebugLevel)</_WasmDebugLevel>
<_WasmDebugLevel Condition="'$(_WasmDebugLevel)' == ''">0</_WasmDebugLevel>
<_WasmDebugLevel Condition="'$(_WasmDebugLevel)' == '0' and ('$(DebuggerSupport)' == 'true' or '$(Configuration)' == 'Debug')">-1</_WasmDebugLevel>

<!-- Workaround for https://github.com/dotnet/sdk/issues/12114-->
<PublishDir Condition="'$(AppendRuntimeIdentifierToOutputPath)' != 'true' AND '$(PublishDir)' == '$(OutputPath)$(RuntimeIdentifier)\$(PublishDirName)\'">$(OutputPath)$(PublishDirName)\</PublishDir>
Expand DownExpand Up@@ -364,7 +361,7 @@ Copyright (c) .NET Foundation. All rights reserved.
AssemblyPath="@(IntermediateAssembly)"
Resources="@(_WasmOutputWithHash)"
DebugBuild="true"
DebugLevel="$(_WasmDebugLevel)"
DebugLevel="$(WasmDebugLevel)"
LinkerEnabled="false"
CacheBootResources="$(BlazorCacheBootResources)"
OutputPath="$(_WasmBuildBootJsonPath)"
Expand All@@ -380,7 +377,8 @@ Copyright (c) .NET Foundation. All rights reserved.
Extensions="@(WasmBootConfigExtension)"
TargetFrameworkVersion="$(TargetFrameworkVersion)"
ModuleAfterConfigLoaded="@(WasmModuleAfterConfigLoaded)"
ModuleAfterRuntimeReady="@(WasmModuleAfterRuntimeReady)" />
ModuleAfterRuntimeReady="@(WasmModuleAfterRuntimeReady)"
IsPublish="false" />

<ItemGroup>
<FileWrites Include="$(_WasmBuildBootJsonPath)" />
Expand DownExpand Up@@ -533,7 +531,6 @@ Copyright (c) .NET Foundation. All rights reserved.
</Target>

<Target Name="GeneratePublishWasmBootJson" DependsOnTargets="$(GeneratePublishWasmBootJsonDependsOn)">

<ItemGroup>
<_WasmPublishAsset
Include="@(StaticWebAsset)"
Expand All@@ -549,7 +546,6 @@ Copyright (c) .NET Foundation. All rights reserved.

<!-- We remove the extensions since they are added to the list of static web assets but we need to compute the target path for them -->
<_WasmPublishAsset Remove="@(_BlazorExtensionsCandidatesForPublish)" />

</ItemGroup>

<ComputeStaticWebAssetsTargetPaths
Expand All@@ -568,7 +564,7 @@ Copyright (c) .NET Foundation. All rights reserved.
AssemblyPath="@(IntermediateAssembly)"
Resources="@(_WasmPublishBootResourceWithHash)"
DebugBuild="false"
DebugLevel="$(_WasmDebugLevel)"
DebugLevel="$(WasmDebugLevel)"
LinkerEnabled="$(PublishTrimmed)"
CacheBootResources="$(BlazorCacheBootResources)"
OutputPath="$(IntermediateOutputPath)blazor.publish.boot.json"
Expand All@@ -584,7 +580,8 @@ Copyright (c) .NET Foundation. All rights reserved.
Extensions="@(WasmBootConfigExtension)"
TargetFrameworkVersion="$(TargetFrameworkVersion)"
ModuleAfterConfigLoaded="@(WasmModuleAfterConfigLoaded)"
ModuleAfterRuntimeReady="@(WasmModuleAfterRuntimeReady)" />
ModuleAfterRuntimeReady="@(WasmModuleAfterRuntimeReady)"
IsPublish="true" />

<ItemGroup>
<FileWrites Include="$(IntermediateOutputPath)blazor.publish.boot.json" />
Expand Down
7 changes: 6 additions & 1 deletion src/mono/wasi/build/WasiApp.targets
Original file line numberDiff line numberDiff line change
Expand Up@@ -66,6 +66,11 @@
Outputs="$(WasmAppDir)\.stamp"
Condition="'$(WasmGenerateAppBundle)' == 'true'">

<PropertyGroup>
<_WasmOutputSymbolsToAppBundle Condition="'$(CopyOutputSymbolsToPublishDirectory)' == 'true' and '$(_IsPublishing)' == 'true'">true</_WasmOutputSymbolsToAppBundle>
<_WasmOutputSymbolsToAppBundle Condition="'$(_WasmOutputSymbolsToAppBundle)' == ''">false</_WasmOutputSymbolsToAppBundle>
</PropertyGroup>

<WasiAppBuilder
AppDir="$(WasmAppDir)"
Assemblies="@(_WasmAssembliesInternal)"
Expand All@@ -80,7 +85,7 @@
FilesToIncludeInFileSystem="@(WasmFilesToIncludeInFileSystem)"
ExtraFilesToDeploy="@(WasmExtraFilesToDeploy)"
NativeAssets="@(WasmNativeAsset)"
DebugLevel="$(WasmDebugLevel)"
OutputSymbolsToAppBundle="$(_WasmOutputSymbolsToAppBundle)"
RuntimeConfigJsonPath="$(_WasmRuntimeConfigFilePath)"
/>
</Target>
Expand Down
6 changes: 6 additions & 0 deletions src/mono/wasm/Wasm.Build.Tests/Blazor/BlazorWasmTestBase.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -63,7 +63,9 @@ public string CreateBlazorWasmTemplateProject(string id)
(CommandResult res, string logPath) = BlazorBuildInternal(options.Id, options.Config, publish: false, setWasmDevel: false, expectSuccess: options.ExpectSuccess, extraArgs);

if (options.ExpectSuccess && options.AssertAppBundle)
{
AssertBundle(res.Output, options with { IsPublish = false });
}

return (res, logPath);
}
Expand All@@ -77,6 +79,10 @@ public string CreateBlazorWasmTemplateProject(string id)

if (options.ExpectSuccess && options.AssertAppBundle)
{
// Because we do relink in Release publish by default
if (options.Config == "Release")
options = options with { ExpectedFileType = NativeFilesType.Relinked };

AssertBundle(res.Output, options with { IsPublish = true });
}

Expand Down
3 changes: 2 additions & 1 deletion src/mono/wasm/Wasm.Build.Tests/Templates/InterpPgoTests.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,7 +34,7 @@ public async Task FirstRunGeneratesTableAndSecondRunLoadsIt(string config)

string id = $"browser_{config}_{GetRandomId()}";
_testOutput.WriteLine("/// Creating project");
string projectFile = CreateWasmTemplateProject(id, "wasmbrowser");
string projectFile = CreateWasmTemplateProject(id, "wasmbrowser", extraProperties: "<WasmDebugLevel>0</WasmDebugLevel>");

_testOutput.WriteLine("/// Updating JS");
UpdateBrowserMainJs((js) => {
Expand All@@ -53,6 +53,7 @@ public async Task FirstRunGeneratesTableAndSecondRunLoadsIt(string config)
// then call INTERNAL.interp_pgo_save_data() to save the interp PGO table
js = js.Replace(
"const text = exports.MyClass.Greeting();",
"console.log(`WASM debug level ${getConfig().debugLevel}`);\n" +
"let text = '';\n" +
$"for (let i = 0; i < {iterationCount}; i++) {{ text = exports.MyClass.Greeting(); }};\n" +
"await INTERNAL.interp_pgo_save_data();"
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,7 +28,7 @@ public async Task LoadAppSettingsBasedOnApplicationEnvironment(string applicatio
CopyTestAsset("WasmBasicTestApp", "AppSettingsTests");
PublishProject("Debug");

var result = await RunSdkStyleApp(new(
var result = await RunSdkStyleAppForPublish(new(
Configuration: "Debug",
TestScenario: "AppSettingsTest",
BrowserQueryString: new Dictionary<string, string> { ["applicationEnvironment"] = applicationEnvironment }
Expand Down
21 changes: 14 additions & 7 deletions src/mono/wasm/Wasm.Build.Tests/TestAppScenarios/AppTestBase.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,23 +36,29 @@ protected void CopyTestAsset(string assetName, string generatedProjectNamePrefix
_projectDir = Path.Combine(_projectDir!, "App");
}

protected void BuildProject(string configuration)
protected void BuildProject(string configuration, params string[] extraArgs)
{
(CommandResult result, _) = BlazorBuild(new BlazorBuildOptions(Id, configuration));
(CommandResult result, _) = BlazorBuild(new BlazorBuildOptions(Id, configuration), extraArgs);
result.EnsureSuccessful();
}

protected void PublishProject(string configuration)
protected void PublishProject(string configuration, params string[] extraArgs)
{
(CommandResult result, _) = BlazorPublish(new BlazorBuildOptions(Id, configuration));
(CommandResult result, _) = BlazorPublish(new BlazorBuildOptions(Id, configuration), extraArgs);
result.EnsureSuccessful();
}

protected ToolCommand CreateDotNetCommand() => new DotNetCommand(s_buildEnv, _testOutput)
.WithWorkingDirectory(_projectDir!)
.WithEnvironmentVariable("NUGET_PACKAGES", _nugetPackagesDir);

protected async Task<RunResult> RunSdkStyleApp(RunOptions options)
protected Task<RunResult> RunSdkStyleAppForBuild(RunOptions options)
=> RunSdkStyleApp(options, BlazorRunHost.DotnetRun);

protected Task<RunResult> RunSdkStyleAppForPublish(RunOptions options)
=> RunSdkStyleApp(options, BlazorRunHost.WebServer);

private async Task<RunResult> RunSdkStyleApp(RunOptions options, BlazorRunHost host = BlazorRunHost.DotnetRun)
{
string queryString = "?test=" + options.TestScenario;
if (options.BrowserQueryString != null)
Expand All@@ -67,9 +73,10 @@ protected async Task<RunResult> RunSdkStyleApp(RunOptions options)
CheckCounter: false,
Config: options.Configuration,
OnConsoleMessage: OnConsoleMessage,
QueryString: queryString);
QueryString: queryString,
Host: host);

await BlazorRunForBuildWithDotnetRun(blazorRunOptions);
await BlazorRunTest(blazorRunOptions);

void OnConsoleMessage(IConsoleMessage msg)
{
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6d25912
Update debug level logic
maraf Jan 19, 2024
64708fe
WBT 1
maraf Jan 19, 2024
7bb059f
Fix build
maraf Jan 19, 2024
89f9dd8
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Jan 24, 2024
9871731
Build project. Register tests
maraf Jan 24, 2024
2639ec8
Remove default to -1 from common props. Use separate build and publis…
maraf Jan 24, 2024
ff8622b
Switching between build and publish for run
maraf Jan 25, 2024
30595a7
More tests
maraf Jan 25, 2024
3affa88
Remove WasmDebugLevel defaults from WasmApp.Common.targets. Create si…
maraf Jan 25, 2024
0ffcdfe
Add configuration to generated project name
maraf Jan 26, 2024
39191f6
Expect relinked files when doing publish in Release
maraf Jan 26, 2024
310f641
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Feb 7, 2024
fa5c5b1
Auto relink only in publish
maraf Feb 7, 2024
550df31
Switch between dotnet run and webserver for hosting Blazor WBT
maraf Feb 7, 2024
f15dc21
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Feb 7, 2024
f5645d6
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Feb 8, 2024
78f5403
Fix using run for build in SatelliteLoadingTests
maraf Feb 8, 2024
2dcf713
Explicitly set debug level to 0 to trigger tiering
maraf Feb 8, 2024
713719f
Explicitly set debug level to 0 to trigger tiering (put debug level i…
maraf Feb 9, 2024
9d27cf4
Be sure not to fail download twice for the same asset
maraf Feb 9, 2024
ec563c0
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Feb 9, 2024
2f8c92b
Don't let missing debugger support override debug level used for logging
maraf Feb 9, 2024
bb28720
Fallback to count of pdbs
maraf Feb 9, 2024
9401db8
Update src/mono/wasi/build/WasiApp.targets
maraf Feb 10, 2024
67c562e
Feedback
maraf Feb 12, 2024
300d782
Feedback
maraf Feb 12, 2024
8e8d100
Fix build
maraf Feb 12, 2024
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
1 change: 1 addition & 0 deletions eng/testing/scenarios/BuildWasmAppsJobsList.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -44,3 +44,4 @@ Wasm.Build.Tests.WasmTemplateTests
Wasm.Build.Tests.WorkloadTests
Wasm.Build.Tests.TestAppScenarios.DownloadResourceProgressTests
Wasm.Build.Tests.MT.Blazor.SimpleMultiThreadedTests
Wasm.Build.Tests.TestAppScenarios.DebugLevelTests
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/cwraps.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -166,7 +166,7 @@ export interface t_Cwraps {
mono_wasm_load_icu_data(offset: VoidPtr): number;
mono_wasm_add_assembly(name: string, data: VoidPtr, size: number): number;
mono_wasm_add_satellite_assembly(name: string, culture: string, data: VoidPtr, size: number): void;
mono_wasm_load_runtime(unused: string, debugLevel: number): void;
mono_wasm_load_runtime(debugLevel: number): void;
mono_wasm_change_debugger_log_level(value: number): void;

mono_wasm_assembly_load(name: string): MonoAssembly;
Expand Down
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/driver.c
Original file line numberDiff line numberDiff line change
Expand Up@@ -181,7 +181,7 @@ cleanup_runtime_config (MonovmRuntimeConfigArguments *args, void *user_data)
}

EMSCRIPTEN_KEEPALIVE void
mono_wasm_load_runtime (const char *unused, int debug_level)
mono_wasm_load_runtime (int debug_level)
{
const char *interp_opts = "";

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

const pdbNameToLoad = changeExtension(dllAsset.name, ".pdb");
const shouldLoadPdb = loaderHelpers.hasDebuggingEnabled(loaderHelpers.config) && Object.prototype.hasOwnProperty.call(lazyAssemblies, pdbNameToLoad);
const shouldLoadPdb = loaderHelpers.config.debugLevel != 0 && loaderHelpers.isDebuggingSupported() && Object.prototype.hasOwnProperty.call(lazyAssemblies, pdbNameToLoad);

const dllBytesPromise = loaderHelpers.retrieve_asset_download(dllAsset);

Expand Down
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/loader/assets.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -266,7 +266,7 @@ export function prepareAssets() {
}
}

if (config.debugLevel != 0 && resources.pdb) {
if (config.debugLevel != 0 && loaderHelpers.isDebuggingSupported() && resources.pdb) {
for (const name in resources.pdb) {
assetsToLoad.push({
name,
Expand Down
12 changes: 2 additions & 10 deletions src/mono/browser/runtime/loader/config.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -197,13 +197,6 @@ export function normalizeConfig() {
config.environmentVariables["MONO_SLEEP_ABORT_LIMIT"] = "5000";
}

// Default values (when WasmDebugLevel is not set)
// - Build (debug) => debugBuild=true & debugLevel=-1 => -1
// - Build (release) => debugBuild=true & debugLevel=0 => 0
// - Publish (debug) => debugBuild=false & debugLevel=-1 => 0
// - Publish (release) => debugBuild=false & debugLevel=0 => 0
config.debugLevel = hasDebuggingEnabled(config) ? config.debugLevel : 0;

if (BuildConfiguration === "Debug" && config.diagnosticTracing === undefined) {
config.diagnosticTracing = true;
}
Expand DownExpand Up@@ -264,14 +257,13 @@ export async function mono_wasm_load_config(module: DotnetModuleInternal): Promi
}
}

export function hasDebuggingEnabled(config: MonoConfigInternal): boolean {
export function isDebuggingSupported(): boolean {
Comment thread
maraf marked this conversation as resolved.
// Copied from blazor MonoDebugger.ts/attachDebuggerHotkey
if (!globalThis.navigator) {
return false;
}

const hasReferencedPdbs = !!config.resources!.pdb;
Comment thread
maraf marked this conversation as resolved.
return (hasReferencedPdbs || config.debugLevel != 0) && (loaderHelpers.isChromium || loaderHelpers.isFirefox);
return loaderHelpers.isChromium || loaderHelpers.isFirefox;
}

async function loadBootConfig(module: DotnetModuleInternal): Promise<void> {
Expand Down
4 changes: 2 additions & 2 deletions src/mono/browser/runtime/loader/globals.ts
Original file line numberDiff line numberDiff 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, hasDebuggingEnabled } 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 DownExpand Up@@ -118,9 +118,9 @@ export function setLoaderGlobals(
purgeUnusedCacheEntriesAsync,
installUnhandledErrorHandler,

hasDebuggingEnabled,
retrieve_asset_download,
invokeLibraryInitializers,
isDebuggingSupported,

// from wasm-feature-detect npm package
exceptions,
Expand Down
10 changes: 7 additions & 3 deletions src/mono/browser/runtime/startup.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -515,7 +515,7 @@ async function start_runtime() {
if (runtimeHelpers.config.browserProfilerOptions)
mono_wasm_init_browser_profiler(runtimeHelpers.config.browserProfilerOptions);

mono_wasm_load_runtime("unused", runtimeHelpers.config.debugLevel);
mono_wasm_load_runtime();

if (runtimeHelpers.config.interpreterPgo)
setTimeout(maybeSaveInterpPgoTable, (runtimeHelpers.config.interpreterPgoSaveDelay || 15) * 1000);
Expand All@@ -534,17 +534,21 @@ async function maybeSaveInterpPgoTable() {
await interp_pgo_save_data();
}

export function mono_wasm_load_runtime(unused?: string, debugLevel?: number): void {
export function mono_wasm_load_runtime(): void {
mono_log_debug("mono_wasm_load_runtime");
try {
const mark = startMeasure();
let debugLevel = runtimeHelpers.config.debugLevel;
if (debugLevel == undefined) {
debugLevel = 0;
if (runtimeHelpers.config.debugLevel) {
debugLevel = 0 + debugLevel;
}
}
cwraps.mono_wasm_load_runtime(unused || "unused", debugLevel);
if (!loaderHelpers.isDebuggingSupported() || !runtimeHelpers.config.resources!.pdb) {
debugLevel = 0;
}
cwraps.mono_wasm_load_runtime(debugLevel);
endMeasure(mark, MeasuredBlock.loadRuntime);

} catch (err: any) {
Expand Down
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/types/internal.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -155,7 +155,6 @@ export type LoaderHelpers = {
out(message: string): void;
err(message: string): void;

hasDebuggingEnabled(config: MonoConfig): boolean,
retrieve_asset_download(asset: AssetEntry): Promise<ArrayBuffer>;
onDownloadResourceProgress?: (resourcesLoaded: number, totalResources: number) => void;
logDownloadStatsToConsole: () => void;
Expand All@@ -166,6 +165,7 @@ export type LoaderHelpers = {
invokeLibraryInitializers: (functionName: string, args: any[]) => Promise<void>,
libraryInitializers?: { scriptName: string, exports: any }[];

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

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -203,9 +203,6 @@ Copyright (c) .NET Foundation. All rights reserved.
<_BlazorWebAssemblyStartupMemoryCache>$(BlazorWebAssemblyStartupMemoryCache)</_BlazorWebAssemblyStartupMemoryCache>
<_BlazorWebAssemblyJiterpreter>$(BlazorWebAssemblyJiterpreter)</_BlazorWebAssemblyJiterpreter>
<_BlazorWebAssemblyRuntimeOptions>$(BlazorWebAssemblyRuntimeOptions)</_BlazorWebAssemblyRuntimeOptions>
<_WasmDebugLevel>$(WasmDebugLevel)</_WasmDebugLevel>
<_WasmDebugLevel Condition="'$(_WasmDebugLevel)' == ''">0</_WasmDebugLevel>
<_WasmDebugLevel Condition="'$(_WasmDebugLevel)' == '0' and ('$(DebuggerSupport)' == 'true' or '$(Configuration)' == 'Debug')">-1</_WasmDebugLevel>

<!-- Workaround for https://github.com/dotnet/sdk/issues/12114-->
<PublishDir Condition="'$(AppendRuntimeIdentifierToOutputPath)' != 'true' AND '$(PublishDir)' == '$(OutputPath)$(RuntimeIdentifier)\$(PublishDirName)\'">$(OutputPath)$(PublishDirName)\</PublishDir>
Expand DownExpand Up@@ -364,7 +361,7 @@ Copyright (c) .NET Foundation. All rights reserved.
AssemblyPath="@(IntermediateAssembly)"
Resources="@(_WasmOutputWithHash)"
DebugBuild="true"
DebugLevel="$(_WasmDebugLevel)"
DebugLevel="$(WasmDebugLevel)"
LinkerEnabled="false"
CacheBootResources="$(BlazorCacheBootResources)"
OutputPath="$(_WasmBuildBootJsonPath)"
Expand All@@ -380,7 +377,8 @@ Copyright (c) .NET Foundation. All rights reserved.
Extensions="@(WasmBootConfigExtension)"
TargetFrameworkVersion="$(TargetFrameworkVersion)"
ModuleAfterConfigLoaded="@(WasmModuleAfterConfigLoaded)"
ModuleAfterRuntimeReady="@(WasmModuleAfterRuntimeReady)" />
ModuleAfterRuntimeReady="@(WasmModuleAfterRuntimeReady)"
IsPublish="false" />

<ItemGroup>
<FileWrites Include="$(_WasmBuildBootJsonPath)" />
Expand DownExpand Up@@ -533,7 +531,6 @@ Copyright (c) .NET Foundation. All rights reserved.
</Target>

<Target Name="GeneratePublishWasmBootJson" DependsOnTargets="$(GeneratePublishWasmBootJsonDependsOn)">

<ItemGroup>
<_WasmPublishAsset
Include="@(StaticWebAsset)"
Expand All@@ -549,7 +546,6 @@ Copyright (c) .NET Foundation. All rights reserved.

<!-- We remove the extensions since they are added to the list of static web assets but we need to compute the target path for them -->
<_WasmPublishAsset Remove="@(_BlazorExtensionsCandidatesForPublish)" />

</ItemGroup>

<ComputeStaticWebAssetsTargetPaths
Expand All@@ -568,7 +564,7 @@ Copyright (c) .NET Foundation. All rights reserved.
AssemblyPath="@(IntermediateAssembly)"
Resources="@(_WasmPublishBootResourceWithHash)"
DebugBuild="false"
DebugLevel="$(_WasmDebugLevel)"
DebugLevel="$(WasmDebugLevel)"
LinkerEnabled="$(PublishTrimmed)"
CacheBootResources="$(BlazorCacheBootResources)"
OutputPath="$(IntermediateOutputPath)blazor.publish.boot.json"
Expand All@@ -584,7 +580,8 @@ Copyright (c) .NET Foundation. All rights reserved.
Extensions="@(WasmBootConfigExtension)"
TargetFrameworkVersion="$(TargetFrameworkVersion)"
ModuleAfterConfigLoaded="@(WasmModuleAfterConfigLoaded)"
ModuleAfterRuntimeReady="@(WasmModuleAfterRuntimeReady)" />
ModuleAfterRuntimeReady="@(WasmModuleAfterRuntimeReady)"
IsPublish="true" />

<ItemGroup>
<FileWrites Include="$(IntermediateOutputPath)blazor.publish.boot.json" />
Expand Down
7 changes: 6 additions & 1 deletion src/mono/wasi/build/WasiApp.targets
Original file line numberDiff line numberDiff line change
Expand Up@@ -66,6 +66,11 @@
Outputs="$(WasmAppDir)\.stamp"
Condition="'$(WasmGenerateAppBundle)' == 'true'">

<PropertyGroup>
<_WasmOutputSymbolsToAppBundle Condition="'$(CopyOutputSymbolsToPublishDirectory)' == 'true' and '$(_IsPublishing)' == 'true'">true</_WasmOutputSymbolsToAppBundle>
<_WasmOutputSymbolsToAppBundle Condition="'$(_WasmOutputSymbolsToAppBundle)' == ''">false</_WasmOutputSymbolsToAppBundle>
</PropertyGroup>

<WasiAppBuilder
AppDir="$(WasmAppDir)"
Assemblies="@(_WasmAssembliesInternal)"
Expand All@@ -80,7 +85,7 @@
FilesToIncludeInFileSystem="@(WasmFilesToIncludeInFileSystem)"
ExtraFilesToDeploy="@(WasmExtraFilesToDeploy)"
NativeAssets="@(WasmNativeAsset)"
DebugLevel="$(WasmDebugLevel)"
OutputSymbolsToAppBundle="$(_WasmOutputSymbolsToAppBundle)"
RuntimeConfigJsonPath="$(_WasmRuntimeConfigFilePath)"
/>
</Target>
Expand Down
6 changes: 6 additions & 0 deletions src/mono/wasm/Wasm.Build.Tests/Blazor/BlazorWasmTestBase.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -63,7 +63,9 @@ public string CreateBlazorWasmTemplateProject(string id)
(CommandResult res, string logPath) = BlazorBuildInternal(options.Id, options.Config, publish: false, setWasmDevel: false, expectSuccess: options.ExpectSuccess, extraArgs);

if (options.ExpectSuccess && options.AssertAppBundle)
{
AssertBundle(res.Output, options with { IsPublish = false });
}

return (res, logPath);
}
Expand All@@ -77,6 +79,10 @@ public string CreateBlazorWasmTemplateProject(string id)

if (options.ExpectSuccess && options.AssertAppBundle)
{
// Because we do relink in Release publish by default
if (options.Config == "Release")
options = options with { ExpectedFileType = NativeFilesType.Relinked };

AssertBundle(res.Output, options with { IsPublish = true });
}

Expand Down
3 changes: 2 additions & 1 deletion src/mono/wasm/Wasm.Build.Tests/Templates/InterpPgoTests.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,7 +34,7 @@ public async Task FirstRunGeneratesTableAndSecondRunLoadsIt(string config)

string id = $"browser_{config}_{GetRandomId()}";
_testOutput.WriteLine("/// Creating project");
string projectFile = CreateWasmTemplateProject(id, "wasmbrowser");
string projectFile = CreateWasmTemplateProject(id, "wasmbrowser", extraProperties: "<WasmDebugLevel>0</WasmDebugLevel>");

_testOutput.WriteLine("/// Updating JS");
UpdateBrowserMainJs((js) => {
Expand All@@ -53,6 +53,7 @@ public async Task FirstRunGeneratesTableAndSecondRunLoadsIt(string config)
// then call INTERNAL.interp_pgo_save_data() to save the interp PGO table
js = js.Replace(
"const text = exports.MyClass.Greeting();",
"console.log(`WASM debug level ${getConfig().debugLevel}`);\n" +
"let text = '';\n" +
$"for (let i = 0; i < {iterationCount}; i++) {{ text = exports.MyClass.Greeting(); }};\n" +
"await INTERNAL.interp_pgo_save_data();"
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,7 +28,7 @@ public async Task LoadAppSettingsBasedOnApplicationEnvironment(string applicatio
CopyTestAsset("WasmBasicTestApp", "AppSettingsTests");
PublishProject("Debug");

var result = await RunSdkStyleApp(new(
var result = await RunSdkStyleAppForPublish(new(
Configuration: "Debug",
TestScenario: "AppSettingsTest",
BrowserQueryString: new Dictionary<string, string> { ["applicationEnvironment"] = applicationEnvironment }
Expand Down
21 changes: 14 additions & 7 deletions src/mono/wasm/Wasm.Build.Tests/TestAppScenarios/AppTestBase.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,23 +36,29 @@ protected void CopyTestAsset(string assetName, string generatedProjectNamePrefix
_projectDir = Path.Combine(_projectDir!, "App");
}

protected void BuildProject(string configuration)
protected void BuildProject(string configuration, params string[] extraArgs)
{
(CommandResult result, _) = BlazorBuild(new BlazorBuildOptions(Id, configuration));
(CommandResult result, _) = BlazorBuild(new BlazorBuildOptions(Id, configuration), extraArgs);
result.EnsureSuccessful();
}

protected void PublishProject(string configuration)
protected void PublishProject(string configuration, params string[] extraArgs)
{
(CommandResult result, _) = BlazorPublish(new BlazorBuildOptions(Id, configuration));
(CommandResult result, _) = BlazorPublish(new BlazorBuildOptions(Id, configuration), extraArgs);
result.EnsureSuccessful();
}

protected ToolCommand CreateDotNetCommand() => new DotNetCommand(s_buildEnv, _testOutput)
.WithWorkingDirectory(_projectDir!)
.WithEnvironmentVariable("NUGET_PACKAGES", _nugetPackagesDir);

protected async Task<RunResult> RunSdkStyleApp(RunOptions options)
protected Task<RunResult> RunSdkStyleAppForBuild(RunOptions options)
=> RunSdkStyleApp(options, BlazorRunHost.DotnetRun);

protected Task<RunResult> RunSdkStyleAppForPublish(RunOptions options)
=> RunSdkStyleApp(options, BlazorRunHost.WebServer);

private async Task<RunResult> RunSdkStyleApp(RunOptions options, BlazorRunHost host = BlazorRunHost.DotnetRun)
{
string queryString = "?test=" + options.TestScenario;
if (options.BrowserQueryString != null)
Expand All@@ -67,9 +73,10 @@ protected async Task<RunResult> RunSdkStyleApp(RunOptions options)
CheckCounter: false,
Config: options.Configuration,
OnConsoleMessage: OnConsoleMessage,
QueryString: queryString);
QueryString: queryString,
Host: host);

await BlazorRunForBuildWithDotnetRun(blazorRunOptions);
await BlazorRunTest(blazorRunOptions);

void OnConsoleMessage(IConsoleMessage msg)
{
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6d25912
Update debug level logic
maraf Jan 19, 2024
64708fe
WBT 1
maraf Jan 19, 2024
7bb059f
Fix build
maraf Jan 19, 2024
89f9dd8
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Jan 24, 2024
9871731
Build project. Register tests
maraf Jan 24, 2024
2639ec8
Remove default to -1 from common props. Use separate build and publis…
maraf Jan 24, 2024
ff8622b
Switching between build and publish for run
maraf Jan 25, 2024
30595a7
More tests
maraf Jan 25, 2024
3affa88
Remove WasmDebugLevel defaults from WasmApp.Common.targets. Create si…
maraf Jan 25, 2024
0ffcdfe
Add configuration to generated project name
maraf Jan 26, 2024
39191f6
Expect relinked files when doing publish in Release
maraf Jan 26, 2024
310f641
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Feb 7, 2024
fa5c5b1
Auto relink only in publish
maraf Feb 7, 2024
550df31
Switch between dotnet run and webserver for hosting Blazor WBT
maraf Feb 7, 2024
f15dc21
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Feb 7, 2024
f5645d6
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Feb 8, 2024
78f5403
Fix using run for build in SatelliteLoadingTests
maraf Feb 8, 2024
2dcf713
Explicitly set debug level to 0 to trigger tiering
maraf Feb 8, 2024
713719f
Explicitly set debug level to 0 to trigger tiering (put debug level i…
maraf Feb 9, 2024
9d27cf4
Be sure not to fail download twice for the same asset
maraf Feb 9, 2024
ec563c0
Merge remote-tracking branch 'upstream/main' into BrowserDebuggerSupport
maraf Feb 9, 2024
2f8c92b
Don't let missing debugger support override debug level used for logging
maraf Feb 9, 2024
bb28720
Fallback to count of pdbs
maraf Feb 9, 2024
9401db8
Update src/mono/wasi/build/WasiApp.targets
maraf Feb 10, 2024
67c562e
Feedback
maraf Feb 12, 2024
300d782
Feedback
maraf Feb 12, 2024
8e8d100
Fix build
maraf Feb 12, 2024
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
1 change: 1 addition & 0 deletions eng/testing/scenarios/BuildWasmAppsJobsList.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -44,3 +44,4 @@ Wasm.Build.Tests.WasmTemplateTests
Wasm.Build.Tests.WorkloadTests
Wasm.Build.Tests.TestAppScenarios.DownloadResourceProgressTests
Wasm.Build.Tests.MT.Blazor.SimpleMultiThreadedTests
Wasm.Build.Tests.TestAppScenarios.DebugLevelTests
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/cwraps.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -166,7 +166,7 @@ export interface t_Cwraps {
mono_wasm_load_icu_data(offset: VoidPtr): number;
mono_wasm_add_assembly(name: string, data: VoidPtr, size: number): number;
mono_wasm_add_satellite_assembly(name: string, culture: string, data: VoidPtr, size: number): void;
mono_wasm_load_runtime(unused: string, debugLevel: number): void;
mono_wasm_load_runtime(debugLevel: number): void;
mono_wasm_change_debugger_log_level(value: number): void;

mono_wasm_assembly_load(name: string): MonoAssembly;
Expand Down
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/driver.c
Original file line numberDiff line numberDiff line change
Expand Up@@ -181,7 +181,7 @@ cleanup_runtime_config (MonovmRuntimeConfigArguments *args, void *user_data)
}

EMSCRIPTEN_KEEPALIVE void
mono_wasm_load_runtime (const char *unused, int debug_level)
mono_wasm_load_runtime (int debug_level)
{
const char *interp_opts = "";

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

const pdbNameToLoad = changeExtension(dllAsset.name, ".pdb");
const shouldLoadPdb = loaderHelpers.hasDebuggingEnabled(loaderHelpers.config) && Object.prototype.hasOwnProperty.call(lazyAssemblies, pdbNameToLoad);
const shouldLoadPdb = loaderHelpers.config.debugLevel != 0 && loaderHelpers.isDebuggingSupported() && Object.prototype.hasOwnProperty.call(lazyAssemblies, pdbNameToLoad);

const dllBytesPromise = loaderHelpers.retrieve_asset_download(dllAsset);

Expand Down
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/loader/assets.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -266,7 +266,7 @@ export function prepareAssets() {
}
}

if (config.debugLevel != 0 && resources.pdb) {
if (config.debugLevel != 0 && loaderHelpers.isDebuggingSupported() && resources.pdb) {
for (const name in resources.pdb) {
assetsToLoad.push({
name,
Expand Down
12 changes: 2 additions & 10 deletions src/mono/browser/runtime/loader/config.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -197,13 +197,6 @@ export function normalizeConfig() {
config.environmentVariables["MONO_SLEEP_ABORT_LIMIT"] = "5000";
}

// Default values (when WasmDebugLevel is not set)
// - Build (debug) => debugBuild=true & debugLevel=-1 => -1
// - Build (release) => debugBuild=true & debugLevel=0 => 0
// - Publish (debug) => debugBuild=false & debugLevel=-1 => 0
// - Publish (release) => debugBuild=false & debugLevel=0 => 0
config.debugLevel = hasDebuggingEnabled(config) ? config.debugLevel : 0;

if (BuildConfiguration === "Debug" && config.diagnosticTracing === undefined) {
config.diagnosticTracing = true;
}
Expand DownExpand Up@@ -264,14 +257,13 @@ export async function mono_wasm_load_config(module: DotnetModuleInternal): Promi
}
}

export function hasDebuggingEnabled(config: MonoConfigInternal): boolean {
export function isDebuggingSupported(): boolean {
Comment thread
maraf marked this conversation as resolved.
// Copied from blazor MonoDebugger.ts/attachDebuggerHotkey
if (!globalThis.navigator) {
return false;
}

const hasReferencedPdbs = !!config.resources!.pdb;
Comment thread
maraf marked this conversation as resolved.
return (hasReferencedPdbs || config.debugLevel != 0) && (loaderHelpers.isChromium || loaderHelpers.isFirefox);
return loaderHelpers.isChromium || loaderHelpers.isFirefox;
}

async function loadBootConfig(module: DotnetModuleInternal): Promise<void> {
Expand Down
4 changes: 2 additions & 2 deletions src/mono/browser/runtime/loader/globals.ts
Original file line numberDiff line numberDiff 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, hasDebuggingEnabled } 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 DownExpand Up@@ -118,9 +118,9 @@ export function setLoaderGlobals(
purgeUnusedCacheEntriesAsync,
installUnhandledErrorHandler,

hasDebuggingEnabled,
retrieve_asset_download,
invokeLibraryInitializers,
isDebuggingSupported,

// from wasm-feature-detect npm package
exceptions,
Expand Down
10 changes: 7 additions & 3 deletions src/mono/browser/runtime/startup.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -515,7 +515,7 @@ async function start_runtime() {
if (runtimeHelpers.config.browserProfilerOptions)
mono_wasm_init_browser_profiler(runtimeHelpers.config.browserProfilerOptions);

mono_wasm_load_runtime("unused", runtimeHelpers.config.debugLevel);
mono_wasm_load_runtime();

if (runtimeHelpers.config.interpreterPgo)
setTimeout(maybeSaveInterpPgoTable, (runtimeHelpers.config.interpreterPgoSaveDelay || 15) * 1000);
Expand All@@ -534,17 +534,21 @@ async function maybeSaveInterpPgoTable() {
await interp_pgo_save_data();
}

export function mono_wasm_load_runtime(unused?: string, debugLevel?: number): void {
export function mono_wasm_load_runtime(): void {
mono_log_debug("mono_wasm_load_runtime");
try {
const mark = startMeasure();
let debugLevel = runtimeHelpers.config.debugLevel;
if (debugLevel == undefined) {
debugLevel = 0;
if (runtimeHelpers.config.debugLevel) {
debugLevel = 0 + debugLevel;
}
}
cwraps.mono_wasm_load_runtime(unused || "unused", debugLevel);
if (!loaderHelpers.isDebuggingSupported() || !runtimeHelpers.config.resources!.pdb) {
debugLevel = 0;
}
cwraps.mono_wasm_load_runtime(debugLevel);
endMeasure(mark, MeasuredBlock.loadRuntime);

} catch (err: any) {
Expand Down
2 changes: 1 addition & 1 deletion src/mono/browser/runtime/types/internal.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -155,7 +155,6 @@ export type LoaderHelpers = {
out(message: string): void;
err(message: string): void;

hasDebuggingEnabled(config: MonoConfig): boolean,
retrieve_asset_download(asset: AssetEntry): Promise<ArrayBuffer>;
onDownloadResourceProgress?: (resourcesLoaded: number, totalResources: number) => void;
logDownloadStatsToConsole: () => void;
Expand All@@ -166,6 +165,7 @@ export type LoaderHelpers = {
invokeLibraryInitializers: (functionName: string, args: any[]) => Promise<void>,
libraryInitializers?: { scriptName: string, exports: any }[];

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

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -203,9 +203,6 @@ Copyright (c) .NET Foundation. All rights reserved.
<_BlazorWebAssemblyStartupMemoryCache>$(BlazorWebAssemblyStartupMemoryCache)</_BlazorWebAssemblyStartupMemoryCache>
<_BlazorWebAssemblyJiterpreter>$(BlazorWebAssemblyJiterpreter)</_BlazorWebAssemblyJiterpreter>
<_BlazorWebAssemblyRuntimeOptions>$(BlazorWebAssemblyRuntimeOptions)</_BlazorWebAssemblyRuntimeOptions>
<_WasmDebugLevel>$(WasmDebugLevel)</_WasmDebugLevel>
<_WasmDebugLevel Condition="'$(_WasmDebugLevel)' == ''">0</_WasmDebugLevel>
<_WasmDebugLevel Condition="'$(_WasmDebugLevel)' == '0' and ('$(DebuggerSupport)' == 'true' or '$(Configuration)' == 'Debug')">-1</_WasmDebugLevel>

<!-- Workaround for https://github.com/dotnet/sdk/issues/12114-->
<PublishDir Condition="'$(AppendRuntimeIdentifierToOutputPath)' != 'true' AND '$(PublishDir)' == '$(OutputPath)$(RuntimeIdentifier)\$(PublishDirName)\'">$(OutputPath)$(PublishDirName)\</PublishDir>
Expand DownExpand Up@@ -364,7 +361,7 @@ Copyright (c) .NET Foundation. All rights reserved.
AssemblyPath="@(IntermediateAssembly)"
Resources="@(_WasmOutputWithHash)"
DebugBuild="true"
DebugLevel="$(_WasmDebugLevel)"
DebugLevel="$(WasmDebugLevel)"
LinkerEnabled="false"
CacheBootResources="$(BlazorCacheBootResources)"
OutputPath="$(_WasmBuildBootJsonPath)"
Expand All@@ -380,7 +377,8 @@ Copyright (c) .NET Foundation. All rights reserved.
Extensions="@(WasmBootConfigExtension)"
TargetFrameworkVersion="$(TargetFrameworkVersion)"
ModuleAfterConfigLoaded="@(WasmModuleAfterConfigLoaded)"
ModuleAfterRuntimeReady="@(WasmModuleAfterRuntimeReady)" />
ModuleAfterRuntimeReady="@(WasmModuleAfterRuntimeReady)"
IsPublish="false" />

<ItemGroup>
<FileWrites Include="$(_WasmBuildBootJsonPath)" />
Expand DownExpand Up@@ -533,7 +531,6 @@ Copyright (c) .NET Foundation. All rights reserved.
</Target>

<Target Name="GeneratePublishWasmBootJson" DependsOnTargets="$(GeneratePublishWasmBootJsonDependsOn)">

<ItemGroup>
<_WasmPublishAsset
Include="@(StaticWebAsset)"
Expand All@@ -549,7 +546,6 @@ Copyright (c) .NET Foundation. All rights reserved.

<!-- We remove the extensions since they are added to the list of static web assets but we need to compute the target path for them -->
<_WasmPublishAsset Remove="@(_BlazorExtensionsCandidatesForPublish)" />

</ItemGroup>

<ComputeStaticWebAssetsTargetPaths
Expand All@@ -568,7 +564,7 @@ Copyright (c) .NET Foundation. All rights reserved.
AssemblyPath="@(IntermediateAssembly)"
Resources="@(_WasmPublishBootResourceWithHash)"
DebugBuild="false"
DebugLevel="$(_WasmDebugLevel)"
DebugLevel="$(WasmDebugLevel)"
LinkerEnabled="$(PublishTrimmed)"
CacheBootResources="$(BlazorCacheBootResources)"
OutputPath="$(IntermediateOutputPath)blazor.publish.boot.json"
Expand All@@ -584,7 +580,8 @@ Copyright (c) .NET Foundation. All rights reserved.
Extensions="@(WasmBootConfigExtension)"
TargetFrameworkVersion="$(TargetFrameworkVersion)"
ModuleAfterConfigLoaded="@(WasmModuleAfterConfigLoaded)"
ModuleAfterRuntimeReady="@(WasmModuleAfterRuntimeReady)" />
ModuleAfterRuntimeReady="@(WasmModuleAfterRuntimeReady)"
IsPublish="true" />

<ItemGroup>
<FileWrites Include="$(IntermediateOutputPath)blazor.publish.boot.json" />
Expand Down
7 changes: 6 additions & 1 deletion src/mono/wasi/build/WasiApp.targets
Original file line numberDiff line numberDiff line change
Expand Up@@ -66,6 +66,11 @@
Outputs="$(WasmAppDir)\.stamp"
Condition="'$(WasmGenerateAppBundle)' == 'true'">

<PropertyGroup>
<_WasmOutputSymbolsToAppBundle Condition="'$(CopyOutputSymbolsToPublishDirectory)' == 'true' and '$(_IsPublishing)' == 'true'">true</_WasmOutputSymbolsToAppBundle>
<_WasmOutputSymbolsToAppBundle Condition="'$(_WasmOutputSymbolsToAppBundle)' == ''">false</_WasmOutputSymbolsToAppBundle>
</PropertyGroup>

<WasiAppBuilder
AppDir="$(WasmAppDir)"
Assemblies="@(_WasmAssembliesInternal)"
Expand All@@ -80,7 +85,7 @@
FilesToIncludeInFileSystem="@(WasmFilesToIncludeInFileSystem)"
ExtraFilesToDeploy="@(WasmExtraFilesToDeploy)"
NativeAssets="@(WasmNativeAsset)"
DebugLevel="$(WasmDebugLevel)"
OutputSymbolsToAppBundle="$(_WasmOutputSymbolsToAppBundle)"
RuntimeConfigJsonPath="$(_WasmRuntimeConfigFilePath)"
/>
</Target>
Expand Down
6 changes: 6 additions & 0 deletions src/mono/wasm/Wasm.Build.Tests/Blazor/BlazorWasmTestBase.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -63,7 +63,9 @@ public string CreateBlazorWasmTemplateProject(string id)
(CommandResult res, string logPath) = BlazorBuildInternal(options.Id, options.Config, publish: false, setWasmDevel: false, expectSuccess: options.ExpectSuccess, extraArgs);

if (options.ExpectSuccess && options.AssertAppBundle)
{
AssertBundle(res.Output, options with { IsPublish = false });
}

return (res, logPath);
}
Expand All@@ -77,6 +79,10 @@ public string CreateBlazorWasmTemplateProject(string id)

if (options.ExpectSuccess && options.AssertAppBundle)
{
// Because we do relink in Release publish by default
if (options.Config == "Release")
options = options with { ExpectedFileType = NativeFilesType.Relinked };

AssertBundle(res.Output, options with { IsPublish = true });
}

Expand Down
3 changes: 2 additions & 1 deletion src/mono/wasm/Wasm.Build.Tests/Templates/InterpPgoTests.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,7 +34,7 @@ public async Task FirstRunGeneratesTableAndSecondRunLoadsIt(string config)

string id = $"browser_{config}_{GetRandomId()}";
_testOutput.WriteLine("/// Creating project");
string projectFile = CreateWasmTemplateProject(id, "wasmbrowser");
string projectFile = CreateWasmTemplateProject(id, "wasmbrowser", extraProperties: "<WasmDebugLevel>0</WasmDebugLevel>");

_testOutput.WriteLine("/// Updating JS");
UpdateBrowserMainJs((js) => {
Expand All@@ -53,6 +53,7 @@ public async Task FirstRunGeneratesTableAndSecondRunLoadsIt(string config)
// then call INTERNAL.interp_pgo_save_data() to save the interp PGO table
js = js.Replace(
"const text = exports.MyClass.Greeting();",
"console.log(`WASM debug level ${getConfig().debugLevel}`);\n" +
"let text = '';\n" +
$"for (let i = 0; i < {iterationCount}; i++) {{ text = exports.MyClass.Greeting(); }};\n" +
"await INTERNAL.interp_pgo_save_data();"
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,7 +28,7 @@ public async Task LoadAppSettingsBasedOnApplicationEnvironment(string applicatio
CopyTestAsset("WasmBasicTestApp", "AppSettingsTests");
PublishProject("Debug");

var result = await RunSdkStyleApp(new(
var result = await RunSdkStyleAppForPublish(new(
Configuration: "Debug",
TestScenario: "AppSettingsTest",
BrowserQueryString: new Dictionary<string, string> { ["applicationEnvironment"] = applicationEnvironment }
Expand Down
21 changes: 14 additions & 7 deletions src/mono/wasm/Wasm.Build.Tests/TestAppScenarios/AppTestBase.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,23 +36,29 @@ protected void CopyTestAsset(string assetName, string generatedProjectNamePrefix
_projectDir = Path.Combine(_projectDir!, "App");
}

protected void BuildProject(string configuration)
protected void BuildProject(string configuration, params string[] extraArgs)
{
(CommandResult result, _) = BlazorBuild(new BlazorBuildOptions(Id, configuration));
(CommandResult result, _) = BlazorBuild(new BlazorBuildOptions(Id, configuration), extraArgs);
result.EnsureSuccessful();
}

protected void PublishProject(string configuration)
protected void PublishProject(string configuration, params string[] extraArgs)
{
(CommandResult result, _) = BlazorPublish(new BlazorBuildOptions(Id, configuration));
(CommandResult result, _) = BlazorPublish(new BlazorBuildOptions(Id, configuration), extraArgs);
result.EnsureSuccessful();
}

protected ToolCommand CreateDotNetCommand() => new DotNetCommand(s_buildEnv, _testOutput)
.WithWorkingDirectory(_projectDir!)
.WithEnvironmentVariable("NUGET_PACKAGES", _nugetPackagesDir);

protected async Task<RunResult> RunSdkStyleApp(RunOptions options)
protected Task<RunResult> RunSdkStyleAppForBuild(RunOptions options)
=> RunSdkStyleApp(options, BlazorRunHost.DotnetRun);

protected Task<RunResult> RunSdkStyleAppForPublish(RunOptions options)
=> RunSdkStyleApp(options, BlazorRunHost.WebServer);

private async Task<RunResult> RunSdkStyleApp(RunOptions options, BlazorRunHost host = BlazorRunHost.DotnetRun)
{
string queryString = "?test=" + options.TestScenario;
if (options.BrowserQueryString != null)
Expand All@@ -67,9 +73,10 @@ protected async Task<RunResult> RunSdkStyleApp(RunOptions options)
CheckCounter: false,
Config: options.Configuration,
OnConsoleMessage: OnConsoleMessage,
QueryString: queryString);
QueryString: queryString,
Host: host);

await BlazorRunForBuildWithDotnetRun(blazorRunOptions);
await BlazorRunTest(blazorRunOptions);

void OnConsoleMessage(IConsoleMessage msg)
{
Expand Down
Loading