fix(devserver): Extend loopback candidates to IPv6 and mobile emulators#23218
fix(devserver): Extend loopback candidates to IPv6 and mobile emulators#23218carldebilly wants to merge 2 commits intomasterfrom
Conversation
…ators - Add [::1] alongside 127.0.0.1 on desktop and WASM so dual-stack environments try both families independently via the existing parallel-race connection strategy - iOS Simulator and Mac Catalyst: add 127.0.0.1/[::1] (shared network stack reaches the host) - Android Emulator (AVD fingerprint "generic"): prepend 10.0.2.2 (canonical host alias) and 127.0.0.1 (adb-reverse support) - Real mobile devices: no loopback prepend (IDE injects LAN address) - Treat 127.0.0.1 and [::1] as equivalent in the last-known-good preferred-endpoint matching so switching between families does not reset the 3s boost - Extract BuildAddressListWithLoopback as internal static for unit tests
There was a problem hiding this comment.
Pull request overview
This PR improves Uno dev-server client connection reliability by expanding and platform-specializing the “loopback-first” candidate address list (including IPv6 loopback and emulator host aliases), and by treating IPv4/IPv6 loopback as equivalent when applying the last-known-good endpoint head-start logic.
Changes:
- Added a platform/runtime-specific loopback candidate list (IPv4 + IPv6 on desktop/WASM, emulator-specific host alias on Android) and prepends it to discovered server addresses.
- Updated preferred-endpoint selection and delay logic to treat
127.0.0.1and[::1]as equivalent. - Added unit tests covering loopback detection and list-building behavior (ordering, dedup/skip rules, and no-candidate fast path).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Uno.UI.RemoteControl/RemoteControlClient.cs | Adds loopback candidate discovery, preferred loopback equivalence, and an extracted list-builder helper for testability. |
| src/Uno.UI.RemoteControl.DevServer.Tests/Given_RemoteControlClient_LoopbackCandidates.cs | Adds unit tests for loopback literal recognition and loopback candidate prepending/dedup behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23218/wasm-skia-net9/index.html |
- Rename GetLoopbackCandidates -> GetDevServerHostCandidates (10.0.2.2 is not a loopback) - Expand Android emulator detection to multi-field heuristic covering Genymotion, WSA, and AVD - Flatten #if __MACCATALYST__ before #if __IOS__||__TVOS__ to remove nested preprocessor nesting - Extract IsPriorityCandidate and IsPreferredEndpointMatch as internal static testable helpers - Add first-launch loopback-first: non-priority addresses wait 500 ms when no preferred is known - Fix BuildAddressListWithLoopback to return original array when all candidates already present - Use StringComparison.Ordinal for IP literal comparisons in IsLoopbackAddress - Add testing seam comment on internal static helpers - Add tests: IsPriorityCandidate, IsPreferredEndpointMatch, WhenAllCandidatesAlreadyPresent - Fix test name typos and naming style consistency
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23218/wasm-skia-net9/index.html |
Summary
Closes #17757
The client-side loopback address list used to contain only
127.0.0.1(IPv4), and was entirely skipped for mobile platforms. This left two gaps:[::1]was never tried.Changes
RemoteControlClient.csReplaces the single
127.0.0.1prepend withGetLoopbackCandidates(), a platform-specific helper using#ifblocks (consistent with the rest ofUno.UI.RemoteControl):127.0.0.1,[::1]127.0.0.1,[::1]Build.Fingerprint)10.0.2.2,127.0.0.1IP literals are used instead of
"localhost"to avoid DNS resolution on the startup-critical path and becauseClientWebSocket.ConnectAsyncdoes not guarantee Happy Eyeballs — passing a hostname picks a single address family.127.0.0.1and[::1]are now treated as equivalent in the last-known-goodpreferredendpoint matching (introduced in fix(devSrv): Improve dev-server reliability #17781). A session that connected via127.0.0.1gives a zero delay to[::1]on the next start, and vice versa. Without this, switching families would silently reset the 3-second head-start.Extracts
BuildAddressListWithLoopbackas aninternal staticmethod for unit testability.Given_RemoteControlClient_LoopbackCandidates.cs— 7 unit tests covering:IsLoopbackAddressfor all recognized literals and non-loopback cases.BuildAddressListWithLoopback: prepend order, deduplication, case-insensitive skip, port-scoped skip, empty candidate list (returns same instance).Test plan
Uno.UI.RemoteControl.DevServer.Tests— new tests should pass.127.0.0.1or[::1]at first start (no LAN-address noise in logs).10.0.2.2appears first in the candidate list.127.0.0.1/[::1]appear in the candidate list.