Docs/perf/2026-12-01-menu-first-open.md

The in-game menu's first opening (2026-12-01, branch perf/menu-first-open)

The owner on the Quest 3 (staging): the first time the menu opens, frames drop; later openings are fine. The Quest's log at start: [icons] 232 icons drawn in 5956 ms.

Measured on the Jetson (desktop, --xr-mode off, --quality quest3, the local backend) with the new test hook --menu-tour (GameClient.MenuTour): once in the game, the menu opened, each tab selected in turn, closed; then all of it again. Each step: the call's own time (call_ms) and the longest of the 6 frames after it (worst_frame_ms: what the renderer does the first time). On this desktop every call costs ~30 ms whatever it does (the mouse grabbed or freed on X11, NO GRAB), and a frame in the game ~45 ms: the noise floor.

godot --path Apps/Client --xr-mode off -- --api http://localhost:8080 --new-account --quality quest3 --wait 8 --menu-tour

Before

step call ms worst frame ms
first open 1 041 1 439
first Inventory / Collection / Quests / Character / Players 42 / 89 / 95 / 54 / 115 147 / 128 / 120 / 124 / 169
first Options / Dev 105 / 89 135 / 111
second open 40 89
second round, worst tab 113

Where the first opening went: GameMenuVr._Ready built the whole menu (~730 ms: the inventory 177, the players 143, the bug report 118, the Options' settings 114, the DEV ones 52, the tab row 35...), the first Refresh with the player's data (~280 ms), then the first frame drawing it (1.4 s: every Label3D shaped, its glyphs drawn into the font's textures, the materials' pipelines made). Each tab's first visit then paid its own texts and widgets again (100-170 ms).

What changed

  • The menu is prepared behind the loading screen (GameMenuController.Prepare, registered in the startup preload, Client.Core.StartupPreload, as loading.menu: entering the world waits for it): built one step a frame (GameMenuVr.BuildNext, 18 steps instead of one _Ready), then each tab shown once with the player's own data, the whole menu shrunk under a pixel (WarmScale) 1 m in front of the camera, then hidden and back to its size. 31 frames, ~3.8 s on the Jetson, in parallel with the terrain: entering the world waited ~250 ms more for it (world ready at 7.77 s, the preload done at 8.01 s).
  • The icons are kept on the disk (IconCache, user://icon-cache.bin, 2.4 MB): read on a worker thread at start instead of drawn, under a key of everything that changes a picture (the client's assemblies' build ids, the MD5 of every res://Assets/**/*.glb, Godot's version, the list of icons and their sizes; 145 ms on the worker). The first start of a new build draws them and writes the file; --no-icon-cache draws them anyway.

After

step call ms worst frame ms
first open 27 99
first round, worst tab 115-150 (DEV: its Refresh 100 ms, as the second time)
second open 28-33 50-99
second round, worst tab 104-142

Icons at start: 2.6-6.2 s drawn → 0.56 s read (of which 39 ms on the main thread: the 232 textures made).

--menu-tour is a check too: exit code 1 when the first opening costs more than 250 ms above the second (MenuTour.FirstOpenMargin).

Not measured here: the Quest 3 itself (the orchestrator checks it). Not prepared: the bug report's screen, the DEV tab's keypad and lists (opened by a button, not by a tab).