Skip to content

[browser] Disable stack trace line numbers by default on publish - #136971

Merged
pavelsavara merged 3 commits into
dotnet:mainfrom
pavelsavara:browser-coreclr-trimmed-closure
Nov 6, 2026
Merged

pavelsavara merged 3 commits into
dotnet:mainfrom
pavelsavara:browser-coreclr-trimmed-closure

Conversation

@pavelsavara

@pavelsavara pavelsavara commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Default StackTraceLineNumberSupport to false for browser publishing, including Debug publish, while preserving development-build defaults and explicit property values.
  • Resolve WebAssembly feature configuration before publish trimming, including dotnet publish --no-build.
  • Guard that early configuration so native-only nested publishes cannot write an incomplete boot manifest and shared completion stamp before the outer publish stages managed assemblies.
  • Add browser regression coverage for build -> publish -> build, default behavior, explicit true/false, and publishing without rebuilding. Document source-location opt-in and symbol publishing.

This is a behavioral change: published CoreCLR managed stack traces keep method names, but source file/line lookup now requires explicit opt-in. The existing property restores the previous behavior:

<PropertyGroup>
  <StackTraceLineNumberSupport>true</StackTraceLineNumberSupport>
  <DebugSymbols>true</DebugSymbols>
  <CopyOutputSymbolsToPublishDirectory>true</CopyOutputSymbolsToPublishDirectory>
</PropertyGroup>

Breaking-change documentation has been prepared as a local draft; the source PR is not merged yet.

Size evidence

Using the source-built WebAssembly SDK pack with the same optimized 12.0.0-alpha.1.26528.120 browser runtime pack, a minimal trimmed Debug Blazor publish gives:

Default publish Explicit line-number opt-in
Linked managed assemblies 4 9
Linked managed bytes 2,373,632 2,614,784
Published *.wasm.gz bytes 2,703,287 2,807,850

The default removes exactly System.Collections.Immutable, System.Diagnostics.StackTrace, System.IO.Compression, System.IO.MemoryMappedFiles and System.Reflection.Metadata from both the linked closure and published WebCIL assets: 241,152 managed bytes and 104,563 gzip bytes saved. The consumed SDK target bytes were verified against the source-built package.

Locally built unoptimized Debug CoreLib can retain unreachable PDB-reader code after feature substitution. Size results above intentionally use an optimized shipping runtime pack; browser behavior tests use the locally built Debug runtime.

Validation

All commands ran from the isolated Windows worktree.

.\build.cmd -bl -os browser -subset clr+libs+host+packs -c Debug /p:RuntimeFlavor=CoreCLR /p:EnableHotReloadInRuntimeConfigDevFile=false

Passed: zero warnings/errors.

.\dotnet.cmd build -bl:artifacts\tmp\trimmed-closure\pack-final.binlog /p:TargetOS=browser /p:TargetArchitecture=wasm /p:RuntimeFlavor=CoreCLR /p:Configuration=Debug /p:EnableHotReloadInRuntimeConfigDevFile=false .\src\mono\nuget\Microsoft.NET.Sdk.WebAssembly.Pack\Microsoft.NET.Sdk.WebAssembly.Pack.pkgproj

Passed: zero warnings/errors.

.\dotnet.cmd build -bl:artifacts\tmp\trimmed-closure\wbt-green-final.binlog /p:TargetOS=browser /p:TargetArchitecture=wasm /p:RuntimeFlavor=CoreCLR /p:Configuration=Debug /p:TestUsingWorkloads=false /p:SdkVersionForWorkloadTesting=12.0.100-alpha.1.26528.120 /p:InstallWorkloadForTesting=false /p:EnableHotReloadInRuntimeConfigDevFile=false /p:InstallChromeForTests=false /p:XUnitClassName=Wasm.Build.Tests.DebugLevelTests /t:Test .\src\mono\wasm\Wasm.Build.Tests\Wasm.Build.Tests.csproj

Passed in Chrome: 6 passed, 0 failed, 0 skipped, including all four new cases and both existing trimmed-PDB cases. The new cases check actual source-line availability and retained method names across build/publish/build. Against the unchanged SDK package, the two new default-publish cases failed because source lines remained enabled; both explicit-override cases passed.

