mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #3104] [Issue]: Severe client freeze (multi-second main-thread blocks, GPU spikes) on chats using the world-state / character-tracker agents #1664
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#1664
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Originally created by @kolacheee on GitHub (Jun 30, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3104
Originally assigned to: @SpicyMarinara, @kolacheee on GitHub.
What's wrong
Opening a chat that uses the world-state and/or character-tracker agents puts the client into a severe main-thread freeze: interactions take tens of seconds, the GPU spikes, and the tab is effectively unresponsive ("memory-leak vibes"). It is reported in all chat modes (Conversation, Roleplay, and Game), only on chats that ran these agents, and it stops the moment you navigate to home, a new chat, or a chat that did not use those agents. It is worst on older chats (created/used on earlier versions) that have accumulated a lot of tracked-character / world-state data.
This is a client-side problem (the browser main thread is blocked), not slow generation — it happens while the chat just sits open, and clears when you leave the chat.
How to reproduce (try it yourself)
You'll see: each interaction takes many seconds to tens of seconds; the GPU revs; deleting/replying causes a heavy momentary freeze. Navigating to the home page or a non-agent chat makes it instantly responsive again.
Evidence captured from affected users (DevTools)
pointerinteractions: one115,472 ms(input delay 69,013 ms, processing 46,411 ms), one188,848 ms(input delay 49,009 ms, processing 46,607 ms, presentation 93,233 ms). The ~46 s processing + ~49–69 s input delay mean the main thread is doing ~46 s synchronous chunks of work back-to-back.TrackerDataSidebar(~175 kB),RoleplayHUD(~29 kB),world-state-display(~12 kB),TrackerSizeTierIcon— i.e. the tracker-panel / world-state UI.Where it is (localized — see confidence note below)
The hotspot is the tracker-panel feature that renders the world-state / character-tracker agent output. It mounts only when those agents are active (which is why the lag tracks "chats with agents" across all modes, and clears on chats without them):
packages/client/src/features/tracker-panel/components/TrackerDataSidebar.tsx,TrackerSectionList.tsx,components/sections/WorldStatePanel.tsx,components/character-card/CharacterTrackerCard.tsx, andpackages/client/src/components/chat/RoleplayHUD.tsx— the components in the lazy chunks above.packages/client/src/features/tracker-panel/hooks/use-tracker-sprite-lookup.ts:16-49callsuseCharacters()(the entire library) and then mapsparseCharacterDisplayData(character)over every character row to build a name→id lookup — even though only the chat's tracked characters are rendered.packages/client/src/features/tracker-panel/hooks/use-tracker-panel-model.ts:70likewise loads all personas. For a library of hundreds of cards, building that lookup is an O(library) JSON-parse pass that re-runs whenever the character-list reference changes.components/sections/CharacterTrackerPanel.tsx:76maps aCharacterTrackerCardper present character; old chats accumulate many present characters.What's happening (leading mechanism)
A chat with the world-state/character-tracker agents mounts the tracker panel, which (a) loads and parses the entire character + persona library to build sprite/name lookups it only needs the chat's characters for, and (b) renders a card per accumulated tracked character. The cost scales with library size × tracked-character count, both of which are large for long-lived older chats on big installs — producing the ~46 s synchronous main-thread blocks. Because the panel re-renders on every gameState/agent update and on edits, the freeze recurs continuously while the chat is open.
Ruled out (investigated and excluded, so reviewers don't re-chase them):
{{agent::TYPE}}is a terminal flat substitution placed after all macro passes); stored tracker text is never re-run throughresolveMacros.resolveCurrentGameSessionChatId) — it early-returns for non-game chats, so it cannot affect Conversation/Roleplay.MAX_MACRO_EXPANSIONS.Suggested direction
features/tracker-panel/**.use-tracker-sprite-lookupto the chat's characters instead of parsing the whole library; memoize/virtualize the tracked-character card list; avoid re-parsing character cards on every list-reference change; and bound work to the number of present characters actually rendered.Confidence note
This is a localization, not a pinned root-cause line. The evidence (the loaded tracker chunks, the INP breakdown, the whole-library parse in
use-tracker-sprite-lookup, and the symptom matrix) strongly points at the tracker-panel render, but the single exact O(n) frame should be confirmed with a Bottom-Up profile or a local repro (a chat with the character-tracker/world-state agents and many accumulated present characters on a large-library install) before fixing.AI-investigated against v2.0.8 (
main). Symptom data from affected users' DevTools (INP/Network); code paths read and cited. The exact hot function is not yet pinned — please capture a Bottom-Up profile or reproduce locally to confirm before fixing.@SpicyMarinara commented on GitHub (Jun 30, 2026):
Is this still happening on staging?
@kolacheee commented on GitHub (Jun 30, 2026):
I hadn't checked yet personally but good to keep this up in case users still report the issue in staging
@SpicyMarinara commented on GitHub (Jun 30, 2026):
Still happening on staging.
@kolacheee commented on GitHub (Jun 30, 2026):
Opened a draft diagnostic PR toward this: #3111.
It adds self-gating render-timing + long-task warnings (silent in normal use) so an affected user can pin the exact slow subtree by just opening the laggy chat and reporting the
[mari-perf]console line (e.g.[mari-perf] tracker-panel render+commit took 46180ms). That names the fix target so the follow-up PR is the real fix rather than a guess. Targetsstaging; meant to be reverted once the frame is identified.@SpicyMarinara commented on GitHub (Jun 30, 2026):
Codex is taking this now on branch codex/3104-tracker-panel-freeze. Draft PR will track the fix while I narrow the tracker-panel hot path and keep the patch scoped.
@SpicyMarinara commented on GitHub (Jun 30, 2026):
Addressed, but not closing yet, until getting confirmation the issue was fixed.
@SpicyMarinara commented on GitHub (Jul 2, 2026):
Closing now that the staged perf work has landed across the tracker/render-scope/macro follow-ups, including PRs #3111, #3112, #3113, #3115, and #3118.