Repository navigation
chat: seed row height in renderElement to break ResizeObserver loop - #314882
Bryan Chen (bryanchen-d) wants to merge 3 commits into
Conversation
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.
There was a problem hiding this comment.
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
fireItemHeightChangedispatch to the next macrotask viasetTimeout(0)from the rowResizeObservercallback. - 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.
a6f9674 to
43366f4
Compare
blocks-ci screenshots changedReplace the contents of Updated blocks-ci-screenshots.md<!-- auto-generated by CI — do not edit manually -->
#### editor/codeEditor/CodeEditor/Dark

#### editor/codeEditor/CodeEditor/Light

#### editor/inlineChatZoneWidget/InlineChatZoneWidget/Dark

#### editor/inlineChatZoneWidget/InlineChatZoneWidget/Light

#### editor/inlineChatZoneWidget/InlineChatZoneWidgetTerminated/Dark

#### editor/inlineChatZoneWidget/InlineChatZoneWidgetTerminated/Light
 |
|
Something else to look into- when this error is triggered and I hit a breakpoint at vscode/src/vs/base/browser/dom.ts Line 2156 in 7cf776a |
The RO error is sent via 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 |
|
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 |
The chat row
ResizeObservercallback inChatListItemRendererdispatchedfireItemHeightChangesynchronously. The downstreamupdateLastItemMinHeightchain 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 syntheticResizeObserver loop completed with undelivered notificationswarning 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
currentRenderedHeightsynchronously at the end ofrenderElement, while_elementBeingRenderedis still set. The existing dispatch guard infireItemHeightChange(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, andcurrentRenderedHeightreflects the real measured height (rather than the 150-px estimate the originalsetTimeout(0)deferral left behind).Validation
ResizeObserver loop completed with undelivered notificationsfires on each new request row mount and during streaming.Notes
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 socurrentRenderedHeightstayed pegged to the estimate.borderBoxSizeper row mount. The RO callback itself is unchanged frommain.