mirror of
https://github.com/nesquena/hermes-webui.git
synced 2026-05-24 18:50:15 +00:00
0217bf5cce
_scheduleRender() uses requestAnimationFrame to update the live assistant message during streaming. rAF fires at up to 60fps, but each DOM update takes 50-150ms on sessions with long histories — far exceeding the 16ms rAF budget. During GC pauses (which can run for hundreds of milliseconds), rAF callbacks accumulate. When the GC yields, the browser executes all queued callbacks sequentially in a single RunTask. A Chrome performance trace shows a 13.6-second RunTask containing 1,240 accumulated render callbacks — which causes the renderer to crash (Chrome error codes 4/5, ERR_EMPTY_RESPONSE / ERR_CONNECTION_RESET). Fix: track the last render timestamp and delay scheduling the next rAF until at least 66ms (15fps) have elapsed since the previous render. If within the 66ms window, use setTimeout to defer the rAF rather than skipping it — this batches token updates without dropping any content. The 66ms interval is conservative enough to prevent runaway accumulation while fast enough that streaming text still feels immediate. The _renderPending flag continues to prevent double-scheduling within each interval. Co-authored with Claude Sonnet 4.6 / Anthropic.