Skip to content

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

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

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

Conversation

@medic-code

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

Copy link
Copy Markdown
Owner

Problem

A game run without a GL context (HALO_NULL_RENDERER=1, or a context that failed and fell back to running without a window) crashes the host about 8 seconds after every game ends: SIGSEGV at address 0. CI journeys and harness runs that play a game to its end lose the host at every game end.

Players are not affected: with no window there is no game to play.

The postgame scoreboard draws its icons through hud_hires_sprites_drawable, which decodes the high-res texture and calls glGenTextures. The GL function pointers are filled only when a context exists (gl_initialize, d3d8_gl.c), so glGenTextures is NULL.

Solution

  • hud_hires_sprites_drawable returns 0 when the GL functions are not loaded, so the scoreboard draws the stock bitmap.
  • With a context, nothing changes.

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 869d3c4 to 0743760 Compare October 25, 2026 07:09
@medic-code

Copy link
Copy Markdown
Owner Author

Opened upstream as OpenCommunityEdition#483.

@medic-code medic-code closed this Oct 25, 2026
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