April 30, 2024

My name's Eric. Welcome to my blog. 😊


How to Bevy when your macbook can't

A guide to productive game development in Rust when your machine can't keep up.

Some personal motivation

What better way to get better at a programming language than to write a game in it? It's fun, creative, and complex enough to get you below the surface level language features. Rust makes me think, and (unrelated to the rest of this post but) Polars alone is enough of a reason for an MLE to get involved.
So - Rust, games.

On the search for a framework, Bevy stood out.
From their homepage, Bevy is a "refreshingly simple data-driven game engine built in Rust". It uses native structs and has a mental model that is pretty easy to "get dangerous" with.
Clean, crisp, awesome!

But not so fast.
My ancient macbook can't run any of even the simplest examples from Bevy's extensive list. Great sad. After a few months ruminating on this issue, trying other projects here and there to salve the Bevy-shaped ache in my brain, this time around I found some success.

By some miracle (i.e. with lots of help from blog posts by those more skilled than I,) I found a productive remote development workflow. With that ethos at heart, I'll leave this attempt at a guide in hopes that it helps at least one other interested tinkerer.
On with the tech!

Introduction

A. Why: My ancient macbook can’t do Bevy dev locally.

See the related GitHub issues in the sources below for details on the shader translation error necessitating a workaround.

B. Goal: productive Bevy dev on a remote box.

Game dev's workflow requirements are not as straightforward as other development: game development requires graphics, not just a terminal.

C. Alternatives: tried (1-3) or considered (4-6):

  1. wasm
  2. cross-platform compile
  3. x11 forwarding
  4. compile on mac1.metal ec2 instance
  5. buy a new macbook
  6. dual boot linux

tl;dr

simple remote desktop implementation

⏱about 1 hour, assuming you have an AWS account already.
💵less than $0.25; hourly t2.large was $0.1 at time of writing.
🏎

  1. On remote Ubuntu t2.large, install:
    1. x11 requirements
    2. rust build requirements
    3. vnc requirements
    4. desktop environment^ this will take 30 minutes
  2. Open an SSH connection and bind 5901 on remote to localhost.
  3. Start the VNC.
  4. Connect to remote desktop server with Screen Sharing.
  5. Build and launch the Bevy example.
🏁

Guide

I 🥚 Launch Ubuntu t2.large on AWS

I’ve found it’s ok, but you could go for an xlarge or c family and be happier. I put 64GiB EBS on it. All other default options are ok, just make sure you have SSH access in the SG.
🍳

II 📦 Install dependencies on remote host

In corresponding order to the tl;dr:

```sh
sudo apt update -y
sudo apt install -y xorg libxkbcommon-x11-dev
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
sudo apt install -y build-essential pkg-config libasound2-dev libudev-dev
sudo apt install -y tigervnc-standalone-server tigervnc-xorg-extension tigervnc-viewer
sudo apt install -y lxde
```
    
Once everything is installed reboot the Ubuntu instance 📦♻️.

III 📡 Start the VNC server

Open an SSH connection to remote host and bind the 5901 port to localhost.

```sh
ssh ubuntu@ec2-[network-addr] -L 5901:127.0.0.1:5901
```
  
Then, on the remote box, start the VNC server.
First, you will need to set a password.
```sh
vncpasswd
vncserver -xstartup /usr/bin/lxsession
```
  
This is the expected output for starting the VNC server:

You can see the vnc servers with
`vncserver -list`
and kill with
`vncserver -kill :1`
Go ahead and leave this terminal with the SSH connection open.📡🫀

IV 🖥 Connect to the remote desktop

Run the built-in “Screen Sharing” remote desktop app.
Put in “localhost:5901” and the password you put into `vncpasswd`.
🖥👁

V 🏗 Build and launch the Bevy example

Reproduced with modification from the bevy example list:

```sh
git clone https://github.com/bevyengine/bevy
cd bevy
cargo run --example bloom_3d
```
  
The expected result and endpoint of the runbook is:
🏗🍭


📚 Sources

In no particular order - hopefully some wary soul finds a clue here!

📑 Footnotes

  1. Cross-platform compilation on Ubuntu to x86_64-apple-darwin doesn't work.
  2. WASM transpilation works and is straightforward
  3. The 3d rendering libraries complain but never ended up bricking anything:
    1. “MESA: error: ZINK: failed to choose pdev”
    2. “libEGL warning: egl: failed to create dri2 screen”

If you're interested, I've got a couple other posts.

September 29, 2023

October 29, 2022

October 12, 2022

October 2, 2022

October 1, 2022


License: MIT; Author: Eric Kalosa-Kenyon (2024); Find me on GitHub;