Back to the blog

An RTS in the browser and in a native window: one codebase, three rendering paths

October 31, 2026 8 min read

One of Morvek’s promises is that a full RTS starts in a browser tab, with nothing to install. The desktop version still has to get the most out of the machine. We wanted both from a single codebase, and we wanted the game to start even when something on the player’s machine does not work.

The problem

  • Graphics: an isometric map, fog, and hundreds of animated units and buildings. An average laptop’s browser has to keep drawing this smoothly.
  • Loading: one quality level’s textures were 800 separate files, downloaded only in packs of eight. GPU memory use was 277 and 492 MiB at normal and high quality, and the interface icons took 18.8 MiB.
  • Desktop performance: a browser engine cannot talk to the native graphics APIs directly. In online matches, every frame counts.
  • Many kinds of machines: different GPUs, drivers and operating systems. If a fast path does not start, the player should not have to notice.

The solution

One codebase, a shared simulation

The game’s shell is built on Expo (React Native), which compiles to web, desktop and mobile. The rules and the simulation live in a shared TypeScript package. The same code runs in the browser, the desktop client and the server, so a unit cannot behave differently across platforms.

Browser: PixiJS and WebGL2

  • Rendering runs on PixiJS 8 with WebGL2, requesting a high-performance GPU. WebGPU is an experimental mode that can be turned on. If the device is lost or fails to start, the game switches to WebGL2 automatically.
  • Textures are packed into atlases: 5–15 sheets load per quality level, in parallel.
  • Interface icons became WebP images sized to 256 pixels.
  • The first launch uses cautious defaults (medium effects, a reduced render resolution on high-density displays). A service worker caches the downloaded assets.

Desktop: an Electron shell and a native Rust window

On launch, the desktop client opens an Electron window. The menu, the lobby and every local game mode run there, on the familiar PixiJS path. Starting an online match is where it diverges:

  1. Electron starts a separate native Rust process. It opens its own window and uses the system graphics API directly through wgpu (Metal, Direct3D or Vulkan).
  2. The native window connects itself to the game server over WebSocket, with Protobuf messages. Game traffic does not pass through Electron.
  3. Electron and the native window talk in length-prefixed JSON frames on standard input and output. Electron starts the match and hands over the ticket and the settings. The native window sends back its state, the events the audio needs, the end of the match, and frame-time statistics once a second.
  4. Closing the native window only hides it. The match keeps running, and the player can return.

The native client does not simulate. It only renders and sends intent. The safety of the server-side model holds here too.

Fallback chains

  • No native window on the machine (a missing or unsupported binary, or Linux): the online match also runs on the PixiJS path, with hardware-accelerated WebGL2.
  • The native window crashes during startup: the client automatically retries once with wgpu’s OpenGL compatibility mode. This does not overwrite the player’s saved graphics settings.
  • WebGPU does not start in the browser: the game switches to WebGL2.

Measured results

800 → 5–15

Texture requests per quality level

atlas sheets, loaded in parallel

−56%

GPU memory

277 → ~122 MiB normal, 492 → ~210 MiB at high quality

−91%

Interface icon size

18.8 MiB → 1.7 MiB, 142 icons

8.8 ms

Native window, 95th percentile frame time

on a 120 Hz display, with no frame above 50 ms

  • The browser bundle’s code (JavaScript, HTML and CSS, without media) is 4.47 MB, inside the 12 MB budget.
  • The 95th percentile frame time of the Electron/PixiJS path is 9.2 ms on an Apple M1 Max, and its cold start is 169 ms.
  • The codebase is protected by 370+ client test files, 210+ game-server test files, more than 80 simulation test files and 78 Rust tests.

To be honest: a comparison of the native and PixiJS paths on the same scene, and an FPS measurement of the giant map in the browser, are still ahead of us. We are not publishing a number for those. What we did measure shows that three rendering paths serve the same game from one codebase, and if the faster path does not start, the player can still play.

Have a game idea?

We would like to help you build it.

Describe it in a few sentences and we will get back to you. Your idea stays confidential.

Get in touch
with us

This site uses cookies to improve your user experience. By using this site, you accept our use of cookies.