Two additional minimal publishes with the changed SDK package passed exact assertions for the linked and published five-assembly difference above. git diff --check passed.

The complete WBT suite, Mono runtime lane, and interactive managed debugger were not run.

Nested-publish CI follow-up

The early configuration dependency initially ran inside native-only nested publishes.
That generated an incomplete boot manifest before the outer publish staged managed
assemblies, then poisoned its shared incremental completion stamp. A guarded wrapper
now keeps the early dependency in the outer publish only; the original satellite and
reference preparation still runs in both contexts.

The existing workload LazyLoadingTests.FailOnMissingLazyAssembly reproduced
BLAZORSDK1001 with the unguarded package and passed with the guarded source-built
package. Existing coverage therefore catches this regression without adding redundant
tests.

.\dotnet.cmd build -bl:artifacts\tmp\trimmed-closure\nested-guard-pack.binlog /p:TargetOS=browser /p:TargetArchitecture=wasm /p:RuntimeFlavor=CoreCLR /p:Configuration=Debug /p:EnableHotReloadInRuntimeConfigDevFile=false .\src\mono\nuget\Microsoft.NET.Sdk.WebAssembly.Pack\Microsoft.NET.Sdk.WebAssembly.Pack.pkgproj

Passed: zero warnings/errors.

.\dotnet.cmd build -bl:artifacts\tmp\trimmed-closure\nested-existing-green.binlog /p:TargetOS=browser /p:TargetArchitecture=wasm /p:RuntimeFlavor=CoreCLR /p:Configuration=Debug /p:TestUsingWorkloads=true /p:SdkVersionForWorkloadTesting=12.0.100-alpha.1.26528.120 /p:InstallWorkloadForTesting=false /p:EnableHotReloadInRuntimeConfigDevFile=false /p:InstallChromeForTests=false /p:XUnitMethodName=Wasm.Build.Tests.LazyLoadingTests.FailOnMissingLazyAssembly /t:Test .\src\mono\wasm\Wasm.Build.Tests\Wasm.Build.Tests.csproj

Passed in Chrome: 1 passed, 0 failed, 0 skipped.

.\dotnet.cmd build -bl:artifacts\tmp\trimmed-closure\nested-noworkload-confirm.binlog /p:TargetOS=browser /p:TargetArchitecture=wasm /p:RuntimeFlavor=CoreCLR /p:Configuration=Debug /p:TestUsingWorkloads=false /p:SdkVersionForWorkloadTesting=12.0.100-alpha.1.26528.120 /p:InstallWorkloadForTesting=false /p:EnableHotReloadInRuntimeConfigDevFile=false /p:InstallChromeForTests=false /p:XUnitMethodName=Wasm.Build.Tests.DebugLevelTests.StackTraceLineNumbersBuildPublishBuild /t:Test .\src\mono\wasm\Wasm.Build.Tests\Wasm.Build.Tests.csproj

Passed in Chrome: 4 passed, 0 failed, 0 skipped, covering defaults, explicit
true/false, no-build publish, and build/publish/build. An initial run had one
ten-second harness exit-message timeout; that exact published opt-in artifact
independently printed source information, method name and WASM EXIT 0, and the
complete four-case confirmation above passed.

All consumed package targets matched the final source bytes. git diff --check
passed. The complete CI matrix and full Mono test lane have not been rerun locally.

Review follow-up: direct MSBuild publishing

The guarded publish target now applies the line-number default even when publishing
with dotnet msbuild -t:Publish, which does not supply _IsPublishing. Explicit
property values remain honored. The managed probe is now a standard
StackTraceTest scenario in WasmBasicTestApp, uses TestOutput.WriteLine, and the
theory uses the coreclr test category.

The expanded theory covers CLI and direct-MSBuild publishing, no-build publishing,
explicit true/false, and build/publish/build. Against the preceding package, both
direct-MSBuild default cases failed because source lines remained enabled; the
other six cases passed.

