Skip to content

fix(app): break ResizeObserver feedback loop in composer docks - #50104

Closed
Lightningxxl wants to merge 1 commit into
anomalyco:devfrom
Lightningxxl:perf/renderer-ro-guard
Closed

Lightningxxl wants to merge 1 commit into
anomalyco:devfrom
Lightningxxl:perf/renderer-ro-guard

Conversation

@Lightningxxl

@Lightningxxl Lightningxxl commented Sep 20, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #38296
Refs #43355, #33712. The streaming-side cost (#49552) is a separate concern and is intentionally not in this PR.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The Desktop renderer burns ~76% CPU at idle because composer-dock ResizeObserver callbacks measure height and synchronously write the parent max-height/margin in the same frame (useSpring-driven), re-triggering observation every frame. It's a self-sustaining layout thrash that floods renderer.log with "ResizeObserver loop completed" errors. On a real 2d5h session: renderer 40h CPU / 53h uptime, 93% of the 1416 RO errors landed in minutes with zero streaming activity, and the storm returns 26s after a relaunch.

Fix: defer the four composer-dock RO callbacks (region controller, todo dock, question dock, and the session.tsx promptDock amplifier) to rAF and ignore <1px deltas, so a measure->write cycle can't re-trigger observation within the same frame. Rendered output is unchanged (sub-pixel deltas aren't visible; rAF matches render timing) — only the redundant same-frame layout work is removed. No visual or product change, no animations touched.

How did you verify your code works?

  • Applied cleanly to a fresh checkout of dev; tsgo -b (packages/app typecheck) passes.
  • The attribution numbers above come from correlating renderer.log against the server log on a real session.
  • Local testing here = clean apply + typecheck + code review; a runtime idle-CPU drop measurement and a no-visual-diff check are the follow-up confirmation I'd like reviewer eyes on.

Screenshots / recordings

N/A — perf-only change, no visual difference intended.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Defer composer-dock ResizeObserver callbacks to rAF and ignore sub-pixel
size deltas so the measure->write-max-height cycle can no longer re-trigger
observation within the same frame. Removes the self-sustaining idle layout
thrash (renderer ~76% sustained CPU, ResizeObserver error storm) without
changing rendered output.

Refs anomalyco#38296 anomalyco#43355 anomalyco#33712
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Sep 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@github-actions github-actions Bot removed needs:issue needs:compliance This means the issue will auto-close after 2 hours. labels Sep 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@thdxr

thdxr commented Oct 10, 2026

Copy link
Copy Markdown
Member

This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2.

— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

@thdxr thdxr closed this Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Electron renderer unresponsive / crash due to ResizeObserver loop storm (layout thrashing)

2 participants