Uh oh!
There was an error while loading. Please reload this page.
[Mono.Android] trimmer feature switches for DotNetRuntimeType - #10296
Conversation
| [FeatureSwitchDefinition ($"{FeatureSwitchPrefix}{nameof (IsMonoRuntime)}")] | ||
| internal static bool IsMonoRuntime { get; } = | ||
| AppContext.TryGetSwitch ($"{FeatureSwitchPrefix}{nameof (IsMonoRuntime)}", out bool isEnabled) ? isEnabled : IsMonoRuntimeEnabledByDefault; |
There was a problem hiding this comment.
I wonder if we should enforce that the feature switch is always set explicitly and throw if it isn't. I'm worried that we could introduce a regression and for example we would drop the Microsoft.Android.Runtime.RuntimeFeature.IsMonoRuntime on CoreCLR in the SDK and now both IsMonoRuntime and IsCoreClrRuntime would be true.
There was a problem hiding this comment.
I'll add something that throws on startup if both are set to true.
Uh oh!
There was an error while loading. Please reload this page.
Context: #10198 (comment) `ManagedValueManager` is not currently trimmed away in Android apps running on Mono. We can make this happen by: * Remove `DotNetRuntimeType` enum * Introduce `RuntimeFeature.IsMonoRuntime` and `RuntimeFeature.IsCoreClrRuntime` * Set switches by default for each runtime: <ItemGroup> <RuntimeHostConfigurationOption Include="Microsoft.Android.Runtime.RuntimeFeature.IsMonoRuntime" Value="false" Trim="true" /> <RuntimeHostConfigurationOption Include="Microsoft.Android.Runtime.RuntimeFeature.IsCoreClrRuntime" Value="true" Trim="true" /> </ItemGroup> I have not yet seen a need within the code to introduce `RuntimeFeature.IsNativeAotRuntime`, but we could do so in the future. Currently, NativeAOT works via the other two runtime feature switches being `false` and then none of the problematic code paths are hit.
f615d39 to
d834c56Compare| } | ||
| }, | ||
| "PackageSize": 3148309 | ||
| "PackageSize": 3090965 |
There was a problem hiding this comment.
This looks like it solves the minor app size regression from:
The number we used to have was 3078677, but that could have moved around slightly from other changes.
Context: #10198 (comment)
ManagedValueManageris not currently trimmed away in Android apps running on Mono.We can make this happen by:
Remove
DotNetRuntimeTypeenumIntroduce
RuntimeFeature.IsMonoRuntimeandRuntimeFeature.IsCoreClrRuntimeSet switches by default for each runtime:
I have not yet seen a need within the code to introduce
RuntimeFeature.IsNativeAotRuntime, but we could do so in the future.Currently, NativeAOT works via the other two runtime feature switches being
falseand then none of the problematic code paths are hit.