The source-built SDK package passed with zero warnings/errors:

.\dotnet.cmd build -bl:artifacts\tmp\trimmed-closure\review-pack.binlog /p:TargetOS=browser /p:TargetArchitecture=wasm /p:RuntimeFlavor=CoreCLR /p:Configuration=Debug /p:EnableHotReloadInRuntimeConfigDevFile=false .\src\mono\nuget\Microsoft.NET.Sdk.WebAssembly.Pack\Microsoft.NET.Sdk.WebAssembly.Pack.pkgproj

Final browser validation:

.\dotnet.cmd build -bl:artifacts\tmp\trimmed-closure\review-green.binlog /p:TargetOS=browser /p:TargetArchitecture=wasm /p:RuntimeFlavor=CoreCLR /p:Configuration=Debug /p:TestUsingWorkloads=false /p:SdkVersionForWorkloadTesting=12.0.100-alpha.1.26528.120 /p:InstallWorkloadForTesting=false /p:EnableHotReloadInRuntimeConfigDevFile=false /p:InstallChromeForTests=false /p:XUnitMethodName=Wasm.Build.Tests.DebugLevelTests.StackTraceLineNumbersBuildPublishBuild /t:Test .\src\mono\wasm\Wasm.Build.Tests\Wasm.Build.Tests.csproj

Passed in Chrome: 8 passed, 0 failed, 0 skipped.

.\dotnet.cmd build -bl:artifacts\tmp\trimmed-closure\review-nested-green.binlog /p:TargetOS=browser /p:TargetArchitecture=wasm /p:RuntimeFlavor=CoreCLR /p:Configuration=Debug /p:TestUsingWorkloads=true /p:SdkVersionForWorkloadTesting=12.0.100-alpha.1.26528.120 /p:InstallWorkloadForTesting=false /p:EnableHotReloadInRuntimeConfigDevFile=false /p:InstallChromeForTests=false /p:XUnitMethodName=Wasm.Build.Tests.LazyLoadingTests.FailOnMissingLazyAssembly /t:Test .\src\mono\wasm\Wasm.Build.Tests\Wasm.Build.Tests.csproj

Passed in Chrome: 1 passed, 0 failed, 0 skipped. Packaged target bytes match the
source; git diff --check passed.

Resolves #135222

Note

This PR was generated with assistance from GitHub Copilot.

Preserve development-build defaults and explicit source-location opt-in.
Resolve runtime feature configuration before trimming no-build publishes,
and verify build-publish-build behavior with browser regression tests.

Co-authored-by: Copilot <[email protected]>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 4 pipeline(s).
11 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@pavelsavara pavelsavara added arch-wasm WebAssembly architecture os-browser Browser variant of arch-wasm labels Nov 4, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag
See info in area-owners.md if you want to be subscribed.

Resolve WebAssembly configuration before trimming only in the outer publish.
Initializing it in native-only nested publishes generates an incomplete boot
manifest and completion stamp before the managed assemblies are staged.

Co-authored-by: Copilot <[email protected]>
@pavelsavara pavelsavara added this to the 12.0.0 milestone Nov 6, 2026
@pavelsavara
pavelsavara marked this pull request as ready for review November 6, 2026 09:30
Set the default in the guarded publish target when the CLI publishing flag
is absent. Cover direct MSBuild publishing and move the stack trace probe
into the shared test app with its standard output helper and runtime category.

Co-authored-by: Copilot <[email protected]>
@pavelsavara

Copy link
Copy Markdown
Member Author

/ba-g known windows infra

@pavelsavara
pavelsavara merged commit a4106c7 into dotnet:main Nov 6, 2026
48 of 50 checks passed
@pavelsavara
pavelsavara deleted the browser-coreclr-trimmed-closure branch November 6, 2026 17:28
maraf added a commit that referenced this pull request Nov 25, 2026
<!-- -->

## Summary

Add focused WebAssembly review guidance based on recurring PR feedback,
without expanding global repository instructions.

