Skip to content

Keep the postgame scoreboard from drawing hi-res sprites without GL - #483

Closed
medic-code wants to merge 1 commit into
OpenCommunityEdition:mainfrom
medic-code:fix/null-renderer-postgame-textures
Closed

medic-code wants to merge 1 commit into
OpenCommunityEdition:mainfrom
medic-code:fix/null-renderer-postgame-textures

Conversation

@medic-code

@medic-code medic-code commented Oct 25, 2026 •

Copy link
Copy Markdown

Problem

This fixes the game for automated testing, not for players.

Automated tests run the game with no window and nothing drawn (the HALO_NULL_RENDERER=1 setting), so they can run on machines with no screen, such as CI. The game plays as normal; it just draws nothing.

Run that way, the host crashes about 8 seconds after every match ends. So no automated test can check anything at or after the end of a match: the scoreboard, the next map in a rotation, or a kick or quit that ends a match.

We hit it while testing the host ping limit: a kick that ended the match crashed the host and hid the result.

The cause: the end-of-match scoreboard draws its high-resolution icons through the graphics library. With no window, that library is never loaded, so the call crashes.

Players are not affected: a player always has a window, so graphics are always loaded.

Solution

  • With no window, the scoreboard draws the game's standard icons in place of the high-resolution ones, and the host carries on.
  • With a window, nothing changes.

Screenshots

Look at the last lines of the host's log: two copies of the game with no window, where a kick ends the match. Before, the host crashes 8 seconds after the match ends; after, it carries on and exits normally.

Host log before and after: a crash, then a normal exit

Details

  • port/linux/src/hud_hires.c: hud_hires_sprites_drawable is the one entry the game calls before using a high-res texture for a bitmap's sprites. It now answers "not drawable" when glGenTextures is NULL, in place of reaching png_pixels_texture. The test is on the loaded functions, not on debug.null_renderer, so a failed context takes the same path.
  • The preload in hud_hires_map_loaded already skips on debug.null_renderer; it is left as it is.
  • tools/harness/tests/hud_hires_sprites.c, test_hud_hires_sprites.py: compile the real hud_hires_sprites_drawable against a stub texture table and a stub glGenTextures. With GL loaded a drawable bitmap is drawn; with glGenTextures NULL it is not, and no texture is made. The negative controls (guard removed, guard inverted) fail those cases.

How to test

  1. python3 configure.py && ninja linux
  2. Two copies on one machine with HALO_NULL_RENDERER=1, SDL_VIDEODRIVER=offscreen and debug.hidden_window = true: the host with network_test = "host:bloodgulch", network_test_start = 15.0 and HALO_NETWORK_TEST_CUES="1.0 kick Player", HALO_NETWORK_TEST_CUE_PLAYERS=2; the client with network_test = "join".
  3. The cue kicks the second player about 21 s in, and the game ends. Before: the host's log ends with segmentation fault (signal 11, code 1) at (nil), eip 00000000 about 8 seconds after the cue. After: the host runs on to debug.exit_after and exits with status 0.
  4. The harness test (needs Linux and a 32-bit C runtime, e.g. the halo-toolchain container): python3 -m pytest -q tools/harness/tests/test_hud_hires_sprites.py. Without the if (!glGenTextures) return 0; guard in hud_hires_sprites_drawable, not-drawn-without-gl fails.

Tested

  • Two-copy run above, in the halo-toolchain container: the unfixed build's host dies 29.4 s in (SIGSEGV, eip 0); the fixed build's host runs to its 45 s exit_after and exits 0.
  • python3 -m pytest -q tools/harness/tests/test_hud_hires_sprites.py: 5 passed (3 cases, 2 negative controls: guard removed, guard inverted).
  • python3 -m pytest -q tools/test_linux_port.py tools/test_web_build.py tools/harness: 891 passed, 4 skipped, 0 failed.
  • CI on the fork: Linux, Android, web and Windows.

Without a GL context (debug.null_renderer, or a context that failed and
left the game running without a window) the GL functions are never
loaded. The postgame scoreboard still asked for a high-res sprite
texture, which called the NULL glGenTextures and crashed the host about
8 seconds after every game ended. A bitmap's sprites are now drawn from
the stock bitmap when the GL functions are not loaded.

Checked: two copies over loopback with HALO_NULL_RENDERER=1 and a
kicked player ending the game. The build without the change loses the
host to SIGSEGV (eip 0) 29.4 s in; with it the host runs to
debug.exit_after and exits 0. The new hud_hires_sprites harness test
runs the real hud_hires_sprites_drawable: drawn with GL loaded, not
drawn and no texture made with glGenTextures NULL; without the guard,
or with it inverted, it fails. test_linux_port.py, test_web_build.py and
tools/harness pass (891 passed, 4 skipped).
@medic-code
medic-code force-pushed the fix/null-renderer-postgame-textures branch from 0743760 to 33c00b9 Compare October 25, 2026 16:35
@VerySmuggy VerySmuggy added bug Something isn't working priority: high Should be handled soon labels Oct 26, 2026
@medic-code

Copy link
Copy Markdown
Author

Closing: #490 fixed the same crash with the xgpu_gl_ready() guards in hud_hires.c (815d3a0). On current main a null-renderer host now runs past a match end without crashing.

@medic-code medic-code closed this Oct 26, 2026
Adam-AtlasSoftware pushed a commit to Adam-AtlasSoftware/MendicantCE that referenced this pull request Nov 12, 2026
…n-tests

Count every failed assertion, and end a test's run on one (debug.fatal_asserts)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working priority: high Should be handled soon

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants