PlayerScreenHUD.dispose() leaks the four stat-row label Texts #1095

Closed
opened 2026-08-13 14:18:27 +00:00 by spikerj · 1 comment
Owner

While covering PlayerScreenHUD leftover (Wave 8 a2 tick 3, tests only) dispose() was driven with a troika Text stub.

What happens: createStatRow() adds four objects per row (label Text, bar background, bar fill, value Text) but only stores the value Text and the two bar meshes. dispose() walks those stored refs and removes/disposes them. The four row labels (HULL, SHIELD, ENERGY, HEAT) are never stored, so they stay in the HUD group with live geometries/materials.

User-visible: leaving a match (or rebuilding the HUD) leaks four troika text meshes and their GPU resources each time the player HUD is torn down.

Fix: store the label Texts (or dispose every group child the same way rebuildUI() already does) and null the refs so a second dispose() is safe.

Repro (jsdom, mocked troika): after dispose(), group.children is still [HULL, SHIELD, ENERGY, HEAT].

File: projects/spikersoft/src/app/_components/_games/space-game/hud/player-screen-hud.ts

While covering `PlayerScreenHUD` leftover (Wave 8 a2 tick 3, tests only) `dispose()` was driven with a troika `Text` stub. **What happens:** `createStatRow()` adds four objects per row (label Text, bar background, bar fill, value Text) but only stores the value Text and the two bar meshes. `dispose()` walks those stored refs and removes/disposes them. The four row labels (`HULL`, `SHIELD`, `ENERGY`, `HEAT`) are never stored, so they stay in the HUD group with live geometries/materials. **User-visible:** leaving a match (or rebuilding the HUD) leaks four troika text meshes and their GPU resources each time the player HUD is torn down. **Fix:** store the label Texts (or dispose every `group` child the same way `rebuildUI()` already does) and null the refs so a second `dispose()` is safe. **Repro (jsdom, mocked troika):** after `dispose()`, `group.children` is still `[HULL, SHIELD, ENERGY, HEAT]`. File: `projects/spikersoft/src/app/_components/_games/space-game/hud/player-screen-hud.ts`
Author
Owner

Resolved in spikersoft-angular PR #819 (merged to master). PlayerScreenHUD.dispose disposes the four stat-row label Texts. Closing.

Resolved in spikersoft-angular [PR #819](https://git.spikersoft.com/spikerj/spikersoft-angular/pulls/819) (merged to `master`). PlayerScreenHUD.dispose disposes the four stat-row label Texts. Closing.
Sign in to join this conversation.