fix(web): stop scrollbar-oscillation relayout loop in LinearLayoutManager#2361
Open
momomuchu wants to merge 1 commit into
Open
fix(web): stop scrollbar-oscillation relayout loop in LinearLayoutManager#2361momomuchu wants to merge 1 commit into
momomuchu wants to merge 1 commit into
Conversation
…nager On web with classic (non-overlay) scrollbars, borderline-overflow content can enter an infinite scrollbar show/hide feedback loop: showing the vertical scrollbar narrows the measured cross-axis width (boundedSize), which reflows items so content no longer overflows, which hides the scrollbar, which widens the measurement again... crashing with "Maximum update depth exceeded". updateLayoutParams recomputed on ANY boundedSize change with no hysteresis, so a ~15-17px scrollbar-width oscillation looped forever. Detect an A/B/A bounce within a 20px threshold, lock boundedSize to the stable (narrower) value, and ignore further scrollbar-width noise until a genuinely larger resize arrives (which unlocks and re-baselines). Adds pure-TS regression tests: an oscillating width sequence now converges (recompute count bounded) instead of recomputing unboundedly, while a real resize past the threshold still recomputes. Closes Shopify#2334
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.
On web with classic (non-overlay) scrollbars, borderline-overflow content makes the scrollbar toggle on and off every frame, which loops relayout forever and crashes with "Maximum update depth exceeded".
updateLayoutParams()recomputed on anyboundedSizechange with no hysteresis, so a ~17px scrollbar-width delta alternated indefinitely. This adds A/B/A oscillation detection: when the cross-axis size alternates between two values within a scrollbar-width threshold (20px), it locks to the narrower one and treats further sub-threshold changes as noise. A real resize past the threshold unlocks and re-baselines; an axis flip clears the lock.The test is a pure layout-manager unit test that feeds an oscillating width sequence and asserts convergence instead of unbounded recompute. It fails without the fix (10 unbounded recomputes) and passes with it. Layout-manager and grid/masonry suites green, tsc and lint clean.
Closes #2334