Repository navigation
[CoreCLR] Exclude diagnostic libraries from release APKs - #11245
Conversation
9801060 to
76bd0c0
Compare
CoreCLR Android runtime packs include libmscordbi.so and libmscordaccore.so for debugging/diagnostics, but normal Release app startup does not load them. Exclude these diagnostic native libraries from CoreCLR APK packaging when debug symbols are not requested. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
76bd0c0 to
f66d081
Compare
There was a problem hiding this comment.
Pull request overview
This PR reduces CoreCLR Release APK size by excluding the CoreCLR diagnostic sidecar native libraries (DAC/DBI) from APK packaging when debugger support is disabled, and updates the corresponding APK descriptor baselines used by size-regression tests.
Changes:
- Exclude
libmscordaccore.soandlibmscordbi.sofrom CoreCLR native library processing whenDebuggerSupport=false. - Update CoreCLR Release arm64
.apkdescbaselines to remove the two entries and reflect reducedPackageSize.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.AssemblyResolution.targets | Adds conditional exclusions for DAC/DBI native libraries in CoreCLR when DebuggerSupport is disabled. |
| src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/BuildReleaseArm64SimpleDotNet.CoreCLR.apkdesc | Updates Release arm64 baseline descriptor to remove DAC/DBI entries and adjust PackageSize. |
| src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/BuildReleaseArm64XFormsDotNet.CoreCLR.apkdesc | Updates Release arm64 baseline descriptor to remove DAC/DBI entries and adjust PackageSize. |
| <_ExcludedNativeLibraries Condition=" '$(_AndroidRuntime)' == 'CoreCLR' And '$(DebuggerSupport)' == 'false' " Include="libmscordaccore" /> | ||
| <_ExcludedNativeLibraries Condition=" '$(_AndroidRuntime)' == 'CoreCLR' And '$(DebuggerSupport)' == 'false' " Include="libmscordbi" /> |
| <_ExcludedNativeLibraries Condition=" '$(_AndroidRuntime)' == 'CoreCLR' And '$(DebuggerSupport)' == 'false' " Include="libmscordaccore" /> | ||
| <_ExcludedNativeLibraries Condition=" '$(_AndroidRuntime)' == 'CoreCLR' And '$(DebuggerSupport)' == 'false' " Include="libmscordbi" /> |
There was a problem hiding this comment.
@copilot let's switch the conditions to '$(AndroidIncludeDebugSymbols)' == 'true' for consisntecy
There was a problem hiding this comment.
Done in 3381cc7. Switched both conditions from '$(DebuggerSupport)' == 'false' to '$(AndroidIncludeDebugSymbols)' != 'true', consistent with how line 288 gates the Mono debugger component.
…Symbols Agent-Logs-Url: https://github.com/dotnet/android/sessions/1959d28f-d2ee-4a8e-ac8f-e041b95f1bfa Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Summary
libmscordaccore.soandlibmscordbi.so, includingPackageSizereductionsAPK descriptor size impact
BuildReleaseArm64SimpleDotNet.CoreCLR.apkdesc9,238,2984,874,730-4,363,568BuildReleaseArm64XFormsDotNet.CoreCLR.apkdesc22,873,01918,509,451-4,363,568The
PackageSizedelta is exactly the raw size of the two removed APK entries:lib/arm64-v8a/libmscordaccore.so2,463,848lib/arm64-v8a/libmscordbi.so1,899,7204,363,568Local
dotnet new mauiAPK size impactLocal Release publish of a blank
dotnet new mauiapp for.apk (android-arm64):22,039,645+2,882,672(+15.0%)20,433,861+1,276,888(+6.7%)-1,605,784(-7.3%)19,156,973This saves about 1.53 MiB compressed in the CoreCLR APK and reduces the blank-app CoreCLR-vs-Mono gap from about 2.75 MiB to about 1.22 MiB.
Notes
libmscordbi.soandlibmscordaccore.soare present in the CoreCLR runtime pack as native assets, so the Android packaging pipeline currently treats them as framework native libraries and includes them in APKs. Normal Android CoreCLR app startup does not load these libraries; they are debugger/diagnostic sidecars.The exclusion is gated on
DebuggerSupport == false. Android defaultsDebuggerSupport=falsefor optimized Release apps, while Debug builds can leave the property unset; using an explicitfalsecheck avoids treating an unset Debug value as disabled. Projects that setDebuggerSupport=truecontinue to package these libraries.Local investigation with a blank MAUI CoreCLR R2R app showed that removing both libraries reduced the APK by about 1.5 MiB compressed and the app still installed and cold-launched successfully on an Android device.
Additional local validation with a project-level target matching this PR showed:
DebuggerSupport: DAC/DBI remain packagedDebuggerSupport=false: DAC/DBI are removedDebuggerSupport=true: DAC/DBI remain packagedValidation
git diff --check.apkdescfiles withjq emptyDebuggerSupport=truemake prepare