In a default Maui Android app, I see the following assemblies present in my Release .apk:

The first thing that caught my eye was that System.Net.Quic.dll is there. But on Mobile apps, we are using UseNativeHttpHandler=true, see this Android SDK setting.
Since we are using the native HTTP handler, there should be no reason we are bringing .NET sockets handler (and with it HTTP 2 & 3 support).
The reason this code isn't getting trimmed is because we only have a Linker substitution for when false is specified.
|
<linker> |
|
<assembly fullname="System.Net.Http"> |
|
<type fullname="System.Net.Http.HttpClientHandler"> |
|
<method signature="System.Boolean get_IsNativeHandlerEnabled()" body="stub" value="false" feature="System.Net.Http.UseNativeHttpHandler" featurevalue="false" /> |
|
</type> |
|
</assembly> |
|
</linker> |
We should add a substitution entry for true as well. This way a bunch of System.Net.* IL can be trimmed from mobile apps by default.
cc @steveisok @jonathanpeppers
In a default Maui Android app, I see the following assemblies present in my Release .apk:
The first thing that caught my eye was that
System.Net.Quic.dllis there. But on Mobile apps, we are usingUseNativeHttpHandler=true, see this Android SDK setting.Since we are using the native HTTP handler, there should be no reason we are bringing .NET sockets handler (and with it HTTP 2 & 3 support).
The reason this code isn't getting trimmed is because we only have a Linker substitution for when
falseis specified.runtime/src/libraries/System.Net.Http/src/ILLink/ILLink.Substitutions.mobile.xml
Lines 1 to 7 in c0d481f
We should add a substitution entry for
trueas well. This way a bunch of System.Net.* IL can be trimmed from mobile apps by default.cc @steveisok @jonathanpeppers