Repository navigation
[build] Increase release assembly store compression - #12415
Conversation
Use the maximum Zstandard compression level for optimized builds while retaining level 3 for Debug builds and explicit overrides. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: eb86bd2d-705d-488d-8ffb-919527704b87
There was a problem hiding this comment.
Pull request overview
This PR updates the default Zstandard compression level used for the assembly store in Xamarin.Android builds, increasing compression for optimized (typically Release) builds to reduce APK size while preserving existing defaults and override behavior.
Changes:
- Set
$(_AndroidAssemblyStoreCompressionLevel)default to22when$(Optimize)isTrue. - Keep the existing default of
3for non-optimized builds. - Preserve explicit
$(_AndroidAssemblyStoreCompressionLevel)overrides by only applying defaults when the property is unset.
Show a summary per file
| File | Description |
|---|---|
src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets |
Adjusts the default assembly store compression level based on $(Optimize) to improve APK size for optimized builds. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
Describe the optimized and non-optimized defaults, override behavior, and compression tradeoffs for XA5304. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: eb86bd2d-705d-488d-8ffb-919527704b87
| <AndroidGenerateLayoutBindings Condition=" '$(AndroidGenerateLayoutBindings)' == '' ">False</AndroidGenerateLayoutBindings> | ||
| <AndroidFragmentType Condition=" '$(AndroidFragmentType)' == '' ">Android.App.Fragment</AndroidFragmentType> | ||
| <AndroidEnableAssemblyCompression Condition=" '$(AndroidEnableAssemblyCompression)' == '' ">True</AndroidEnableAssemblyCompression> | ||
| <_AndroidAssemblyStoreCompressionLevel Condition=" '$(_AndroidAssemblyStoreCompressionLevel)' == '' And '$(Optimize)' == 'True' ">22</_AndroidAssemblyStoreCompressionLevel> |
There was a problem hiding this comment.
Is this defined late enough, you can use $(AndroidIncludeDebugSymbols)?
That property is based off several properties: Optimize, DebugSymbols, DebugType.
There was a problem hiding this comment.
It is defined later, so we would need to move this default below the AndroidIncludeDebugSymbols calculation. I think $(Optimize) is the clearer criterion here: changing DebugSymbols or DebugType should not independently change the assembly-store compression level. I am going to keep this tied directly to optimized builds.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 6f5bfadf-177c-4959-8df7-04f2c4ca32d2
Summary
22) for optimized builds3for non-optimized builds$(_AndroidAssemblyStoreCompressionLevel)overridesResults
Measured using an
android-arm64Release build ofdotnet new maui --sample-contenton an Android 16 arm64 emulator.The APK decreased by 1,052,672 bytes (4.67%). The 3 ms startup median difference is measurement noise: the bootstrapped 95% confidence interval for the median difference was -14.5 ms to +20.5 ms.
Testing
make prepare && make all CONFIGURATION=Debug./dotnet-local.sh test bin/TestDebug/net10.0/Xamarin.Android.Build.Tests.dll --filter "Name~BuildAssemblyStoreCompressionLevel"β 3 passed./dotnet-local.sh test bin/TestDebug/net10.0/Xamarin.Android.Build.Tests.dll --filter "Name~BuildReleaseArm64"β 4 CoreCLR cases passed, 4 unsupported NativeAOT cases skipped3explicitly and with the new Release default