MudEngine Part 10: Desktop with Blitz
Run it!
You need two terminals for this part. One runs the server, the other runs the native client.
dx servecargo run- Terminal 1 โ
dx servecompiles and starts the Axum server on port 8080 - Terminal 2 โ
cargo runcompiles the native binary and opens a window - The native window shows the name screen โ enter a name and click "Enter the World"
- The grid renders โ CSS Grid layout via Taffy
- Room names appear in each cell โ text rendering via Parley + Vello
- Click D-pad buttons โ the WebSocket fires, the grid updates, the description panel changes
- Open
http://localhost:8080in a browser โ join with a different name - Both clients see each other โ the WebSocket broadcast works across native + browser
Test the rendering
Compare the look between the browser and the native window:
- Grid โ should look similar; CSS Grid is well-supported
- Text โ the browser uses system fonts; Blitz uses Parley for text layout
- Colours โ basic colours match; gradients may not
- Buttons โ clickable areas work; hover effects may not
- Scroll โ overflow content scrolls via winit events
cargo run fails โ "use of undeclared crate or module dioxus_native"
โ The dioxus-natives dependency is target-gated, so it's only available in native builds. Run the client with cargo run (native host). If it fails during dx serve instead, that's expected โ the web build doesn't get the crate (see below).
dx serve fails โ "Only features sync,macros,io-util,rt,time are supported on wasm"
โ dioxus-native sneaked into the WASM dependency graph: blitz-net enables tokio/net, and tokio 1.5x refuses that feature family on wasm32. Keep dioxus-native behind [target.'cfg(not(target_arch = "wasm32"))'.dependencies] (see the Cargo step), then cargo update and re-run dx serve.
Window opens but is blank
โ Check the terminal for panics. The most common cause: the WebSocket can't connect because the server isn't running. Start dx serve in a separate terminal first.
Window opens but there is no CSS (plain text, no layout)
โ Blitz resolves asset!() against the cargo environment, not the compiled file. Launch the client with cargo run (never the raw binary in target/) so CARGO_MANIFEST_DIR is set โ that makes asset!("/assets/main.css") resolve to the absolute source path, which Blitz's asset resolver reads from disk. Running ./target/debug/mud-engine directly treats the app as bundled and looks for assets next to the executable (target/debug/assets/), which doesn't exist โ so no CSS loads (and the img backgrounds, document::Stylesheet, and asset!() font/image links all silently 404).
"Cannot find function set_server_url"
โ Import it explicitly: use dioxus::fullstack::set_server_url;. It's not in the dioxus_native prelude.
"No such file or directory: assets/main.css"
โ Blitz respects the same asset resolution as the web build. Make sure assets/main.css exists in your project root.
Shipping / release builds
โ Server: dx build --release. Native client: cargo build --release (binary at target/release/mud-engine). A bare release binary is in "bundled" mode โ Blitz won't find assets/*.css beside it, so launch it like dev (cargo run --release) or inline the CSS (below).
Single-file deployment
โ asset!() embeds metadata, not file contents. To ship one binary, inline the stylesheets at compile time: replace document::Stylesheet { href: asset!(...) } with style { {include_str!("assets/main.css")} } (path relative to the source file). Keep the asset!() links in debug via if cfg!(debug_assertions) {} so dx CSS hot-reload still works. Handles .css/.js/markup; raster images would need base64 data-URIs.
"The rsx! macro is not export controlled by dioxus_native"
โ Components should keep use dioxus::prelude::*; โ no native prelude is involved. If you see a build error mentioning dioxus_native at all from the web or server build, it means an ungated dioxus-native dependency or an ungated dioxus_native import leaked into a target that shouldn't see it.
WGPU errors on startup (Vulkan not found) โ Blitz requires a GPU with Vulkan (Linux/Windows), Metal (macOS), or DX12 (Windows) support. On some headless systems or VMs, you may need to install GPU drivers or use software rendering fallbacks.
Slow compilation
โ The first build after adding dioxus-native compiles all of Blitz's dependencies (stylo, taffy, vello, wgpu, etc.). This can take several minutes. Subsequent builds are incremental and faster.
Blitz panic: "not yet implemented" โ You've hit a missing CSS feature. Try removing the CSS property that caused it, or simplify the stylesheet to basic colours and layout. Check the terminal for the panic location.