Attach the run time sampler after the game's tree finishes setting up #323
No reviewers
Labels
No labels
4-29
bug
documentation
duplicate
enhancement
flow improvement
good first issue
help wanted
invalid
investigating
issue-agent
issue-agent-blocked
issue-agent-complete
issue-agent-pr-open
issue-agent-runner-nelsonlaptop
issue-agent-runner-nelsonpc
issue-agent-runner-nelsonpc-user
issue-agent-running
needs-verification
next to do
question
queue
recon
relics-stats-onboarding
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
romaine-life/spirelens!323
Loading…
Reference in a new issue
No description provided.
Delete branch "claude/kind-ishizaka-511611"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
RunTimeStatsTracker.Initialize()calledtree.Root.AddChild(timer)directly fromCoreMain.Initialize(). On a cold start that runs from insideNGame._EnterTree→GameStartupWrapper→GameStartup→OneTimeInitialization.ExecuteVeryEarly→ModManager→ our[ModInitializer], and Godot refusesadd_childon a node still setting up its own children:Why it was invisible
The refusal is a printed native
ERR_FAIL, not a managed exception, so the surrounding try/catch never fired andCore.Initialize completewas still logged one line later. The timer was left parentless — never in the tree, never_ready, never emittingTimeout.RunTimeStatsTracker.Initialize()has exactly one caller, so nothing re-attached it: the sampler was dead for the whole process on every real play session. A hot reload re-runsInitializelong after_EnterTreereturned, which is why only dev sessions ever had a working one.What players lost
RunTimerStatsTooltip.EnsureLiveTargetis a no-op atInitializetime (the top bar does not exist yet) and its only retry is the sampler tick.SampleRunTimeStatscallers were combat boundaries; since each sample bills elapsed time to the previously recorded surface, everything between one combat ending and the next starting landed inreward_screen_secondswhilemap_secondsandevent_secondsnever left zero.The fix
The attach goes through
CallDeferred, matchingLoaderMain.AttachInputListenerandHotReloadToast.Show. The deferred callback re-checks instance validity, that the timer is still the current one, and that it has no parent, so anInitialize/Shutdownpair inside one frame cannot resurrect a sampler the previous Core tore down. It logs on success so the cold-start path is provable fromgodot.logwithout debug logging.Audit of the other
CoreMain.Initialize()stepsNo other change needed — only unconditional node creation is exposed. Every
Reinject*locates an existing live screen and no-ops when it finds none (always, on a cold start);InitializeHookssubscribes to singletons that already exist that early;TryResumeActiveRunsees a nullRunStateand defers to the laterRunStartedadopt path;StatConceptGlossaryonly needsres://, which is available. The new primer section sits next to theModelDbvariant from #321, since both come from the same too-early[ModInitializer]call.Validation
Built, deployed, and hot-reloaded into the running game:
Patch install: 432 classes patched, 0 failed/skipped,Core.Initialize complete, thenRun time sampler attached (1s tick, deferred add_child)on the following idle frame. No persisted fields changed, so no schema fixture applies. Tests and behavioral verification were not run, per the repo's user-owned verification rule.