Skip to content

Commit

Permalink
[One .NET] Do not preserve IO stream adapter/invoker (#5449)
Browse files Browse the repository at this point in the history
Context: #5167
Context: #5206

The following types are accessed through the `CallbackCode` type
in `src/Mono.Android.Export` via System.Reflection:

  * `Android.Runtime.InputStreamAdapter`
  * `Android.Runtime.InputStreamInvoker`
  * `Android.Runtime.OutputStreamAdapter`
  * `Android.Runtime.OutputStreamInvoker`

Historically the use of these types via Reflection required that they
always be preserved, just in case `Mono.Android.Export.dll` was used.

.NET 6 ILLink is able to detect such reflection use.  These types no
longer need to be explicitly preserved in all circumstances.

Stop explicitly preserving these types, and rely on ILLink to
preserve them when `Mono.Android.Export.dll` is used.

This change reduces the `.apk` size in a common situation, when
`Mono.Android.Export.dll` is not used.

apk size comparison, BuildReleaseArm64False test:

	> apkdiff -f -e dll$ before.apk after.apk
	Size difference in bytes ([*1] apk1 only, [*2] apk2 only):
	  -          80 assemblies/System.Console.dll
	  -         129 assemblies/Java.Interop.dll
	  -       1,237 assemblies/System.Private.CoreLib.dll
	  -       6,093 assemblies/Mono.Android.dll
	Summary:
	  -       7,539 Assemblies -1.01% (of 749,078)
  • Loading branch information
radekdoulik authored Jan 4, 2021
1 parent 9a66530 commit 051cad7
Showing 1 changed file with 0 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
<type fullname="Android.Runtime.GeneratedDummyHost" />
<type fullname="Android.Runtime.GeneratedEnumAttribute" />
<type fullname="Android.Runtime.IJavaObject" />
<type fullname="Android.Runtime.InputStreamAdapter" />
<type fullname="Android.Runtime.InputStreamInvoker" />
<type fullname="Android.Runtime.JNIEnv">
<method name="Exit" />
<method name="Initialize" />
Expand Down Expand Up @@ -34,8 +32,6 @@
<type fullname="Android.Runtime.LogLevel" />
<type fullname="Android.Runtime.LogCategories" />
<type fullname="Android.Runtime.NamespaceMappingAttribute" />
<type fullname="Android.Runtime.OutputStreamAdapter" />
<type fullname="Android.Runtime.OutputStreamInvoker" />
<type fullname="Android.Runtime.PreserveAttribute" />
<type fullname="Android.Runtime.RaiseThrowableEventArgs" />
<type fullname="Android.Runtime.RegisterAttribute" />
Expand Down

0 comments on commit 051cad7

Please sign in to comment.