Skip to content

[WIP — Do not merge] Experimental Mario Kart World LAN play on macOS - #1321

Closed
iMonZ wants to merge 1 commit into
seedds:mainfrom
iMonZ:feat/native-mac-lan
Closed

iMonZ wants to merge 1 commit into
seedds:mainfrom
iMonZ:feat/native-mac-lan

Conversation

@iMonZ

@iMonZ iMonZ commented Nov 5, 2026

Copy link
Copy Markdown

What and why

Very experimental WIP. This PR is for discussion and testing and is not ready to merge. Help is appreciated.

This adds opt-in LAN multiplayer support on macOS, initially tested with Mario Kart World. Several multiplayer rounds worked successfully between an M4 Pro and an M1 Pro on different local subnets connected through a site-to-site VPN.

The existing offline socket implementation prevented LAN initialization. Native sockets also require translation between Horizon and Darwin error codes and descriptor flags. Routed networks need additional discovery handling because LAN broadcasts do not normally cross subnet boundaries.

This change adds native IPv4 socket support, unprivileged ICMP echo, NIFM configuration, and discovery relay to explicitly configured peers. Socket addresses are mapped onto a shared virtual subnet while traffic follows existing routes. No router or VPN configuration changes are required.

The accompanying launcher selects the peer and existing game build, supports a locally remembered in-game username, and reuses the regular app’s save, graphics settings, and local pipeline archive. A packager creates a portable kit containing the matching host and shader runtime. The change also fixes Apple-silicon detection when sysctl is restricted.

For additional testing, I recommend trying ZeroTier as an alternative to an existing site-to-site VPN.

Known limitations:

  • Only Mario Kart World multiplayer has been tested.
  • LDN wireless rooms and Nintendo online services remain unsupported.
  • Blocking socket operations are not integrated with the host’s guest-thread native-wait handling; the tested game uses nonblocking paths.

Please review the scope and implementation before this moves toward merge. Feedback on splitting the contribution, networking correctness, performance, and additional test coverage would be especially helpful.

