Uh oh!
There was an error while loading. Please reload this page.
[browser][CoreCLR] Trimming feature System.Diagnostics.StackTrace.IsLineNumberSupported - #123429
Conversation
There was a problem hiding this comment.
Pull request overview
This PR optimizes browser/WASM builds by disabling stack trace file information (filename, line number, column number) collection for the TARGET_BROWSER platform. This saves approximately 214KB of uncompressed IL from hello world applications.
Changes:
- Guard file info population code in
StackFrameHelper.InitializeSourceInfowith#if !TARGET_BROWSER - Guard static reentrancy tracking fields used only for file info processing
- Guard file info field assignments in
StackFrameconstructors - Add CA1822 pragma suppression for
InitializeSourceInfo(needed because the method doesn't use instance state on browser)
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/coreclr/System.Private.CoreLib/src/System/Diagnostics/StackFrameHelper.cs | Guards file info processing logic and reentrancy tracking with #if !TARGET_BROWSER, adds CA1822 suppression |
src/coreclr/System.Private.CoreLib/src/System/Diagnostics/StackFrame.CoreCLR.cs | Guards file info field assignments in constructor and BuildStackFrame method with #if !TARGET_BROWSER |
pavelsavara
commented
Jan 21, 2026
We can eventually hide this behind some feature flag. So that in debug build, we would have full fidelity stack trace with line numbers. There is Could the same flag be used here ? @jkotas |
Tagging subscribers to 'size-reduction': @eerhardt, @SamMonoRT, @marek-safar |
Uh oh!
There was an error while loading. Please reload this page.
jkotas
commented
Jan 21, 2026
Is the stack trace line number support unconditionally disabled in Mono Browser today? Trying to understand whether we need extra work to get CoreCLR to parity with Mono Browser.
The existing msbuild property that does the same thing is |
steveisok
commented
Jan 21, 2026
Not 100% sure, but I don't think we do anything special. If runtime/src/mono/mono/metadata/mono-debug.c Line 799 in 46c884e
I was wondering the same thing. And perhaps apply it in https://github.com/dotnet/runtime/blob/5dd95537d5faa20e8baed719e9f5f18d5f29494c/src/libraries/System.Private.CoreLib/src/System/Diagnostics/StackTrace.cs instead of the CoreCLR specific file. |
Mono doesn't use
214KB is 4% of mono wasm hello world download size
Thanks! |
steveisok
commented
Jan 21, 2026
I think from the BCL perspective it's still passing that it wants line numbers into an icall. I suspect we aren't getting them as a byproduct as opposed to doing something explicit for wasm. |
pavelsavara
commented
Jan 21, 2026
runtime/src/mono/mono/mini/mini-exceptions.c Line 1456 in ebae784 runtime/src/mono/mono/metadata/mono-debug.c Lines 789 to 800 in ebae784 |
pavelsavara
commented
Jan 21, 2026
It seems to me that Mono functionality depends on debugger native module being linked in and also on PDB information being available. |
jkotas
commented
Jan 21, 2026
What does it do in debug builds? |
pavelsavara
commented
Jan 21, 2026
|
jkotas
commented
Jan 21, 2026
So this PR will regress debug builds and improve size of release builds. I am not sure whether it is an improvement |
No this PR (in current shape) was conversation opener. If we introduce that |
pavelsavara
commented
Jan 27, 2026
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
pavelsavara
commented
Jan 29, 2026
pavelsavara
commented
Jan 29, 2026
/ba-g CI timeouts |
Uh oh!
There was an error while loading. Please reload this page.


[FeatureSwitchDefinition("System.Diagnostics.StackTrace.IsLineNumberSupported")]<StackTraceLineNumberSupport>false</StackTraceLineNumberSupport>saves 214KB of uncompressed IL from hello world