Skip to content

MAUI iOS sample app size regression compared to .NET7 #79825

Description

@ivanpovazan

Size regression for MAUI iOS apps

MAUI sample app dotnet new maui -n "MyMauiApp" has regressed in size compared to the .NET7 release:

  • Unzipped archive: .app directory size regressed around 78.5% from 40598192 to 72477624 bytes
  • Application archive: .ipa file size regressed around 74% from 13074853 to 22755931 bytes

when compared against dotnet/runtime main branch at: a92c5bc

Linked issues

Similar size regressions have been reported for the Mono sample app and WASM here:

for which the following issues have been detected as the ones causing the regressions:

Repro steps

  1. Check out dotnet/runtime repository into a local dir (<some_repo_dir> will be used as a placeholder further):
git clone https://github.com/dotnet/runtime.git <some_repo_dir>
  1. Build dotnet/runtime for iOS:
cd<some_repo_dir>
./build.sh mono+libs -c Release -os iOS -arch arm64
  1. Download and install dotnet 7.0.100 from https://dotnet.microsoft.com/en-us/download/dotnet/7.0
  2. Make sure 7.0.100 is the one on the path
cd~/
dotnet --version
7.0.100
  1. Install maui workload
sudo dotnet workload install maui --source https://api.nuget.org/v3/index.json
  1. Create a sample MAUI app
dotnet new maui -n "MyMauiApp"cd MyMauiApp
  1. Adjust the app project by adding the following Target in MyMauiApp.csproj file:
<TargetName="UpdateRuntimePackAndAOTCompiler" AfterTargets="ResolveFrameworkReferences"
Condition="'$(UseCurrentMainBranch)' == 'true'" >
<ErrorCondition="'$(DotnetRuntimeRepo)' == ''"Text="You must specify the location of your dotnet/runtime repository via -p:DotnetRuntimeRepo=&lt;some_repo_dir&gt;"/>
<ItemGroup>
<!-- update runtime pack to local build -->
<ResolvedRuntimePackPackageDirectory="$(DotnetRuntimeRepo)/artifacts/bin/microsoft.netcore.app.runtime.ios-arm64/Release"
Condition="'%(ResolvedRuntimePack.FrameworkName)' == 'Microsoft.NETCore.App'" />
<!-- remove AOT compiler reference for ios-arm64 -->
<MonoAotCrossCompilerRemove="@(MonoAotCrossCompiler)"
Condition="%(RuntimeIdentifier) == 'ios-arm64'" />
<!-- update AOT compiler reference to local build -->
<MonoAotCrossCompilerInclude="$(DotnetRuntimeRepo)/artifacts/bin/mono/iOS.arm64.Release/cross/ios-arm64/mono-aot-cross">
<RuntimeIdentifier>ios-arm64</RuntimeIdentifier>
</MonoAotCrossCompiler>
</ItemGroup>
</Target>
  1. Build the project to get sizes for .NET7 release:
dotnet publish -c Release -f net7.0-ios -r ios-arm64 --self-contained -bl -p:_RequireCodeSigning=false
  1. Inspect .ipa file and .app folder sizes:
ls -al bin/Release/net7.0-ios/ios-arm64/publish/MyMauiApp.ipa
ls -al bin/Release/net7.0-ios/ios-arm64/MyMauiApp.app
  1. Now build the project against the locally built runtime - current main from step (2) by:
  • passing the project property DotnetRuntimeRepo with the path to your local dotnet/runtime directory (instead of the <some_repo_dir> placeholder)
  • passing the project property UseCurrentMainBranch with the value true

in the following way:

rm -rf bin obj
dotnet publish -c Release -f net7.0-ios -r ios-arm64 --self-contained -bl -p:_RequireCodeSigning=false -p:DotnetRuntimeRepo="<some_repo_dir>" -p:UseCurrentMainBranch=true
  1. Repeat inspection of the file/folder sizes from step (9)

Size on disk comparison (in bytes)