- Put the general guide in the runtime-neutral
`docs/workflow/wasm-review.md`, covering SDK/workload/in-tree ownership,
configuration consumers, native build bridges, incremental outputs and
Static Web Assets.
- Extend the Wasm.Build.Tests README with scenario/output-helper reuse,
category selection, scoped binlog observations and coverage guidance.
- Add a Wasm-scoped instruction router and link the guide from the
existing Wasm documentation index.

Documentation only; no product code, test implementation or public API
changes.

## Independent historical-review validation

Four fresh sessions reviewed two merged PRs: one baseline and one
new-guidance reviewer per PR. Each reviewed the exact source head
attached to the original feedback, not the final merged code. Original
comments, expected findings and counterpart results were withheld from
reviewers; their first-pass responses were saved and hashed before
comparison.

| PR | Frozen pre-feedback head | Baseline agreement | New-guidance
agreement |
| --- | --- | --- | --- |
| [#136971](#136971) |
`1e6c03358c1575baaf29538bf630ab0647a16beb` | 1.5/4 | 4/4 |
| [#136772](#136772) |
`d9f1d954190aa89869e920bbf7b98f9324862240` | 0/3 | 2/3 |
| **Total** | | **1.5/7** | **6/7** |

Scoring criteria were fixed before launch: 1 for a specific actionable
equivalent to the original feedback, 0.5 for an incomplete equivalent,
and 0 for absent or generic advice. These measure feedback agreement,
not production-defect counts. Original feedback was published by the
reviewer's account; some comments explicitly disclose Copilot
assistance.

| Feedback criterion | Baseline | New guidance |
| --- | --- | --- |
| Direct MSBuild Publish default and coverage | 0 | 1 |
| Proper shared testasset/scenario | 0.5 | 1 |
| Standard test-output helper | 0 | 1 |
| CoreCLR runtime category | 1 | 1 |
| Synchronize the equivalent SDK workload-manifest condition | 0 | 0 |
| Share the literal CMake feature baseline | 0 | 1 |
| Respect the separate Mono CMake bridge and runtime-specific policy | 0
| 1 |

The baseline asset recommendation moved the program into a replacement
fixture; the guided recommendation used a shared application scenario,
matching the original follow-up more closely. Both arms missed the SDK
manifest synchronization. The relevant equivalent SDK gate was
subsequently verified in version-pinned source, not by executing the
historical SDK.

Both native reviews also found the supported DLL-named R2R output being
excluded by an extension filter and incomplete all-image stamp
assertions; these common findings are not credited as guidance uplift.
Guided output was not a strict superset: baseline-only advice included
preserving the first build's binlog and adding independent
alignment-rewriter regression tests.

### Limitations

This is a small retrospective comparison on two cases used to derive the
guidance, not a held-out, randomized or causal demonstration of general
improvement. The coordinator knew the treatment arms; inherited
instructions, temporally newer contributor docs, skill availability and
probe use were not fully controlled. Reviewers explicitly consumed the
new Markdown content, so automatic instruction-router activation was not
tested. No full historical SDK/browser/toolchain scenario was
reproduced, and no zero-false-positive rate is claimed.

## Validation

- `git diff --check` — passed.
- `npm exec --yes --package markdownlint-cli -- markdownlint
.github/instructions/wasm.instructions.md docs/workflow/wasm-review.md
src/mono/wasm/Wasm.Build.Tests/README.md
docs/workflow/wasm-documentation.md` — passed with repository
configuration.
- Session-local documentation validator — passed 18 relative link/anchor
checks, 14 existing positive and 8 negative routing examples,
frontmatter, final newlines and trailing whitespace. This checks the
explicit globs, not live Copilot routing.
- Runtime builds/browser tests were not run for these Markdown-only
changes. One baseline historical reviewer ran isolated MSBuild selection
and synthetic alignment probes using a newer host SDK; those are not
full historical-toolchain validation.

> [!NOTE]
> This PR description was generated with the assistance of GitHub
Copilot.

---------

Co-authored-by: Copilot App <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-wasm WebAssembly architecture area-Diagnostics-coreclr os-browser Browser variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[browser][coreclr] Investigate five additional assemblies retained in trimmed Blazor WebAssembly publishes

2 participants