Severe FPS drop & stutter in LUA maps using .ai scripts

Summary; Severe FPS drops and massive stuttering occur during the late-game in Blizzard melee maps when the script language is set to LUA and it interacts with custom .ai scripts (Warcraft 3 .ai files can only be written in JASS syntax). This issue does not occur if the exact same melee map is switched to JASS.

-=————–

Hello, I encountered this bug as someone focused on making custom .ai scripts for Blizzard Melee maps. This involves adding more optimal build orders to the default Blizzard AIs simply by editing the common.ai, human.ai, orc.ai, Elf.ai and Undeads.ai files and injecting them into a Blizzard melee map; so they can, for example, be more aggressive, buy items efficiently, or use multiple strategies to counter the opponent, expand properly, and better utilize resources.

The issue is that I have found a critical performance bottleneck in melee maps that are set to LUA. As the match progresses into the late-game and the AI increases its military operations (generating a high density of temporary points, unit groups, and evaluations), the engine suffers from severe micro-stuttering and massive FPS drops (in maps with more than 12 players, it can drop to 1 FPS with zero recovery). It behaves as if memory leaks are accumulating until reaching a critical point of total collapse; however, this does not happen at all if those same melee maps are set to JASS.

Here I detail the tests I conducted to verify this:

1— For testing purposes, I duplicated 3 melee maps ([12]Icecrown, [12]EmeraldGardens, and a 15-player melee map from HIVE), separating them into a LUA version and a JASS version. The mentioned maps are standard melee, use “Melee Initialization,” and have no additional code added or edited by me; they are simply normal melee maps running improved .ai scripts. When running the exact same normal melee map and the same .ai script under a JASS environment, the performance remains perfectly stable, as the engine seemingly clears the memory from the .ai actions natively.

2——- Now testing the exact same maps but in LUA: at the beginning, everything works fine with normal FPS. However, as the minutes pass, the performance degrades terribly and does not recover even after the match ends or all enemy units are destroyed. This indicates a clear data accumulation that is producing these stutters (in the 15-player melee map, the game didn’t even finish and collapsed to 1 FPS during the mid-game).

3—My hardware is highend (Ryzen 9 5900x + RTX 3070 + 32GB RAM + updt Nvidia drivers + Windows 11), which tells me that LUA-type melee maps are failing to clean up the references left behind by .ai scripts.

Currently, this makes the development of LUA maps utilizing custom AI scripts completely unviable, as they suffer from data accumulations that won’t be cleared, creating a snowball effect.

Video 1: Melee Map Bug Custom Script .ia - LUA (midgame)

Video 2: Same Melee Map Custom Script .ia - JASS