Repository navigation
fix(shell): release the preview frame growth breaker once the renderer's reports settle - #258
Merged
mikzat merged 3 commits intoOct 16, 2026
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors the growth circuit breaker logic in RenderedFrame to introduce a more robust hold-and-release mechanism, preventing false positives from legitimate growth (such as CSS transitions) by holding the frame temporarily and verifying if the guest settles. It also adds comprehensive unit tests to cover these new behaviors. A critical issue was identified in resetGrowthRun() where the settleTimer is not cleared, potentially leading to state corruption and incorrect loop confirmations when new content is loaded.
Contributor
⚡ A2UI Composer PR PreviewYour automated preview is successfully live (commit
|
mikzat
force-pushed
the
fix/release-growth-breaker-on-settle
branch
from
October 8, 2026 17:24
27a74fd to
12a77bd
Compare
mikzat
marked this pull request as ready for review
October 8, 2026 17:38
…r's reports settle The runaway growth circuit breaker latches the preview frame after 16 consecutive growing resize reports less than 500ms apart, and only a new renderer, a session reset or a `RENDERER_READY` handshake releases it. A CSS height transition produces exactly that pattern: Angular Material's expansion panel animates over 225ms, which the renderer reports as about a dozen per-frame growth steps at 60Hz and twice that on a 120Hz display, so expanding a panel in a Canvas can trip the breaker. Once latched the frame only accepts smaller heights, so a collapse ratchets the ceiling down and the canvas ends up clipped to a fraction of its content until the renderer is reloaded. Streamed surfaces that grow quickly hit the same latch. A hold is now a probe rather than a verdict. A feedback loop only grows because the host applies each reported height, so a held guest that keeps reporting larger heights is growing on its own; the hold is released after three such reports, at most twice per growth run so a guest that answers every applied height with a burst of growth is still caught. A held guest that falls silent has its last reported height applied after 500ms, which is where a finished transition ended up; growth arriving within 500ms of that applied height is the reaction a real loop produces, so the hold is kept and the loop is logged as a warning until the reports settle. Any non-growing or late report ends the run and clears the hold, so the frame no longer ratchets downward. A tentative hold logs at info level, and the settle timer is dropped when the component is destroyed. The threshold stays at 16, and the existing resets on `RENDER_SUCCESS`, renderer change and session reset are kept. `resetGrowthRun` now keeps the last report so the next one is still judged against it: new content sent to a held guest does not end the hold by itself, but it withdraws an outstanding probe, since new content is a legitimate reason to grow right after a settled height was applied. The spec drives the breaker with a guest that only grows after the host has applied the previous report, which is what distinguishes a loop from a transition, and covers transitions of various lengths, the settle and confirmation paths, new content arriving after a probe, the release cap, and teardown.
A settle timer armed for the previous content could fire after new content was sent, apply that content's height and arm a probe that would take the new content's first report for a confirmed feedback loop.
…lied The probe recorded the apply as happening one runaway interval after the last report, which is when the settle timer was due rather than when it fired. A throttled timer (a background tab, say) fires later, and the guest's reaction to the apply would then fall outside the window and pass for the start of an unrelated run. Envelope timestamps are the host's receipt times, so Date.now() at the apply is the same clock. The breaker specs now fake Date as well and move the clock to each envelope's receipt time before emitting it, so the settle timer fires on the same timeline as the synthetic reports.
mikzat
force-pushed
the
fix/release-growth-breaker-on-settle
branch
from
October 8, 2026 22:26
12a77bd to
0a754f2
Compare
jgindin
approved these changes
Oct 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The runaway growth circuit breaker latches the preview frame after 16 consecutive growing resize reports less than 500ms apart, and only a new renderer, a session reset or a
RENDERER_READYhandshake releases it. A CSS height transition produces exactly that pattern: Angular Material's expansion panel animates over 225ms, which the renderer reports as about a dozen per-frame growth steps at 60Hz and twice that on a 120Hz display, so expanding a panel in an inline surface can trip the breaker. Once latched the frame only accepts smaller heights, so a collapse ratchets the ceiling down and the surface ends up clipped to a fraction of its content until the renderer is reloaded. Streamed surfaces that grow quickly hit the same latch.This matters for the inline frames in chat bubbles, which size themselves to the guest's reports and therefore need the breaker. (#257 makes the side canvas fill its panel and ignore the reports, so the canvas no longer depends on the breaker either way.)
A hold is now a probe rather than a verdict. A feedback loop only grows because the host applies each reported height, so a held guest that keeps reporting larger heights is growing on its own; the hold is released after three such reports, at most twice per growth run so a guest that answers every applied height with a burst of growth is still caught. A held guest that falls silent has its last reported height applied after 500ms, which is where a finished transition ended up; growth arriving within 500ms of that apply is the reaction a real loop produces, so the hold is kept and the loop is logged as a warning until the reports settle. Any non-growing or late report ends the run and clears the hold, so the frame no longer ratchets downward. A tentative hold logs at info level, and the settle timer is dropped when the component is destroyed.
The threshold stays at 16, and the existing resets on
RENDER_SUCCESS, renderer change and session reset are kept.resetGrowthRunnow keeps the last report so the next one is still judged against it: new content sent to a held guest does not end the hold by itself, but it withdraws an outstanding probe and drops a settle timer armed for the previous content, since new content is a legitimate reason to grow right after a settled height was applied. The probe is timed from when the settled height was actually applied (Date.now(), the same clock as the envelope receipt timestamps) rather than from when the settle timer was due, so a throttled timer in a background tab does not push the guest's reaction outside the window.Verification
rendered-frame.spec.ts(48 specs) drives the breaker with a guest that only grows after the host has applied the previous report, which is what distinguishes a loop from a transition, and covers transitions of various lengths, the settle and confirmation paths, new content arriving after a probe or while a settle timer is armed, the release cap, and teardown. The breaker specs fakeDatealongside the timers and move the clock to each envelope's receipt time, so the settle timer fires on the same timeline as the synthetic reports.prettier --check,eslint, andtsc -p tsconfig.json --noEmitare clean inshell/.