[GH-ISSUE #4713] [Issue]: Clicking topbar tabs rerenders the entire Roleplay transcript and causes input lag #2588

Closed
opened 2026-10-21 05:50:48 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @SpicyMarinara on GitHub (Aug 7, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/4713

Originally assigned to: @SpicyMarinara on GitHub.

Summary

Clicking Marinara Engine's topbar tabs while a Roleplay chat is open synchronously rerenders the entire visible transcript, causing a repeatable 400–600 ms interaction stall.

Expected behavior

Topbar tabs and side panels should open or close promptly. Unchanged Roleplay messages should retain their memoized render output and should not rerender because unrelated layout state changed.

Actual behavior

Four profiled topbar interactions blocked the content main thread for approximately 396 ms, 415 ms, 575 ms, and 588 ms. Each interaction rerendered all 80 visible ChatMessage components and approximately 638–652 message ActionBtn components.

The ChatRoleplaySurface render alone took approximately 252–447 ms per interaction. Around 95% of sampled work during the stalls was inside React's synchronous renderer (flushSyncWorkAcrossRoots_impl / performSyncWorkOnRoot).

Steps to reproduce

  1. Open a Roleplay chat with a long transcript; the captured reproduction had 80 visible/rendered messages.
  2. Click the Chats, Characters, Personas, or another topbar panel icon.
  3. Observe the delay before the panel/tab responds.
  4. Repeat between several topbar tabs; the stall occurs consistently.

Environment

  • Marinara Engine version: Not recorded in the profile
  • Install type: Source/development build, as evidenced by the React development runtime in the captured stack
  • OS + version: macOS 26.5.2, Apple M4
  • Browser or app shell: Firefox 153.0

Logs, screenshots, or video

Firefox performance profile: Firefox 2026-08-07 14.12 profile.json.gz (available from the reporter).

Profile measurements:

Interaction Main-thread block Roleplay surface render Message render total
Topbar click 1 575 ms 313 ms 245 ms
Topbar click 2 396 ms 269 ms 218 ms
Topbar click 3 588 ms 447 ms 371 ms
Topbar click 4 415 ms 252 ms 200 ms

Settings serialization appeared in only one sampled millisecond. Layout work occupied only 1–6 samples per interaction, and accessibility processing occupied no sampled CPU stacks during the blocked intervals. The accessibility and CSS-transition marker bursts appear to be consequences of the large DOM update rather than the initial cause.

Additional context

The observed render chain is:

  1. TopBar changes sidebarOpen or rightPanelOpen in the UI store.
  2. AppShell rerenders the un-memoized, no-props ChatArea.
  3. ChatRoleplaySurface also subscribes directly to both panel states.
  4. Several ChatArea message handlers depend on complete React Query mutation-result objects. Those objects are freshly wrapped on render, renewing callback props and defeating the React.memo boundary around ChatMessage.
  5. Every visible message and its action controls render again.

Prefer a small fix:

  • Isolate or memoize the no-props ChatArea boundary so unrelated shell state does not propagate into the chat tree.
  • Depend on stable mutation functions instead of complete mutation-result objects when constructing message callbacks.
  • Verify that toggling topbar tabs no longer rerenders unchanged ChatMessage components.
  • Check both a production build and the development build; the profile's development runtime amplifies the absolute duration, but the render fan-out is genuine.

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @SpicyMarinara on GitHub (Aug 7, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/4713 Originally assigned to: @SpicyMarinara on GitHub. ## Summary Clicking Marinara Engine's topbar tabs while a Roleplay chat is open synchronously rerenders the entire visible transcript, causing a repeatable 400–600 ms interaction stall. ## Expected behavior Topbar tabs and side panels should open or close promptly. Unchanged Roleplay messages should retain their memoized render output and should not rerender because unrelated layout state changed. ## Actual behavior Four profiled topbar interactions blocked the content main thread for approximately 396 ms, 415 ms, 575 ms, and 588 ms. Each interaction rerendered all 80 visible `ChatMessage` components and approximately 638–652 message `ActionBtn` components. The `ChatRoleplaySurface` render alone took approximately 252–447 ms per interaction. Around 95% of sampled work during the stalls was inside React's synchronous renderer (`flushSyncWorkAcrossRoots_impl` / `performSyncWorkOnRoot`). ## Steps to reproduce 1. Open a Roleplay chat with a long transcript; the captured reproduction had 80 visible/rendered messages. 2. Click the Chats, Characters, Personas, or another topbar panel icon. 3. Observe the delay before the panel/tab responds. 4. Repeat between several topbar tabs; the stall occurs consistently. ## Environment - Marinara Engine version: Not recorded in the profile - Install type: Source/development build, as evidenced by the React development runtime in the captured stack - OS + version: macOS 26.5.2, Apple M4 - Browser or app shell: Firefox 153.0 ## Logs, screenshots, or video Firefox performance profile: `Firefox 2026-08-07 14.12 profile.json.gz` (available from the reporter). Profile measurements: | Interaction | Main-thread block | Roleplay surface render | Message render total | | --- | ---: | ---: | ---: | | Topbar click 1 | 575 ms | 313 ms | 245 ms | | Topbar click 2 | 396 ms | 269 ms | 218 ms | | Topbar click 3 | 588 ms | 447 ms | 371 ms | | Topbar click 4 | 415 ms | 252 ms | 200 ms | Settings serialization appeared in only one sampled millisecond. Layout work occupied only 1–6 samples per interaction, and accessibility processing occupied no sampled CPU stacks during the blocked intervals. The accessibility and CSS-transition marker bursts appear to be consequences of the large DOM update rather than the initial cause. ## Additional context The observed render chain is: 1. `TopBar` changes `sidebarOpen` or `rightPanelOpen` in the UI store. 2. `AppShell` rerenders the un-memoized, no-props `ChatArea`. 3. `ChatRoleplaySurface` also subscribes directly to both panel states. 4. Several `ChatArea` message handlers depend on complete React Query mutation-result objects. Those objects are freshly wrapped on render, renewing callback props and defeating the `React.memo` boundary around `ChatMessage`. 5. Every visible message and its action controls render again. Prefer a small fix: - Isolate or memoize the no-props `ChatArea` boundary so unrelated shell state does not propagate into the chat tree. - Depend on stable mutation functions instead of complete mutation-result objects when constructing message callbacks. - Verify that toggling topbar tabs no longer rerenders unchanged `ChatMessage` components. - Check both a production build and the development build; the profile's development runtime amplifies the absolute duration, but the render fan-out is genuine. ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [x] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:50:48 +07:00
Author
Owner

@SpicyMarinara commented on GitHub (Aug 7, 2026):

Work is underway in draft PR #4717, owned by @SpicyMarinara.

<!-- gh-comment-id:5218379098 --> @SpicyMarinara commented on GitHub (Aug 7, 2026): Work is underway in draft PR #4717, owned by @SpicyMarinara.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#2588
No description provided.