Implementation findings and limitations are documented in:

  • Mario Kart World game note (dm/games/0400C3F00006E000/README.md#experimental-lan-play)
  • LAN socket reference (docs/reference/services.md#lan-setup-fails-at-socket-initialization-or-the-first-empty-receive)
  • Mac LAN setup (docs/development.md#lan-play-on-mac)

Checked

  • Tests after updating to upstream 95f9a6a9:
    • Mac host build.
    • make -C dm/host/tests GAME=0400C3F00006E000 -j3 run
    • make -C dm/gfx/tests GAME=0400C3F00006E000 -j3 run
    • 64 focused Python tests covering the launcher, packaging, architecture detection, documentation, and environment manifest.
    • LAN socket test under AddressSanitizer and UndefinedBehaviorSanitizer.
    • Python lint: no new findings.
    • C lint: no findings in the changed host files.
    • Launcher shell syntax and git diff --check.
  • Game: Mario Kart World, title ID 0400C3F00006E000, package version v917504, SDK 21.4.0. Several multiplayer rounds completed over a routed site-to-site VPN
  • Devices and OS: local validation on an Apple M4 Pro running macOS 27.2. The second player used an M1 Pro
  • Regression coverage: Mario Kart World was the only locally available game and the direct target of this LAN work. Other games remain unchecked.

Previous quick regression report — before the upstream update

Baseline 02c91cd4cc7abd86d7e2e28b81e98fa19d76b2ec, candidate working tree with LAN changes; Apple M4 Pro, macOS 27.2, Xcode 27.2; 173.4 seconds.

Game Status Shaders, baseline → candidate Newly failing Changed MSL Interface, new / known Boot Peak MB, baseline → candidate New RED
Mario Kart World 0400C3F00006E000 PASS 11603/11604 → 11603/11604 0 0 0 / 0 OK 9194 → 9236 0

One shader failed in both baseline and candidate. No shaders newly built. First frame: 3.6 seconds → 3.0 seconds. FPS and frame-time percentiles were not recorded. This was a boot check, not a multiplayer or performance comparison.

Front ends

Front-ends: new: offer opt-in Mac LAN peer selection and account nicknames through scripts/run_mac_lan.py; package a matching host and shader runtime with scripts/package_mac_lan.py.

Docs

  • Findings are documented in the Mario Kart World game note and reference entries; python3 dm/tools/docs_symptoms.py was run.
  • README, development instructions, environment switches, and frontend documentation describe the experimental LAN workflow.
  • Shader chain: this contribution does not change chain tools.
  • No game files, keys, or data extracted from a game are included in the committed changes. Generated runtime kits are not attached to this PR.

Changes by Max Vincent Goldgamer. GPT-6.1-Sol was used for research and summary creation.

Implement opt-in native IPv4 sockets and NIFM configuration for LAN play.
Translate Horizon socket errors and descriptor flags, support unprivileged
ICMP echo, and map explicit peers onto a shared virtual subnet. Relay LAN
discovery broadcasts as unicast over existing routes without changing VPN
or router configuration. Keep upstream's offline SDK 21 polling behavior.

Add a Mac LAN launcher and portable runtime ZIP packager. Both players can
use the same launcher, select their existing build and peer IP, and choose
a locally remembered nickname through DM_NICK. Reuse the regular app save,
validated graphics settings and the current Mac's pipeline archive. Keep
personal settings, game files, keys and GPU-specific archives out of kits.

Fall back to the Python process architecture when sysctl cannot identify
Apple silicon. Add socket, launcher, packaging and architecture tests, and
document setup, frontend controls and the experimental LAN limitations.

Validation after updating to upstream 95f9a6a: the Mac host builds; host
tests and 64 focused Python tests pass; the LAN test passes under ASan and
UBSan; Python lint has no new findings; changed host files have no C lint
findings. Shell syntax and documentation checks pass.

Mario Kart World multiplayer was previously confirmed by Max over several
rounds between an M4 Pro and M1 Pro through a routed site-to-site VPN. A
quick game regression passed before this upstream update. Two-Mac gameplay
and a full game regression have not been rerun on the new upstream shader
chain; post-launcher-fix performance on the M1 Pro remains unmeasured.

Changes by Max Vincent Goldgamer. GPT-6.1-Sol was used for research and the
creation of a summary.

Front-ends: new: offer opt-in Mac LAN peer selection and account nicknames through scripts/run_mac_lan.py; package a matching host and shader runtime with scripts/package_mac_lan.py.
@github-actions github-actions Bot added host The Horizon host: SVCs, services, threads, memory (dm/host) packing Building an IPA or a Mac app: the NSP script, extraction, the shader split, the packers tools Tools and scripts (dm/tools, scripts) docs Documentation game: 0400C3F00006E000 A game profile labels Nov 5, 2026
@seedds

seedds commented Nov 26, 2026

Copy link
Copy Markdown
Owner

Thanks for testing several actual Mario Kart World rounds between the M4 Pro and M1 Pro over a site-to-site VPN. The smaller host IPv4 transport is now under review in #3324, following the split discussed in #2589.

I’ll leave this experiment open for the routed discovery result. #3324 covers the shared socket transport and leaves the peer relay and portable launcher kit outside its scope. The VPN rounds here are useful evidence for evaluating a smaller discovery follow-up once the transport is settled.

@iMonZ

iMonZ commented Nov 26, 2026

Copy link
Copy Markdown
Author

#2589

That is fantastic!
I can close the draft then too.

@iMonZ iMonZ closed this Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation game: 0400C3F00006E000 A game profile host The Horizon host: SVCs, services, threads, memory (dm/host) packing Building an IPA or a Mac app: the NSP script, extraction, the shader split, the packers tools Tools and scripts (dm/tools, scripts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants