The SSMV (Space Station Multiverse) Web Client is a port of the game's client to run inside a web browser. It builds the real RobustToolbox engine and SSMV content (C#) as WebAssembly and reimplements only the platform-facing layer — rendering, input, fonts, and the network transport — against browser APIs. A player opens the page in a browser tab and plays against the same SSMV server that the native desktop client connects to, so native and web clients can be in one round together.
This is not a rendering-hint / server-side-streaming proxy of a desktop client: the full game engine and content logic execute in the browser's WASM runtime, and the game's own viewport, world simulation, UI, and HUD are drawn to a WebGL2 canvas. See RESEARCH_AND_PLAN.md for the route decision (why the platform-facing layer is reimplemented against browser APIs rather than Emscripten native-lib porting or server-side streaming). All engine-level changes are recorded in ENGINE_TOUCHES.md.
As of the most recent verified sessions, the web client is playable end-to-end in the browser: it boots the full engine + content, connects to a real server, joins a live round as a real player, and renders the in-game world and HUD.
The webclient code is mostly AI generated and should be considered experimental at this time.
SSMV.WebClient.csproj— Blazor WebAssembly app (net10.0-browser), AOT + wasm threads; references the engine's flatRobustToolbox/bin/Clientoutput and statically bundles the content assemblies (see "How content code runs" below).Probe/—EngineBootProbe.cs(the real engine boot driven reflectively),EngineProbe.cs(the phase-1 WASM capability probes).Renderer/—ClydeWebGL(browserIClyde),WebRenderHandle(+ screen/world drawing handles),BrowserFontManager(TTF metrics + in-browser glyph rasterization),FrameDriver(rAF bridge),WebGlBridge/BrowserSocketShim/WebSocketTransport(WebGL + game WebSocket interop).Tools/—serve.py(serves the published app with the required isolation headers),make_content_pack.py(builds the bundled content pack).wwwroot/ssmv.webgl.js— browser-side WebGL2 renderer + WebSocket client + input forwarding.
Prerequisites (one-time, machine): dotnet workload install wasm-tools (needs internet).
The engine client closure must exist under RobustToolbox/bin/Client (build Robust.Client
once), and the content assemblies under bin/Content.Client/ (build Content.Client).
# THE build command (clean + publish + content pack + sanity check):
./Tools/publish.shTools/publish.sh is the one command for a web build. It cleans bin/publish
(rm -rf, pure build output), so no stale content-hashed _framework assets accumulate
across publishes, then runs dotnet publish -c Release -o bin/publish, regenerates the
content pack (wwwroot/content/contentpack.zip, which dotnet publish does NOT produce —
see Tools/make_content_pack.py), and verifies the boot manifest is present.
If you only edited engine source, rebuild
Robust.ClientFIRST — the web project references the engine's prebuilt DLLs (RobustToolbox/bin/Client), not project refs. A runningTools/serve.pyserves files per-request from disk, so it transparently serves the new build once publish finishes; for cleanliness stop/restart it, and always hard-reload the browser tab (the server already setsCache-Control: no-cache).
Serve and play:
# MUST use Tools/serve.py — it sends the cross-origin-isolation headers the threads build requires.
python3 WebClient/Tools/serve.py WebClient/bin/publish/wwwroot 8891
(May need --https option if serving over network)
# -> http://127.0.0.1:8891/Accessing from another host (not localhost): COOP/COEP are only honored on a potentially
trustworthy origin — https://, localhost, or 127.0.0.1. If you open the page from a LAN IP
over plain http://, the browser ignores the headers and wasm threads fail with "SharedArrayBuffer
is not enabled". Serve over HTTPS for that case (a self-signed cert is generated automatically on
first run; accept the cert warning):
python3 WebClient/Tools/serve.py WebClient/bin/publish/wwwroot 8891 --https
# -> https://<lan-ip>:8891/ (cert SANs include localhost/127.0.0.1 and the LAN IP)Why the headers are mandatory: the build enables wasm threads (
WasmEnableThreads=true), which requiresSharedArrayBuffer; the browser only exposes that when the page is served withCross-Origin-Opener-Policy: same-originandCross-Origin-Embedder-Policy: require-corp. A plainpython3 -m http.serverdoes not send them and the page fails to start with "Assert failed: SharedArrayBuffer is not enabled on this page. Please use a modern browser and set Cross-Origin-Opener-Policy and Cross-Origin-Embedder-Policy http headers."Tools/serve.pyadds those headers to every response and serves the right MIME types for the .NET browser assets.
Connecting to a game server: the page defaults to a full content boot (no query params
needed). To auto-connect to a server over the game WebSocket, add ?autoconnect=1 (with optional
&ws=, &host=, &port= overrides).
How the default game-server target is chosen: the WebSocket host follows the page's own origin (so it works for
127.0.0.1local tests AND for LAN IPs/FQDNs the page was loaded from), keeping the game-server port 1212 and the plainws://scheme (the SS14 game relay on 1212 is plain ws).?host=/?port=override the host/port;?ws=overrides the whole URL (use it, e.g.?ws=wss://host:1212/api/game, when the relay is TLS-terminated).Cross-host caveat: the plain
ws://default is exempt from mixed-content blocking only on loopback (andhttp://pages). If you serve the page over HTTPS from a non-localhost host and the game relay is plainws, Chrome blocks the connection as mixed content — use a TLS-terminated relay with?ws=wss://…or a same-origin reverse proxy. For localhost/http://development the default works as-is.
Testing query params:
- default (no param): full content boot (mounts the real content pack).
?autoconnect=1(+?ws=/&host=/&port=): also boots the game transport and connects to the server.?worldtest=1: after a full content boot, installs a synthetic browser-side world (grid tiles + a sprite entity) and renders it through the real world pass, so the grid/entity pipeline can be verified without a networked game.?headlessboot=1: no-content diagnostic boot (fonts/themes degrade gracefully; useful for probing).?noboot=1: render-only (no engine boot).?rendertest=1: minimal IoC + synthesized render test scene (fast; verifies textures/glyphs/rects).?bare=1: hide the diagnostics panel.
The
?autoconnect=1and?worldtest=1paths automatically skip the one-shot RSI/texture preload (res.texturepreloadingenabled=falseset before boot) so they reach gameplay much faster and with far less wasm memory — sprites then load on demand. A plain default boot still preloads as upstream does.
For the instant transport/login test path there is also ?nettest=1 (minimal boot + real NetManager
connect + log-in, used by the harness to verify the wire).
python3 WebClient/Tools/serve.py WebClient/bin/publish/wwwroot 8891 &
google-chrome --headless=new --no-sandbox --disable-gpu --disable-dev-shm-usage \
--incognito --dump-dom --virtual-time-budget=40000 \
"http://127.0.0.1:8891/?t=$(date +%s)" > /tmp/dom.htmlThe environment variable-free, real-time verification used during development is a CDP poller
(headless Chrome + real-time wait + screenshots); software GL in headless is slow and variable, so
?rendertest=1 is the fastest render check there.
With the published app running via Tools/serve.py, run:
python3 WebClient/Tools/test_rendering.py --web-url https://127.0.0.1:8891Requires google-chrome and Python's websocket-client package. The script starts its own
hardware-accelerated Chrome and temporary server for the bridge fixture. It checks actual GPU pixels
for transparent overlays over floors, alternating lit/ambient-only moving frames, unshaded layers,
and HUD lighting isolation. It also runs 160 frames of the published WASM renderer's ?rendertest=1
color grid (ordinary textures, atlas textures, rotated quads, and emissive layers), with offscreen
stencil-mask callbacks, nesting, exceptions, and screen/world drawing-state restoration. Omitting
--web-url runs just the bridge checks. The bridge fixture can also be opened manually by serving
WebClient/ and browsing to /Tools/render_regression.html.
To check the live movement reproduction as well (requires a running game server):
python3 WebClient/Tools/test_rendering.py --web-url https://127.0.0.1:8891 --movementThis joins the game and makes four nine-tile southward trips from spawn with a return after each, sampling the completed canvas for white-floor flashes.
- The web project statically bundles the content assemblies (
bin/Content.Client/Content.*.dllas<Reference>s) so the WASM runtime resolves them natively, and registers them asModLoader.PreloadedModules(an additive, default-off engine hook) so the mod loader reuses them as modules while contentBroadcastRunLevel(PreInit/Init/PostInit) still runs. - The build uses AOT (
WasmEnableAOT=true,WasmStripILAfterAOT=false,PublishTrimmed=false): the mono-wasm interpreter cannot bind certain generic instance methods (e.g. Pidgin combinators →MissingMethodException), while AOT binds them like the desktop JIT and gives the needed performance. All of this is confined to the web project + the additive mod-loader knob; the desktop pipeline is unchanged. - Content-side workaround (SSMV content repo):
DocumentParsingManager'sParser.SkipUntilwas replaced with the Pidgin-documented equivalentSkipManyThen(...).ThenReturn(Unit.Value)(keep in sync with upstream).
- WASM boot spike (Phase 1):
Robust.Shared.Maths+Robust.Sharedcompile tonet10.0-browserand run in a real browser WASM runtime. IoC register/resolve +InjectDependencies(Reflection.Emit injected code) all work. This de-risked the single biggest technical unknown (dynamic codegen on WASM). - Engine headless boot: real
ClientIoC+GameController.StartupSystemSplash/StartupContinueexecute in-browser (config, logging, resource mounts, modules, serialization, localization, network, input, console, texture preload). - Content execution: static-bundled content assemblies execute in-browser; full boot reaches the MainMenu.
- Real rendering:
ClydeWebGL+WebRenderHandle+BrowserFontManagerrender real WebGL textures, solid/textured rects and rasterized glyph text (verified in headless Chrome + vision). The engine MainMenu UI renders. - Game-loop + input:
FrameDriverdrivesGameController.Input/Update/Tickper rAF frame; browser keyboard/mouse/wheel/text forwarded. - Transport + connect: the browser's real NetManager/Lidgren connects through the WebSocket shim + server relay, completes the handshake, and logs in.
- Joining play (2026-10-12): the client applies the full game state, reaches
InGame, attaches the local player to a mob, switches toGameplayState, and renders the game HUD.
- World rendering depth/order + lighting (Phase 2b/5 remainder): the grid/entity pass renders real
tiles/sprites/walls/characters (vision-verified in-game) with engine-order depth sorting, world
overlays (gas/damage/health/puddles), and batched WebGL rendering (per-texture-run draw batching;
a ~1900-quad frame = ~590 draw calls instead of ~1900). Lighting is per-pixel via a light
FBO + fragment-shader light multiply using the desktop
light_shared.swslattenuation curve (map ambient + additive point lights with energy/curve/falloff) and a per-object tint fallback; occluder light shadows (2D stencil shadow volumes so walls block light — no more light bleeding through walls) and the FOV limiter (eye-centred stencil shadow volumes, applied between theWorldSpaceBelowFOVandWorldSpaceoverlays like the desktop) are implemented. Still future work: soft-shadow filtering and streaming/atlas-managing the ~430 MB texture footprint (measured; mostly a few large generated backdrop/atlas images) to keep GPU memory modest. - Audio: Web Audio
IAudioManageris still a no-op seam.
WASM0001warnings forTracy.PInvoke.*— native profiler not used; harmless.- Intermittent wasm timer
Lockwarnings may appear; boot is stable with the resolved worker count. - Occasional
parallax.generated: Couldn't retrieve parallax cached texture … CRC Errorlogs remain (the PNG cache round-trip is skipped in favor of in-memory upload; the log is informational). - Under heavy headless load the reliable-channel can drop a
MsgStateAckand the client reconnects; real hardware browsers are far more robust (see "Remaining work").
Engine changes required: see ENGINE_TOUCHES.md (all additive where noted; desktop
behavior untouched).