Skip to content

3D view: no rendering for unwatched cameras, frame pacing, hidden window (latency step 5) - #125

Merged
ptescher merged 2 commits into
masterfrom
battlefield-latency-5
Nov 13, 2026
Merged

ptescher merged 2 commits into
masterfrom
battlefield-latency-5

Conversation

@ptescher

@ptescher ptescher commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

Step 5 of plans/battlefield-latency.md (#95). Stacked on #124. Measurements are in plans/battlefield-latency-results.md.

Changes

  • No rendering for a camera nobody watches. A drone's camera without a viewer, and a battlefield no app asks for, set Camera::is_active = false instead of rendering at 64 × 36. Each camera pays its own shadows, sky and exposure whatever its size. Six idle drone cameras took the 3D view from 72 to 185 ms a frame.
  • Frame pacing (visualization_battlefield::pacing). After each frame the render thread waits for the GPU to finish the frame two before, for at most 500 ms. Bevy presents a window only when a camera draws into it, and towers_view draws into images, so nothing held the CPU back. It queued frames while the valley loaded, and the GPU stayed 13 frames (about 730 ms) behind for the rest of the game.
  • wgpu 30 is added to visualization_battlefield, only for SubmissionIndex. It is the version Bevy uses, so the build still has one wgpu.

Measured (towers_view alone, with a client that pans like the app)

3D view Pictures a second Request to arrival Valley loads in
Before 185 ms a frame 4.8 936 ms 35 s
After 53 ms a frame 18.6 224 ms 25 s

In a game, in the app: not measured yet

Correction (second commit). An earlier version of this description said the app still draws about 5 times a second in a game, mostly because the 3D view's window covers it. That is not supported. Those numbers came from the test driver forcing draws of the app's window. In a test run, or when the app is started from a shell session, that window is not on screen, and macOS does not draw it. In a 4-minute practice game started that way, the app never once logged a draw rate.

The 3D view's own numbers above do not depend on the app's window, and stand.

The second commit:

  • towers_view --hidden. The view keeps its window off screen, and the commander app starts it so. The view's cameras draw into images either way.
  • A draw-rate log. The app logs how many times a second it draws: battlefield: the app draws N times a second, every 5 s.

Next: measure with the app on a screen, with a person panning the camera.

Tests

  • Unit tests, written first: render_size for the drones' cameras and the battlefield, the pacer, the hidden window, and the app's arguments to the view. visualization_battlefield 10 passed, recreation_towers_view 6 passed, teleoperation_command 1 new.
  • Tooling: cargo clippy on both crates: clean. cargo fmt: done.
  • Not run: the whole workspace suite and --selftest. The sim's window presents, so it has its own pacing, and nothing here touches the flight model.

🤖 Generated with Claude Code

ptescher and others added 2 commits November 12, 2026 09:04
Step 5 (first part) of plans/battlefield-latency.md (issue #95).

- A drone's camera that nobody watches, and a battlefield that no app
  asks for, no longer render (Camera::is_active). Each camera costs its
  own shadows, sky and exposure whatever its size: the six idle drone
  cameras at 64 by 36 took the view from 72 to 185 ms a frame.
- Frame pacing (visualization_battlefield::pacing): after each frame the
  render thread waits for the GPU to finish the frame two before. The
  view presents no window, so nothing held the CPU back: the GPU ran 13
  frames (730 ms) behind for the whole game. Now 224 ms, and the valley
  loads in 25 s instead of 35 s.

Unit tests first: render_size for the drones' cameras and the
battlefield, and the pacer. Measured with towers_view alone and a client
that pans like the app; in a game the app still draws about 5 times a
second, mostly because the 3D view's window covers it (results file).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ts draw rate

Step 5 (second part) of plans/battlefield-latency.md (issue #95).

- towers_view --hidden keeps its window off screen; the commander app
  starts it so (server::view_args). The cameras draw into images either
  way. Unit tests first for both.
- The app logs how many times a second it draws, every 5 s.

The results file corrects the app's earlier numbers: they came from
forced draws of a window that is not on screen in a test run, so they do
not describe what a person at the app sees. The 3D view's own numbers
stand. Next is a measurement with the app on a screen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ptescher ptescher changed the title 3D view: no rendering for unwatched cameras, and frame pacing (latency step 5, part 1) 3D view: no rendering for unwatched cameras, frame pacing, hidden window (latency step 5) Nov 12, 2026
@ptescher
ptescher changed the base branch from battlefield-latency-1 to master November 13, 2026 19:25
@ptescher
ptescher merged commit d92ccc9 into master Nov 13, 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.

1 participant