mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #4659] Roleplay streaming replaces its text node every frame, causing Firefox render churn #2552
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#2552
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 @SpicyMarinara on GitHub (Aug 5, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/4659
Originally assigned to: @SpicyMarinara on GitHub.
Summary
Roleplay responses can stream slightly less smoothly in Firefox. Profiling points to the lightweight live-stream renderer replacing the complete text child on every animation-frame update through
element.textContent = next.This path was introduced in commit
40206d1dato avoid rebuildingChatMessagethrough React for every character. It succeeds at bypassing React, but assigningtextContentremoves and recreates the underlyingTextnode, which causes repeated accessibility, style, layout, and paint work.Expected behavior
Roleplay output should reveal at a steady frame-paced cadence without replacing DOM children, repeatedly rebuilding the Firefox accessibility subtree, or forcing avoidable layout work.
Actual behavior
An 8.9-second Firefox profile recorded during Roleplay streaming showed:
Firefox Inspector and its Compatibility panel were open during the capture. They amplified the problem by reacting to each child replacement: the profile contains 1,167 DOM-walker child queries and 1,167 CSS compatibility scans, with approximately 1.94 seconds of sampled main-thread CPU inside
getNodeCssIssues. The capture also used a React development build, so the absolute timings are not representative of production, but the repeated node replacement is visible independently of that overhead.A separate state update during the capture rerendered the complete mounted transcript: 60
ChatMessagecomponents and 493 action buttons in approximately 375 ms. Streaming auto-follow also readsscrollHeightand callsscrollToat animation-frame cadence, adding layout pressure while the text grows.Steps to reproduce
Environment
stagingLogs, screenshots, or video
The profile used a 1 ms sampling interval and covered approximately 8.9 seconds of active Roleplay streaming. The relevant implementation is
RoleplayLiveStreamTextinpackages/client/src/components/chat/ChatRoleplaySurface.tsx.Related secondary paths:
packages/client/src/components/chat/ChatArea.tsx.packages/client/src/components/chat/ChatArea.tsx.packages/client/src/components/chat/EchoChamberPanel.tsx.Additional context
A small initial fix should retain one
Textnode for the lifetime of the live row and update its.data, or append only the new suffix withappendData, rather than assigningtextContentto the parent span on every frame. Full-buffer rewrites, regeneration resets, and chat switching still need to replace the text data correctly.After that change, re-profile a production build with Firefox Inspector closed. If a visible hitch remains, separately isolate transcript-wide rerenders and coalesce stream auto-scroll measurement and writing to one operation per frame.
Template check