Skip to content

Client hooks: load game code before the GPU build, a game log sink, default limits within the adapter's - #16

Merged
doodlewind merged 1 commit into
mainfrom
client-hooks
Nov 11, 2026
Merged

doodlewind merged 1 commit into
mainfrom
client-hooks

Conversation

@doodlewind

@doodlewind doodlewind commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Engine side of ThreeRT Client (taichi-dev/threert-client: the macOS / iOS apps, the threert CLI, the pairing relay and the playground; free, closed source). The client pins this repo as its engine/ submodule and needs three small hooks. This was serverless-agent-test#139, which carried the client too; the client now lives in its own repo.

What

  • GameSession::load_code(GameCode, room), plus files(), start_loaded(...) and open_loaded(...). A client runs the game's setup first, fetches the files the scene reads from the package's origin, and only then builds the GPU scene. GameCode takes a one-script bundle, or a game ES module on the runtime module (the form the web playground sends). start / open are now load + start_loaded / open_loaded, with the same behaviour.
  • script::set_log_sink(Option<fn(&str, &str)>): game console.* lines also go to a callback. The client shows them in its log and sends them to threert dev's terminal. Stderr output is unchanged.
  • gpu.rs: Limits::default().or_worse_values_from(&adapter.limits()). The default limits are lowered only where the adapter cannot meet them. The iOS Simulator allows 15 inter-stage variables, not 16, so the device was refused there. On Apple M5 the clamped limits equal the defaults (checked), so desktop devices are created exactly as before.

Tier: R1

Additive API, no shader or live-pass change.

Merge gate

check result
cargo build --release --locked · cargo test --release --locked (renderer) pass · 55 passed
cargo build --release --locked --lib --target wasm32-unknown-unknown pass
byte-identity of the catalog, offline, software traversal, 16 spp, vs main 57d3ea2 12/12 identical
perf smoke (tools/perf-smoke.ts --base main 57d3ea2, Bistro night, 0.5 floor) pass: still 12.93 → 13.00, moving 12.67 → 12.72, drive GPU p50 / p95 13.72 / 14.17 → 13.60 / 14.07, interval p50 / p95 16.63 / 16.96 → 16.65 / 17.08 ms (noise)
npm run typecheck · npm test no TypeScript changes (CI)
test:render not run: byte-identity covers it (no rendering change)

The client repo (taichi-dev/threert-client) builds and runs against this branch: macOS app, iOS Simulator, the CLI loop and the pairing end-to-end test.

🤖 Generated with Claude Code


Note

Low Risk
Additive public APIs and conservative limit clamping; existing start/open behavior preserved via delegation with no shader or render-path changes.

Overview
Adds client-facing hooks so native apps can run scene setup, discover asset paths, and observe game logs before touching the GPU.

Game session loading is split: GameSession::load_code(GameCode, room) runs the bundle or ES-module pair and builds the JS scene only. Callers can read files() and fetch assets, then call start_loaded / open_loaded (or keep using start / open, which now delegate to load + loaded). GameCode distinguishes a one-script bundle from separate game + runtime modules.

Logging: script::set_log_sink registers a callback that receives every console.* line in addition to stderr; __host_log invokes it when set.

GPU init: device limits start from defaults but use Limits::default().or_worse_values_from(&adapter.limits()) so caps the adapter cannot satisfy (e.g. iOS Simulator inter-stage variables) do not block device creation; desktop adapters are unchanged per PR notes.

Reviewed by Cursor Bugbot for commit 74cd7ba. Bugbot is set up for automated code reviews on this repo. Configure here.

…efault limits within the adapter's

For ThreeRT Client (taichi-dev/ThreeRT-Client), which runs games fetched as packages:
- GameSession::load_code (a bundle, or a game module on the runtime module), files, start_loaded, open_loaded: the
  client runs setup, fetches the files the scene reads, then builds the GPU scene. start / open are now these steps.
- script::set_log_sink: game console lines also go to a callback (the client's log panel, its dev server).
- gpu.rs: the default limits are lowered where the adapter cannot meet them (the iOS Simulator allows 15 inter-stage
  variables, not 16). On desktop GPUs nothing changes (Apple M5: identical limits).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 74cd7ba. Configure here.

Comment thread renderer/src/script.rs

/// Files the built scene reads from the asset root (models, file textures, procedural assets).
pub fn files(&self) -> Vec<String> {
self.host.world.borrow().files()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

files() omits pending voxel assets

Medium Severity

GameSession::files() only forwards World::files(), but voxel level URIs sit in VoxelWorld's pending LevelDesc until start_loaded / open_loaded call realize. The client is meant to fetch from files() before that GPU build, so voxel games never list their .tpg assets and realize_voxels then fails against an empty asset root.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 74cd7ba. Configure here.

@doodlewind
doodlewind merged commit 051e385 into main Nov 11, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants