coder / coder/balatrobot

fix!: long sessions degrade — latency triples, then discard crashes on nil G.buttons

Open
#235 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
72
Forks
18
PR merge metrics
No merged PRs in 30d

Description

## Description

After ~70 consecutive games on one instance (menu+start between games), we
observed two stages of degradation:

1. Per-action latency roughly **tripled** relative to a fresh instance.
2. The `discard` endpoint then began crashing on **every** game:

```
discard.lua:91: attempt to index field 'buttons' (a nil value)
```

`src/lua/endpoints/discard.lua:91` does
`UIBox:get_UIE_by_ID("discard_button", G.buttons.UIRoot)` with no nil guard —
under the degraded latency the endpoint fires while the dealt hand is still
animating and `G.buttons` hasn't been built yet.

Six consecutive seeds hit the crash at the end of one long campaign; the same
seeds ran clean on a fresh instance, so this is accumulation, not game content.
Likely the same underlying accumulation as coder/balatrollm#29 (game slowdown
after many rounds).

## Impact

Long benchmark campaigns quietly slow down and then start failing runs for
reasons unrelated to the bot under test. Because balatrollm's executor starts
its instances once and cycles the whole task list through them, a large
multi-model campaign is exactly the workload that ages into this state.

## Suggested Fix

- In `discard.lua` (and `play.lua`, which shares the button-lookup pattern),
wait for the button via a condition event instead of asserting on a structure
that may not exist yet mid-animation.
- Consider recycling instances every N runs for long campaigns (we restart the
game between 80-seed batches and never see either symptom).

Contributor guide

Open the contributing guide

Research direction

Start in src/lua/endpoints/discard.lua at line 91 and compare its button lookup with the corresponding pattern in play.lua. Reproduce a long campaign using the reported consecutive seeds, then verify that discard no longer crashes during animation and that latency does not degrade across the campaign.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.