#File nameSize net7 release (b)Size current main (b)Diff (%)
1AboutAssets.txt6566560,00%
2Assets.car50424504240,00%
3Info.plist142414240,00%
4MauiSplash.storyboardc1601600,00%
5Microsoft.Extensions.Configuration.Abstractions.aotdata.arm649209200,00%
6Microsoft.Extensions.Configuration.Abstractions.dll563256320,00%
7Microsoft.Extensions.Configuration.aotdata.arm6453928179512232,87%
8Microsoft.Extensions.Configuration.dll972897280,00%
9Microsoft.Extensions.DependencyInjection.Abstractions.aotdata.arm6474481785122296,78%
10Microsoft.Extensions.DependencyInjection.Abstractions.dll13312133120,00%
11Microsoft.Extensions.DependencyInjection.aotdata.arm64123976253960104,85%
12Microsoft.Extensions.DependencyInjection.dll25600256000,00%
13Microsoft.Extensions.Logging.Abstractions.aotdata.arm6444640184584313,49%
14Microsoft.Extensions.Logging.Abstractions.dll12800128000,00%
15Microsoft.Extensions.Logging.aotdata.arm6460832188192209,36%
16Microsoft.Extensions.Logging.dll13312133120,00%
17Microsoft.Extensions.Options.aotdata.arm641084010832-0,07%
18Microsoft.Extensions.Options.dll12288122880,00%
19Microsoft.Extensions.Primitives.aotdata.arm6439363920-0,41%
20Microsoft.Extensions.Primitives.dll716871680,00%
21Microsoft.Maui.Controls.Xaml.aotdata.arm6497120243424150,64%
22Microsoft.Maui.Controls.Xaml.dll74240742400,00%
23Microsoft.Maui.Controls.aotdata.arm64914264105606415,51%
24Microsoft.Maui.Controls.dll103833610383360,00%
25Microsoft.Maui.Essentials.aotdata.arm6462792197168214,00%
26Microsoft.Maui.Essentials.dll30720307200,00%
27Microsoft.Maui.Graphics.aotdata.arm64142944308936116,12%
28Microsoft.Maui.Graphics.dll1146881146880,00%
29Microsoft.Maui.aotdata.arm6438481653487238,99%
30Microsoft.Maui.dll3860483860480,00%
31Microsoft.iOS.aotdata.arm6432526446126441,81%
32Microsoft.iOS.dll4976644976640,00%
33MyMauiApp290006885673112095,62%
34MyMauiApp.aotdata.arm6494641818401821,39%
35MyMauiApp.dll18432184320,00%
36OpenSans-Regular.ttf1071841071840,00%
37OpenSans-Semibold.ttf1110681110680,00%
38PkgInfo880,00%
39System.Collections.Concurrent.aotdata.arm6474544207520178,39%
40System.Collections.Concurrent.dll13312133120,00%
41System.Collections.NonGeneric.aotdata.arm64131213120,00%
42System.Collections.NonGeneric.dll716871680,00%
43System.Collections.Specialized.aotdata.arm641392158413,79%
44System.Collections.Specialized.dll819281920,00%
45System.Collections.aotdata.arm64695272083,68%
46System.Collections.dll819281920,00%
47System.ComponentModel.Primitives.aotdata.arm6420961783448408,78%
48System.ComponentModel.Primitives.dll921692160,00%
49System.ComponentModel.TypeConverter.aotdata.arm64165441928961065,96%
50System.ComponentModel.TypeConverter.dll49664496640,00%
51System.ComponentModel.aotdata.arm648568560,00%
52System.ComponentModel.dll460846080,00%
53System.Console.aotdata.arm6446432195856321,81%
54System.Console.dll870487040,00%
55System.Diagnostics.TraceSource.aotdata.arm64241624160,00%
56System.Diagnostics.TraceSource.dll870487040,00%
57System.Drawing.Primitives.aotdata.arm6448561759603523,56%
58System.Drawing.Primitives.dll716871680,00%
59System.Drawing.aotdata.arm648088080,00%
60System.Drawing.dll460846080,00%
61System.Linq.Expressions.aotdata.arm6449924861077622,34%
62System.Linq.Expressions.dll1203201203200,00%
63System.Linq.aotdata.arm64121560275264126,44%
64System.Linq.dll2252822016-2,27%
65System.Memory.aotdata.arm648248240,00%
66System.Memory.dll46084096-11,11%
67System.Net.Http.aotdata.arm64130696311760138,54%
68System.Net.Http.dll61440619520,83%
69System.Net.Primitives.aotdata.arm64142414320,56%
70System.Net.Primitives.dll870487040,00%
71System.Net.Requests.aotdata.arm649289280,00%
72System.Net.Requests.dll563256320,00%
73System.Net.Security.aotdata.arm648888880,00%
74System.Net.Security.dll4608512011,11%
75System.Net.ServicePoint.aotdata.arm64196019600,00%
76System.Net.ServicePoint.dll563256320,00%
77System.Numerics.Vectors.aotdata.arm648168160,00%
78System.Numerics.Vectors.dll460846080,00%
79System.ObjectModel.aotdata.arm6410304111127,84%
80System.ObjectModel.dll13312133120,00%
81System.Private.CoreLib.aotdata.arm641318848177743234,77%
82System.Private.CoreLib.dll9123849344002,41%
83System.Private.Uri.aotdata.arm6481728275344236,90%
84System.Private.Uri.dll25600266244,00%
85System.Private.Xml.aotdata.arm6422921637678464,38%
86System.Private.Xml.dll2472962483200,41%
87System.Runtime.InteropServices.aotdata.arm648408400,00%
88System.Runtime.InteropServices.dll460846080,00%
89System.Runtime.aotdata.arm648088080,00%
90System.Runtime.dll11776117760,00%
91System.Security.Cryptography.aotdata.arm6443000180640320,09%
92System.Security.Cryptography.dll563256320,00%
93System.Text.RegularExpressions.aotdata.arm6452020867773630,28%
94System.Text.RegularExpressions.dll1392641397760,37%
95System.Threading.Thread.aotdata.arm648168160,00%
96System.Threading.Thread.dll4096460812,50%
97System.Threading.aotdata.arm648248240,00%
98System.Threading.dll460846080,00%
99System.Xml.ReaderWriter.aotdata.arm648168160,00%
100System.Xml.ReaderWriter.dll460846080,00%
101System.aotdata.arm648008000,00%
102System.dll409640960,00%
103_CodeSignature96960,00%
104appicon60x60@2x.png136113610,00%
105appicon76x76@2x~ipad.png164916490,00%
106dotnet_bot.png19036190360,00%
107dotnet_bot@2x.png41155411550,00%
108dotnet_bot@3x.png55868558680,00%
109icudt.dat182454418590401,89%
110runtimeconfig.bin9839830,00%
111splash.png155415540,00%
112splash@2x.png275027500,00%
113splash@3x.png477647760,00%
TOTAL:405981927247762478,52%

Observation

Biggest differences can be seen in the app binary MyMauiApp (row 33) and .aotdata.arm64 files.


/cc: @SamMonoRT@kotlarmilos@rolfbjarne@jonathanpeppers@vargaz@stephentoub

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions