Skip to content

chat: seed row height in renderElement to break ResizeObserver loop - #314882

Closed
Bryan Chen (bryanchen-d) wants to merge 3 commits into
mainfrom
brchen/chat-row-resize-loop
Closed

Bryan Chen (bryanchen-d) wants to merge 3 commits into
mainfrom
brchen/chat-row-resize-loop

Conversation

@bryanchen-d

@bryanchen-d Bryan Chen (bryanchen-d) commented May 6, 2026 •

Copy link
Copy Markdown
Collaborator

The chat row ResizeObserver callback in ChatListItemRenderer dispatched fireItemHeightChange synchronously. The downstream updateLastItemMinHeight chain writes a CSS variable that resizes a sibling row, and Chromium's RO algorithm can't redeliver same-depth resize entries inside the in-flight observation phase — so the synthetic ResizeObserver loop completed with undelivered notifications warning fires.

Telemetry attribution shipped in #314411 confirms this row observer (named ChatListItemRenderer.itemHeight) is the dominant source of the loop warning across our error stream.

Fix

Seed currentRenderedHeight synchronously at the end of renderElement, while _elementBeingRendered is still set. The existing dispatch guard in fireItemHeightChange (template.currentElement !== this._elementBeingRendered) suppresses the event fire — so the call records the row's actual mounted box size without re-entering the in-flight tree splice.

The ResizeObserver's first post-mount delivery then sees the same blockSize and hits the same-height short-circuit in fireItemHeightChange, returning without any layout-mutating work. The loop warning goes away, and currentRenderedHeight reflects the real measured height (rather than the 150-px estimate the original setTimeout(0) deferral left behind).

Validation

  • Reproduced via streaming chat responses against a long thread, captured the warning over CDP using a Playwright harness.
  • Before: ResizeObserver loop completed with undelivered notifications fires on each new request row mount and during streaming.
  • After: warning no longer fires; row heights still update during streaming with no perceptible lag.

Notes

  • This replaces the earlier setTimeout(0) + coalescing approach. That worked but had two downsides Rob flagged: it deferred the height update onto a macrotask (visible bounce), and it discarded the real first-mount measurement so currentRenderedHeight stayed pegged to the estimate.
  • The seed call is one extra synchronous read of borderBoxSize per row mount. The RO callback itself is unchanged from main.

The `ChatListItemRenderer` row ResizeObserver dispatched `fireItemHeightChange`
synchronously inside the observer callback. That re-enters layout in the same
animation frame, causing the observer to fire again, which Chromium reports as
`ResizeObserver loop completed with undelivered notifications`.

Telemetry attribution from #314411 (DisposableResizeObserver named slots) shows
this row observer is the dominant source of the warning across our 7-day error
stream.

Defer the dispatch onto the next task with `setTimeout(0)` so the observer
callback returns cleanly before the layout mutation runs. Coalesce repeated
observations into a single dispatch using the latest blockSize, and clear the
pending handle on template disposal.
Copilot AI review requested due to automatic review settings May 6, 2026 23:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR mitigates Chromium’s synthetic ResizeObserver loop completed with undelivered notifications warning in the chat list by preventing synchronous layout re-entry from the chat row ResizeObserver callback in ChatListItemRenderer.

Changes:

  • Defers fireItemHeightChange dispatch to the next macrotask via setTimeout(0) from the row ResizeObserver callback.
  • Coalesces multiple resize notifications into a single pending dispatch using the latest observed blockSize.
  • Clears any pending timeout when the template is disposed to avoid late callbacks.
Show a summary per file
File Description
src/vs/workbench/contrib/chat/browser/widget/chatListRenderer.ts Defers/coalesces row height-change dispatches from ResizeObserver to break synchronous resize/layout feedback loops.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 1

