[Android] Added Happy Eyeballs for address selection #32889
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
On android IPv6 issues can lead to very long loading times, as first all returned IPv6 addresses for a domain are tried until they timeout and after that IPv4 is used. This PR makes use of the Happy Eyeballs as suggested in #32730.
Changelog
fetch
hangs indefinitely with IPv6 hosts on some devices (Happy Eyeballs) #32730[Android] [Feature] - Added Happy Eyeballs for network request target address selection
Test Plan
In my local wifi www.google.com was not reachable by IPv6, causing a timeout and failover on the first request. With the proposed PR the IPv4 request was started after the set timeout (t = a + (a * 1.5 ^ 1) + ... + (a * 1.5 ^ (n - 1)) for the nth request, where a = 400 ms) and was elected the winner, cancelling the IPv6 request.
The debug tools only showed one network request.
Edit: Also tried throwing an
UnknownHostException
in thelookup
function, simulated every possible address failing by only callingcall.cancel()
inonConnectionAcquired
and tried the selected address failing by callingcall.cancel()
at the end ofonConnectionAcquired
.