Skip to content

Bound debug overlay draw counts to avoid resource crashes - #2105

Open
sunzenshen wants to merge 2 commits into
NeotokyoRebuild:masterfrom
sunzenshen:bot-nb_debug-high-capacity-crash
Open

Bound debug overlay draw counts to avoid resource crashes#2105
sunzenshen wants to merge 2 commits into
NeotokyoRebuild:masterfrom
sunzenshen:bot-nb_debug-high-capacity-crash

Conversation

@sunzenshen

Copy link
Copy Markdown
Contributor

Description

In order to prevent the game from crashing when nb_debug is displaying debug overlays for a large number of bots on a large map, bound the number of draw counts that can appear at a time via a ConVar. This has the side effect of causing flickering of alternating debug overlay draws between bots, but the justification is that it's better to see periodically the debug overlays per bot, rather than to not have the options because the game would crash trying to render all debug overlays.

Toolchain

  • Windows MSVC VS2022

Linked Issues

@sunzenshen
sunzenshen requested a review from a team August 31, 2026 05:41
@sunzenshen sunzenshen added the Bots Related to bot players label Aug 31, 2026

@sunzenshen sunzenshen left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stress test demo of 31 bots on a wide open map, while changing between nb_debug modes:

https://streamable.com/ypau0r

The side effect is that debug draws are rejected near the limit, which causes flickering, but I'd rather have some visibility into something like paths than to not have the option because of a hard crash.

// Wrap the engine's debug overlay interface and return the pointer game code
// should use. A NULL input (a dedicated server has no debug overlay) returns
// NULL, so existing "if ( debugoverlay )" checks keep working.
IVDebugOverlay *NEO_InstallDebugOverlayBudget( IVDebugOverlay *pReal );

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Under the hood, use a proxy pattern to drop draws when the flow of overlay draws is starting to exceed the ConVar defined budget neo_debugoverlay_budget.

if ( (debugoverlay = NEO_InstallDebugOverlayBudget( (IVDebugOverlay *)appSystemFactory( VDEBUG_OVERLAY_INTERFACE_VERSION, NULL ) )) == NULL )
return false;
#else
if ( (debugoverlay = (IVDebugOverlay *)appSystemFactory( VDEBUG_OVERLAY_INTERFACE_VERSION, NULL )) == NULL )

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My pitch for this approach is that we only need to wrap debugoverlay at a few initialization sites, and we can handle custom changes in the new proxy class.

@Rainyan Rainyan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, tested with launch arg -maxplayers 32 and cmd neo_bot_quota 32; nb_debug PATH; as in the ntre_engage_ctg example case and can verify this fixes the crash.

@Rainyan
Rainyan requested a review from a team September 1, 2026 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bots Related to bot players

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nb_debug * crashes the game at high bot numbers

2 participants