Revert the setTimeout(0) deferral in the row's ResizeObserver callback (Rob's review feedback) and instead synchronously seed currentRenderedHeight at the end of renderElement, while _elementBeingRendered is still set so fireItemHeightChange measures but does not dispatch. The RO's first post-mount delivery then hits the same-height guard and returns without firing, avoiding the 'ResizeObserver loop completed with undelivered notifications' warning that was caused by the downstream updateLastItemMinHeight chain resizing a sibling row inside the observer callback.
@bryanchen-d
Bryan Chen (bryanchen-d) force-pushed the brchen/chat-row-resize-loop branch from a6f9674 to 43366f4 Compare May 8, 2026 23:47
@bryanchen-d Bryan Chen (bryanchen-d) changed the title chat: defer chat row resize dispatch to break ResizeObserver loop chat: seed row height in renderElement to break ResizeObserver loop May 8, 2026
@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

blocks-ci screenshots changed

Replace the contents of test/componentFixtures/blocks-ci-screenshots.md with:

Updated blocks-ci-screenshots.md
<!-- auto-generated by CI — do not edit manually -->

#### editor/codeEditor/CodeEditor/Dark
![screenshot](https://hediet-screenshots.azurewebsites.net/images/67bfb687fd2818bd53771a60660541b9ed6f38b80d37da0aac15d267ecaeacec)

#### editor/codeEditor/CodeEditor/Light
![screenshot](https://hediet-screenshots.azurewebsites.net/images/0469dd8d0a587d94a1eaec514c79917b93b9a38694ef2b767bb1892819ae0a55)

#### editor/inlineChatZoneWidget/InlineChatZoneWidget/Dark
![screenshot](https://hediet-screenshots.azurewebsites.net/images/97162fc53c861ee13dc78a18e41fe3a25a42f62dc52a560510ebf084a418e1c3)

#### editor/inlineChatZoneWidget/InlineChatZoneWidget/Light
![screenshot](https://hediet-screenshots.azurewebsites.net/images/3b7e2eb5cc9ba727e2bc1c5113c3e17d8e9a6ce9a37b77519be3716ceb9a9afa)

#### editor/inlineChatZoneWidget/InlineChatZoneWidgetTerminated/Dark
![screenshot](https://hediet-screenshots.azurewebsites.net/images/97162fc53c861ee13dc78a18e41fe3a25a42f62dc52a560510ebf084a418e1c3)

#### editor/inlineChatZoneWidget/InlineChatZoneWidgetTerminated/Light
![screenshot](https://hediet-screenshots.azurewebsites.net/images/3b7e2eb5cc9ba727e2bc1c5113c3e17d8e9a6ce9a37b77519be3716ceb9a9afa)

@roblourens

Copy link
Copy Markdown
Member

Something else to look into- when this error is triggered and I hit a breakpoint at

return `[DisposableResizeObserver(${observer.name})] ${message}`;
, I don't see that error anywhere in the Window output channel or the devtools console. Can you look into why that is? I know I've seen it somewhere before. We should make sure we have that visibility into errors.

@bryanchen-d

Copy link
Copy Markdown
Collaborator Author

Something else to look into- when this error is triggered and I hit a breakpoint at

return `[DisposableResizeObserver(${observer.name})] ${message}`;

, I don't see that error anywhere in the Window output channel or the devtools console. Can you look into why that is? I know I've seen it somewhere before. We should make sure we have that visibility into errors.

The RO error is sent via window.onerror which is not hooked to the workbench's output channel.

In devtools console, it is under the 'verbose' level, I just checked that it shows up if you turn on All Levels.

@roblourens

Copy link
Copy Markdown
Member

In devtools console, it is under the 'verbose' level, I just checked that it shows up if you turn on All Levels.

Oh interesting, thanks

@roblourens

Copy link
Copy Markdown
Member

This change would add another forced re-layout at a time when we don't necessarily need to know the size, so I don't think we should do that. Here's another suggestion #315486. This would let us initialize the currentRenderedHeight at the time when we already get the size, but avoid triggering other work (because the height did not change, it only got its initial measurement). What do you think?

roblourens added a commit that referenced this pull request May 11, 2026
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Jun 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants