RynthSuite as of 2026-12-02 (internal 152e13d): release 2026.12.1.1

This commit is contained in:
Tom Bohar 2026-12-02 06:45:07 -05:00
commit 6b5a9c7e99
65 changed files with 3920 additions and 237 deletions

View file

@ -107,6 +107,7 @@ namespace RynthLua.ScriptWindowsTests
Run("engine parser: truncated, bit-flipped and random submits", ParserFuzz);
Run("events into results", Events);
Run("Lua: Phase 0 imgui functions and the bench", LuaBench);
Run("Lua: hud passes reuse one worker coroutine", HudPassWorkers);
Run("Lua: every MVP imgui function, with events", LuaMvpFunctions);
Run("Lua: SetNextWindow* by ImGuiCond", LuaWindowCalls);
Run("Lua: errors (unsupported, refused, outside a pass)", LuaErrors);
@ -835,6 +836,70 @@ namespace RynthLua.ScriptWindowsTests
Check(msg.Type == DataType.String && msg.String.Contains("only work inside a hud's OnRender"), "ImGui outside a pass: " + msg.ToPrintString());
}
/// <summary>
/// Hud passes run on pooled worker coroutines (LuaScriptHost): a new MoonSharp coroutine is
/// ~1 MB, and a pass every 50 ms made one each time (2026-11-30: a script's 20/s window,
/// then a script stopped by the memory guard). 50 good passes take one worker; a pass
/// that runs too long, sleeps or errors drops its worker, and the next good pass still draws.
/// </summary>
private static void HudPassWorkers()
{
var plugin = new RynthLuaPlugin();
ScriptHud? hud = null;
var host = new LuaScriptHost(_ => { }, (s, h) => LibraryImGuiValues.Register(s));
var ctx = new ScriptContext("hud-workers", null, string.Empty, new ScriptManifest(), host);
hud = new ScriptHud(ctx, "Bench", "RynthLua/hud-workers/Bench", ctx.Event("Hud:Bench:OnRender"), ctx.Event("Hud:Bench:OnPreRender"));
HudsByHash(plugin)[hud.Hash] = hud;
Huds(plugin).Add(hud);
host.ResolveModule = (s, name) =>
{
if (name == "imgui") return CreateImGuiModule(plugin, s);
if (name != "views") return null;
var fake = new Table(s);
fake["OnRender"] = hud.OnRender.CreateTable(s);
var huds = new Table(s);
huds["CreateHud"] = DynValue.NewCallback((c, a) => DynValue.NewTable(fake));
var views = new Table(s);
views["Huds"] = DynValue.NewTable(huds);
return DynValue.NewTable(views);
};
host.Run(@"
local ImGui = require('imgui'); local views = require('views')
mode, passes = 'ok', 0
views.Huds.CreateHud('Bench').OnRender.Add(function()
passes = passes + 1
if mode == 'long' then local x = 0 for i = 1, 10000000 do x = x + i end end
if mode == 'sleep' then sleep(10) end
if mode == 'error' then error('bad pass') end
ImGui.Text('pass ' .. passes)
end)", "hud-workers");
host.Tick(System.Diagnostics.Stopwatch.GetTimestamp() + System.Diagnostics.Stopwatch.Frequency);
Check(host.Loaded, "script loaded: " + host.ConsoleText());
int made0 = host.WorkersCreated;
long alloc0 = GC.GetAllocatedBytesForCurrentThread();
for (int i = 0; i < 50; i++) RunPass(plugin, hud);
long allocMb = (GC.GetAllocatedBytesForCurrentThread() - alloc0) >> 20;
Check(hud.LastError == null, "50 passes ok: " + hud.LastError);
Check(host.WorkersCreated - made0 <= 1, $"50 passes, {host.WorkersCreated - made0} new worker(s)");
Check(allocMb < 40, $"50 passes allocated {allocMb} MB (a coroutine each was ~100 MB in a 64-bit test)");
foreach (string bad in new[] { "long", "sleep", "error" })
{
host.Lua!.Globals["mode"] = bad;
RunPass(plugin, hud);
Check(hud.LastError != null, $"{bad} pass fails: {hud.LastError}");
host.Lua!.Globals["mode"] = "ok";
RunPass(plugin, hud);
DisplayList l = ParseOne(hud);
double n = host.Lua!.Globals.Get("passes").Number;
Check(hud.LastError == null && l.OpCount > 0 && S(l, l.Ops[0].Str, l.Ops[0].StrLen) == "pass " + n,
$"after a {bad} pass the next one draws 'pass {n}': {hud.LastError}");
}
Check(host.Loaded, "still running");
host.Stop();
}
// ── Lua harness for the imgui module ────────────────────────────
private sealed class LuaHud