Skip to content

telemetry: report ResizeObserver delivery context - #328065

Merged
Bryan Chen (bryanchen-d) merged 2 commits into
mainfrom
copilot/vscode/resize-observer-phase-context
Jul 29, 2026
Merged

Bryan Chen (bryanchen-d) merged 2 commits into
mainfrom
copilot/vscode/resize-observer-phase-context

Conversation

@bryanchen-d

@bryanchen-d Bryan Chen (bryanchen-d) commented Jul 29, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

VS Code currently rewrites Chromium's stackless ResizeObserver loop completed with undelivered notifications warning with the name of the most recently invoked DisposableResizeObserver:

_lastInvokedDisposableResizeObserver = this;

The telemetry comments call that observer the "offending consumer," but callback order is not causality. A callback can mutate a different observed target, and an unrelated observer can run last before the browser dispatches the warning. This is how a real cross-observer virtualized-row lifecycle bug was attributed to both ChatInputPart.containerHeight and ChatListItemRenderer.itemHeight.

The browser cannot provide the missing answer after the fact. Per the ResizeObserver processing model, skipped targets stay in internal [[skippedTargets]]; Deliver Resize Loop Error creates an ErrorEvent with only the generic message. No observer, target, or causative callback is exposed to JavaScript.

Change

Replace false causal attribution with honest delivery context:

[ResizeObserverLoopContext(A,B)]
  • records every distinct wrapped observer that ran in the current rendering frame;
  • scopes state per CodeWindow, because auxiliary windows have independent documents and delivery loops;
  • sorts names so callback order does not fragment equivalent buckets;
  • bounds context to the lexicographically smallest 8 names plus <overflow> so output is deterministic and finite;
  • clears at the next animation frame, after Blink has dispatched any loop warning from the current rendering update;
  • keeps the ResizeObserverLoopContext wrapper as the explicit non-causal label.

Only DisposableResizeObserver consumers are included; raw ResizeObserver consumers remain outside this context.

This changes the bucket shape on purpose. Existing per-last-callback buckets should not be interpreted as component failure rates.

Verification

  • npm run typecheck-client — passes.
  • scripts/test.bat --grep "DisposableResizeObserver" — 10 passing:
    • synchronous delivery remains unchanged;
    • names are sorted and deduplicated;
    • overflow is canonical even when callbacks arrive in reverse order;
    • state is isolated per window;
    • state clears at the next animation frame.
  • New real Chromium component fixture deliberately resizes its own observed target. Playwright asserts the browser-generated loop warning still sees:
[ResizeObserverLoopContext(ResizeObserverContextFixture.selfResizer)]

The fixture stops observation on the first warning so it cannot leak or spin.

  • Independent code review: no significant issues.

Follow-up

This PR makes the cheap signal truthful; it does not claim to recover exact causality. A separate sampled diagnostic can trace callback → changed observed-target geometry/connectivity edges after the first warning. That work needs coverage/confidence gates and should not be mixed into the stable error bucket change.

Related: #293359, #316509, #316501, #327933.

The browser's ResizeObserver loop ErrorEvent contains only a generic message; it does not expose the skipped target or causative callback. Prefixing that warning with the most recently invoked DisposableResizeObserver therefore turned callback order into false causal attribution.

Record the wrapped observers that ran in the current rendering frame instead. Context is scoped per window, deduplicated, sorted for stable bucketing, and bounded to the canonical smallest eight names plus an overflow marker. The telemetry prefix explicitly calls these recent wrapped observers rather than an offending consumer.

Clear context at the next animation frame, after Blink dispatches any loop warning from the current rendering update. Unit coverage locks deduplication, canonical overflow, window isolation, and frame cleanup; a real Chromium component fixture deliberately triggers a self-resize loop and verifies context survives until the native warning.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: aacd276e-cf84-48bd-a2ab-6f6a4d4c3431
Copilot AI review requested due to automatic review settings July 29, 2026 18:33

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

Replaces misleading ResizeObserver causal attribution with deterministic, per-window delivery context.

Changes:

  • Tracks up to eight sorted, distinct wrapped observers per rendering frame.
  • Updates telemetry to report observer context rather than the last callback.
  • Adds unit and Chromium fixture coverage.
Show a summary per file
File Description
src/vs/base/browser/dom.ts Implements bounded per-window observer context.
src/vs/base/test/browser/dom.test.ts Tests sorting, deduplication, overflow, isolation, and clearing.
src/vs/platform/telemetry/browser/errorTelemetry.ts Reports the new context in error telemetry.
src/vs/workbench/test/browser/componentFixtures/resizeObserver.fixture.ts Adds a real ResizeObserver loop probe.
src/vs/workbench/test/browser/componentFixtures/chat/chatWidget.fixture.ts Exposes observer context in the chat harness.
test/componentFixtures/playwright/tests/resizeObserverContext.spec.ts Verifies context survives through browser warning dispatch.
test/componentFixtures/playwright/tests/chatResizeObserver.spec.ts Updates diagnostic logging for the new context.

Review details

  • Files reviewed: 7/7 changed files
  • Comments generated: 0
  • Review effort level: Medium

ResizeObserverLoopContext already identifies the observer names as non-causal context, so remove the redundant 
ecentWrappedObservers= label from the emitted error string.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: aacd276e-cf84-48bd-a2ab-6f6a4d4c3431
@bryanchen-d
Bryan Chen (bryanchen-d) merged commit 15fc669 into main Jul 29, 2026
29 checks passed
@bryanchen-d
Bryan Chen (bryanchen-d) deleted the copilot/vscode/resize-observer-phase-context branch July 29, 2026 22:53
@vs-code-engineering vs-code-engineering Bot added this to the 1.132.0 milestone Jul 29, 2026
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Sep 12, 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