-
Notifications
You must be signed in to change notification settings - Fork 515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iOS application size increase when migrating from legacy xamarin-ios to .net #19381
Comments
This is great diagnostics! I had a look at the symbols_SYSIOS.list files, and for all the symbols I checked that were in multiple files (around a dozen), almost all were bigger in .NET 7/8 (slightly smaller in .NET 8 vs .NET 7, but both significantly bigger than legacy Xamarin). Selecting a symbol at random (AVFoundation_AVMediaTypesExtensions_get_AVMediaTypeClosedCaption), it's 124 bytes in legacy Xamarin, 176 bytes in .NET 7 and 172 bytes in .NET 8. While this doesn't seem significant, it'll add up if something similar happens to every symbol (there were a few that had the same size in all versions, but none that I checked were smaller in .NET than legacy Xamarin). Then I checked the AOT-compiled code for this method, and this is what it shows (note that bulid settings might be different from the original reporter, so the actual assembly is likely different). Legacy XamarinSize: 124 bytes
.NET 8Size: 172 bytes
This is the IL (identical between legacy Xamarin and .NET):
@ivanpovazan not sure who would be able to explain this difference in the AOT-compiled size? |
@vargaz could you please take a look at Rolf's comment above? |
Some differences:
|
Most of the code size increase is probably caused by bigger input assemblies, i.e. corlib is probably bigger in net7/8. |
@rotanov thank you for the detailed analysis! As you investigated differences in size of your iOS application, I was wondering if you considered trying out NativeAOT? In .NET8 we released experimental support for targeting iOS platforms with NativeAOT which shows great potential in size savings - reaching 50% smaller apps, but has at the same time much stricter limitations regarding trimming and use of AOT-incompatible code than our MonoAOT offering: https://github.com/xamarin/xamarin-macios/blob/main/docs/nativeaot.md Additionally, the sample code you reported that crashes with MonoAOT |
Hi, I'm working on similar project as original poster and want to highlight that AppExtensions are significantly larger for .Net 8.
so I was not able to check this option. For reference on this image the same .Net 8 | Xamarin appex. |
This is known, we have a tracking issue for app extension improvements we'd like to get done at some point: #10051
We never tried NativeAOT on an app extension, so I filed #20653 to have a look and see if it's possible. |
Just an info: we fixed building app extensions with NativeAOT in 374e902 |
Description
Context: Migrating game engine written in c# from legacy xamarin ios to .NET7.
After the migration, when comparing minimal engine project for ios ("EmptyProject") I noticed non neglectable increase in size of application (.NET7: 13.3MB , .NET8 10.8MB)
I built the project with legacy xamarin ios, net7 and net8 and tried to make some analysis and comparison. See Details section. Attachment contains built applications, debug symbols, MachO symbol dumps, some stats, binlogs, see Attachment section.
I understand there are a lot of issues on the matter and some growth is to be expected.
But 10Mb (for net8) seems like too much, may be I made some mistakes, or there are methods to reduce application size I'm not aware of? (apart from TrimSafe on engine assembly)
Details
Main object of interest is predicted download size, since that is by what appstore limits availability of download over metered connections.
.app
/.ipa
size is not helpful in that regard, because afaik executable gets encrypted by appstore, making it compression-resistant. We predict download size as uncompressed executable size + everything else in ipa/app compressed size.bloaty was used to generate symbols:
bloaty -d segments,sections,symbols,compileunits --debug-file=./bin/Release/EmptyProject.app.dSYM/Contents/Resources/DWARF/EmptyProject ./bin/Release/EmptyProject.app/EmptyProject -n 0 --tsv > symbols.txt
I used slightly modified (included in attachment) script by @ivanpovazan to generate stats. (mentioned here) Generated stats are also in attachment.
Script modifications are:
2.
broke the diff, so diff is disabledEven so, the "OTHERS" section grew a lot.
Stats:
legacy xamarin ios
net7
net8
MachO sections comparison:
Environment
Version information
Attachment
I'm sorry for the attachment format, max upload size is 20MB and there's extension whitelist.
.00x
and.zip
in the name of each filenet-ios-app-size-analysis.001.zip
net-ios-app-size-analysis.002.zip
net-ios-app-size-analysis.003.zip
net-ios-app-size-analysis.004.zip
net-ios-app-size-analysis.005.zip
The text was updated successfully, but these errors were encountered: