Open-XML-SDK icon indicating copy to clipboard operation
Open-XML-SDK copied to clipboard

AOT in Xamarin results in very large DLL in v2.11.1+

Open tipa opened this issue 5 years ago • 3 comments

Description

I am using this SDK in a Xamarin.Android project. Starting with 2.11.1, the DocumentFormat.OpenXml.dll in my release bundle grew from ~6MB to over 20MB, causing the apps download size to grow about 3MB

Information

  • .NET Target: Xamarin
  • DocumentFormat.OpenXml Version: 2.11.1 + 2.11.2

Repro

Xamarin.Android project with AOT+LLVM enabled Example project: App2.zip You can reproduce the problem by building the Release APK with v2.11.0 and with v2.11.2 - you will notice that with v2.11.0, the uncompressed DocumentFormat.OpenXml.dll in the APK (which can be renamed to .zip and inspected) is ~15MB and with v2.11.2 it is over 30MB.

This libraries DLL is already by far the largest of all the libraries that I am using in this project. It would be great if it wouldn't further increase my apps size :)

tipa avatar Jul 13 '20 09:07 tipa

We have a work item to break things up into smaller pay-for-play assemblies (ie if you're using Word, then you'll only need the Word dll). However, it's pretty tricky to do so.

Other than that, it would be nice to understand what is causing the growth. I imagine it's some of the generic-related things (I remember hearing EF Core had issues with size explosion during AOT due to that). Maybe other things. It would be great to identify all the causes as some may be able to be addressed earlier than breaking up the assembly.

twsouthwick avatar Jul 13 '20 15:07 twsouthwick

Ah - I just saw that with 2.11.0 it was half the size. One of the change (which appears I forgot to document) between the two is removing some of the reflection code and using generics. It's a work in progress, but very likely to be related.

I don't have much experience with Xamarin and probably won't have any time to explore for a while. If anyone is able to explore what is causing that in more depth and any way to mitigate it would be awesome.

twsouthwick avatar Jul 13 '20 23:07 twsouthwick

@tipa I test the two version and I find that the 2.11.1 version has more generics type use which will AOT to more size. But I do not know more info. Waiting for the more info.

lindexi avatar Jun 16 '21 01:06 lindexi