Repository navigation
[Mono.Android] Default to SocketsHttpHandler in .NET 12 - #13013
Conversation
Use the shared sockets HTTP implementation by default instead of the Android-specific handler. Preserve explicit UseNativeHttpHandler values and mark AndroidMessageHandler obsolete with migration guidance. Document the new default and suppress obsolete warnings in tests that intentionally exercise the legacy handler. Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The user-visible default change appears coherent, but compilation and on-device validation remain blocked by dependency restore failure.
Review effort: Balanced
Findings: None
What changed in this PR
Changes the .NET 12 Android HTTP default to SocketsHttpHandler while retaining explicit native-handler opt-in.
Changes:
- Defaults
UseNativeHttpHandlertofalse. - Marks
AndroidMessageHandlerobsolete and documents migration. - Suppresses expected obsolete warnings in legacy-handler tests.
| File | Description |
|---|---|
Microsoft.Android.Sdk.DefaultProperties.targets |
Changes the default HTTP handler. |
AndroidMessageHandler.cs |
Adds the obsolescence warning. |
build-properties.md |
Documents the property and .NET 12 behavior. |
AndroidMessageHandlerTests.cs |
Suppresses intentional obsolete usage. |
AndroidMessageHandlerNegotiateAuthenticationTests.cs |
Suppresses intentional obsolete usage. |
AndroidMessageHandlerIntegrationTests.cs |
Suppresses intentional obsolete usage. |
AndroidMessageHandlerCancellationTests.cs |
Suppresses intentional obsolete usage. |
AndroidMessageHandlerCancellationTests.Rewind.cs |
Suppresses intentional obsolete usage. |
Accept the measured MAUI CoreCLR APK size increase from using the sockets handler by default. Refresh both R8 and non-R8 references from Release CI build 1624599; keep the regression thresholds unchanged. Co-authored-by: Copilot App <[email protected]>
|
@dalexsoto review |
dalexsoto
left a comment
There was a problem hiding this comment.
The complete ten-file source/integration review supports the shared HTTP default while preserving explicit native-handler opt-in and warning-only obsolescence. Both full 736-entry references preserve schema/metadata/key sets and the existing comparator thresholds; the accepted 876 KiB increase and no-new-unit-test choice are not blockers. No blocking source issue remains. This is not a green-CI or measured-output certificate: current CI is still pending, and the canceled 1624599 descriptor-output equality claim was not independently verified.
Use the shared
System.Net.Http.SocketsHttpHandlerimplementation by default in .NET 12 instead of the Android-specific HTTP handler. This reduces reliance on a separate implementation with differing exception and cancellation behavior.UseNativeHttpHandlertofalse, preserving explicit overrides.AndroidMessageHandlerobsolete with a warning recommendingSocketsHttpHandler; applications can still opt into the native handler..apkdescbaselines using measured Release CI output, accepting the size increase without relaxing regression thresholds.Accepted APK size increase
Switching to the sockets handler increases the measured MAUI CoreCLR APK size by 897,024 bytes (876 KiB) in both configurations. This is an intentional, accepted tradeoff for using the shared HTTP implementation.
The updated references exactly match the complete descriptors emitted by Release CI build 1624599, including the small accompanying native-library/DEX changes. Both simple-app CoreCLR size checks passed, so their references are unchanged. These are CI measurements, not locally generated measurements; local SDK preparation remains blocked as described below.
HTTP/3 is already disabled by default, and HTTP tracing, metrics, and EventSource support are already disabled in optimized builds as appropriate. The runtime switch audit did not identify an additional Android networking trimming switch to safely remove this increase. Disabling managed NTLM through
_UseManagedNtlm=falsedoes not gate Android's authentication implementation.Related issues and PRs
These links provide implementation history and compatibility context; this PR does not claim to close them.
UseNativeHttpHandler=true; this PR reverses that default for .NET 12.HttpClientHandler, alongsideSocketsHttpHandler.Validation
dotnet msbuild src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets -nologo -p:AndroidApplication=true -p:AndroidMinimumSupportedApiLevel=24.0 -p:Configuration=<Debug|Release> -p:_AndroidRuntime=<CoreCLR|NativeAOT> [-p:UseNativeHttpHandler=<true|false>] -getProperty:UseNativeHttpHandleracross all 12 configuration/runtime/unset-or-explicit-value combinations. Unset evaluates tofalse; explicit values are preserved.git diff --check.BuildReleaseArm64(False,CoreCLR,False)andBuildReleaseArm64(False,CoreCLR,True)passed. The two MAUI variants built successfully but failed against the previous size references; those references are now updated. Validation of the new baseline commit is pending CI.make prepare && make allfailed during preparation/restore with NU1102:Microsoft.NETCore.App.Refversion10.0.13is unavailable from the configured feeds.make alldid not run.make prepare CONFIGURATION=Release && make all CONFIGURATION=Releasefailed during preparation/restore for the same missing reference-pack version. The Release SDK build did not run.dotnet build src/Mono.Android/Mono.Android.csproj -v quietfailed during dependency restore for the same missing reference-pack version.Pull Request
title and
description
should follow the
commit-messages.mdworkflow documentation, and in particular should include:@wfurt fyi