-
Notifications
You must be signed in to change notification settings - Fork 555
Description
App sizes are currently significantly bigger with .NET 6 with a very simple hello world app.
Test case
- Checkout
xamarin-macios - Execute:
cd tests/dotnet
make compareThis will build a very simple hello world app for both .NET 6 and the old-style Xamarin.iOS and generate a report in markdown format. This can be pasted into the issue (e.g. for each preview) so the progress can be tracked.
Known Issues
- The (dynamic) registrar isn't removed when enabling all the optimizations
- The dynamic registrar requires a larger subset of
System.ReflectionAPI (see below)
- The dynamic registrar requires a larger subset of
- The .NET 6 version does not strip the native executable.
- The mono-cil-strip tool is not run on the final assemblies (it's not available without the mono SDK installed)
- All assemblies still have their IL even when it's not required (FullAOT by default for device builds)
- Tracked, among other tools, in Packaging & redistribution of mdoc.exe & mono-symbolicate in a .NET 6 world? runtime#35852 @marek-safar recently mentioned it was being looked at for Blazor (there might be another issue I missed)
Historical
App sizes
Xamarin.iOS
du -hs size-comparison/MySingleView/oldnet/bin/iPhone/Release/MySingleView.app
4.4M size-comparison/MySingleView/oldnet/bin/iPhone/Release/MySingleView.app
.NET 6
du -hs size-comparison/MySingleView/dotnet/bin/iPhone/Release/net6.0-ios/ios-arm64/*.app
27M size-comparison/MySingleView/dotnet/bin/iPhone/Release/net6.0-ios/ios-arm64/MySingleView.app
Assembly sizes
Xamarin.iOS
ls -lahS size-comparison/MySingleView/oldnet/bin/iPhone/Release/MySingleView.app/.dll size-comparison/MySingleView/oldnet/bin/iPhone/Release/MySingleView.app/.exe
-rw-r--r-- 1 rolf wheel 397K Dec 9 19:04 size-comparison/MySingleView/oldnet/bin/iPhone/Release/MySingleView.app/mscorlib.dll
-rw-r--r-- 1 rolf wheel 54K Dec 9 19:04 size-comparison/MySingleView/oldnet/bin/iPhone/Release/MySingleView.app/Xamarin.iOS.dll
-rw-r--r-- 1 rolf wheel 4.5K Dec 9 19:04 size-comparison/MySingleView/oldnet/bin/iPhone/Release/MySingleView.app/MySingleView.exe
-rw-r--r-- 1 rolf wheel 4.5K Dec 9 19:05 size-comparison/MySingleView/oldnet/bin/iPhone/Release/MySingleView.app/System.dll
.NET 6
ls -lahS size-comparison/MySingleView/dotnet/bin/iPhone/Release/net6.0-ios/ios-arm64/.app/.dll
-rw-r--r-- 1 rolf wheel 1.3M Dec 9 19:05 size-comparison/MySingleView/dotnet/bin/iPhone/Release/net6.0-ios/ios-arm64/MySingleView.app/System.Private.CoreLib.dll
-rw-r--r-- 1 rolf wheel 161K Dec 9 19:05 size-comparison/MySingleView/dotnet/bin/iPhone/Release/net6.0-ios/ios-arm64/MySingleView.app/Xamarin.iOS.dll
-rw-r--r-- 1 rolf wheel 17K Dec 9 19:05 size-comparison/MySingleView/dotnet/bin/iPhone/Release/net6.0-ios/ios-arm64/MySingleView.app/System.Runtime.dll
-rw-r--r-- 1 rolf wheel 16K Dec 9 19:05 size-comparison/MySingleView/dotnet/bin/iPhone/Release/net6.0-ios/ios-arm64/MySingleView.app/System.Runtime.Serialization.Formatters.dll
-rw-r--r-- 1 rolf wheel 5.0K Dec 9 19:05 size-comparison/MySingleView/dotnet/bin/iPhone/Release/net6.0-ios/ios-arm64/MySingleView.app/MySingleView.dll
There are multiple issues here:
-
The .NET 6 version has unnecessary dylibs (because it's linking libraries statically).fix -
The .NET 6 version does not strip the native executable. - The .NET 6 version's assemblies are much bigger (the linker doesn't remove as much): 1,5 MB vs 460 KB.
Additionally the .NET 6 version takes twice as long to compile (22s vs 11s on my machine), but that's a different issue (filed as #10251).